Ios 起点和终点未精确放置在Google Maps SDK上

Ios 起点和终点未精确放置在Google Maps SDK上,ios,google-maps,google-directions-api,Ios,Google Maps,Google Directions Api,我试图在iOS上用谷歌地图绘制一条路线,这条路线来自谷歌方向API。 我到达了终点 NSString *urlString = [NSString stringWithFormat:@"https://maps.googleapis.com/maps/api/directions/json?origin=%@&destination=%@&mode=driving&key=%@", origin, destination, gDirectionKey]; 然后我用GMS

我试图在iOS上用谷歌地图绘制一条路线,这条路线来自谷歌方向API。 我到达了终点

NSString *urlString = [NSString stringWithFormat:@"https://maps.googleapis.com/maps/api/directions/json?origin=%@&destination=%@&mode=driving&key=%@", origin, destination, gDirectionKey];
然后我用
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;
看起来起跑线不是以坐标开始的,而是以最近的方式开始的。见下图


有没有可能从它的坐标到“起始方向”划出一条线?如果是这样,我们将不胜感激。谢谢。

您需要从google direction结果的起点和mapView中的实际起点绘制一条多段线

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

您需要从google direction结果的起点和mapView中的实际起点绘制一条多段线

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

可以在起点坐标和实际起点之间绘制多段线!!“起始方向”是什么意思?起始方向是来自谷歌方向结果的起始点。实际起点是我的初始点,我用它作为谷歌方向的参数。你可以在起点坐标和实际起点之间画一条多段线!!“起始方向”是什么意思?起始方向是来自谷歌方向结果的起始点。实际起点是我的初始点,我将其用作google direction API的参数