我想繪製從我的mapView
(GMSMapView
)上的點A到點B的路線。在GMSMapView(Google Maps iOS SDK)上繪製路線
我一直試圖做這樣的:
GMSMutablePath *path=[GMSMutablePath path];
[path addCoordinate:self.locationManager.location.coordinate];
[path addCoordinate:marker.position];
GMSPolyline *rectangle=[GMSPolyline polylineWithPath:path];
rectangle.strokeWidth=2.f;
rectangle.map=self.mapView;
,但它只是畫了一條線A點連接到B點,但不是路由本身(通過街道的方向,道路等.. )。
我想在地圖上畫出從步行到達點B的最佳方式。
我該怎麼做?
謝謝!
深入瞭解谷歌地圖API(https://developers.google.com/maps/documentation/directions/intro#DirectionsRequests)你的答案 – Hima
@Hima你可以給我一個代碼示例,我該怎麼做?謝謝! –
他們已經給出了關於如何調用API的查詢方法,請查找「https://maps.googleapis.com/maps/ api/directions/json?origin = sydney,au&destination = perth,au&waypoints = via:-37.81223%2C144.96254%7C-34.92788%2C138.60008&key = YOUR_API_KEY 「in the Waypoints ** topic in the page。 – Hima