2017-03-19 5 views
1

Google Direction APIから来たiOS上のGoogleマップで経路を描こうとしました。 私はその後、私はスタートラインは、その座標に開始、しかし最も近い方法でないように見えますGMSPolyline出発地と目的地がGoogle Maps SDKに正確に配置されていない

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; 

で私が描くそのルートを持っ

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

をこのエンドポイントをヒット。下の画像を参照してください。

google direction

その「開始方向」へ座標から線を描画することが可能ですか?もしそうなら、どんな助けもありがとう。ありがとうございました。

+1

開始線の座標と実際の開始点の間にポリラインを描くことができます。 –

+0

"出発方向"とは何を意味しますか? –

+0

開始方向はGoogleの方向からの開始点です。実際の出発点は、Googleの方向APIへのパラメータとして使用する私の最初のポイントです –

答えて

0

mapViewの開始点と実際の開始点からポリラインを描く必要があります。

GMSMutablePath *path = [GMSMutablePath path]; 
[path addCoordinate:CLLocationCoordinate2DMake(actualLat,actualLon)]; 
[path addCoordinate:CLLocationCoordinate2DMake(startLat,startLon)]; 
GMSPolyline *polyline = [GMSPolyline polylineWithPath:path]; 
関連する問題