【发布时间】:2016-03-08 08:34:03
【问题描述】:
我想在我的mapView (GMSMapView) 上画一条从 A 点到 B 点的路线。
我试过这样做:
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 的线,而不是路线本身(通过街道、道路等的方向......)。
我想在地图上画出步行从 A 点到 B 点的最佳方式。
我该怎么做?
谢谢!
【问题讨论】:
-
深入了解 Google Directions API (developers.google.com/maps/documentation/directions/…) 以获得答案。
-
@Hima 你能给我一个代码示例,我该怎么做?谢谢!
-
他们已经给出了关于如何调用路线API的查询,在该页面的Waypoints主题中找到“maps.googleapis.com/maps/api/directions/…”。
标签: ios objective-c iphone cocoa-touch google-maps-sdk-ios