2017-03-19 3 views
1

Ich habe versucht, eine Route mit Google Maps auf iOS, die von Google Direction API stammen, zu zeichnen. Ich traf diesen EndpunktHerkunft und Zielpunkt ist nicht genau in Google Maps SDK platziert

NSString *urlString = [NSString stringWithFormat:@"https://maps.googleapis.com/maps/api/directions/json?origin=%@&destination=%@&mode=driving&key=%@", origin, destination, gDirectionKey]; 

Dann habe ich ihre Routen, die ich mit GMSPolyline

GMSPath *path =[GMSPath pathFromEncodedPath:resultData[@"routes"][0][@"overview_polyline"][@"points"]]; 
if (routeToCustomer == nil) 
    routeToCustomer = [[GMSPolyline alloc] init]; 
routeToCustomer.path = path; 
routeToCustomer.strokeWidth = 7; 
routeToCustomer.strokeColor = [UIColor colorWithHexString:ACTIVE_COLOR]; 
routeToCustomer.map = _mapView; 

zeichnen Es sieht aus wie, dass die Startlinie in seiner Koordinate startet nicht, aber in der nächsten Weg . Siehe Bild unten.

google direction

ist es möglich, seine Linie zu ziehen Koordinate in die „Start-Richtung“? Wenn ja, würde jede Hilfe geschätzt werden. Vielen Dank.

+1

Sie können eine Polylinie zwischen Startlinie Koordinate & tatsächlichen Startpunkt zeichnen! –

+0

Was bedeutet "Startrichtung"? –

+0

Startrichtung ist Startpunkt von Google-Richtung Ergebnis. Der tatsächliche Startpunkt ist mein Ausgangspunkt, den ich als Parameter für die Google-Richtungs-API verwende –

Antwort

0

Sie müssen eine Polylinie vom Startpunkt des Google-Richtungsergebnisses und vom tatsächlichen Startpunkt in mapView zeichnen.

GMSMutablePath *path = [GMSMutablePath path]; 
[path addCoordinate:CLLocationCoordinate2DMake(actualLat,actualLon)]; 
[path addCoordinate:CLLocationCoordinate2DMake(startLat,startLon)]; 
GMSPolyline *polyline = [GMSPolyline polylineWithPath:path]; 
Verwandte Themen