iOS,如何使用Google Places Api显示两点之间的路线?

我一直在寻找如何在iOS中使用Google Places API绘制两点之间的路线 ,但是我还没有find有趣的地方。 您可以在两点之间绘制路线的唯一方法是调用Web服务并将JSONparsing到您的应用程序中,以在两点之间路由路线。 这里有一个参考。

问题是:

是否有任何示例代码可以帮助我如何绘制两点之间的路线,起点(基于用户当前位置)和目的地。

我使用这个图书馆 ,非常强大…用这个你可以绘制两点之间的方向和更多

你可以得到一个谷歌开发者的教程作为参考。 你可以查看这个 YouTube教程的指导。

希望这可以帮助。 干杯:)

- (void)viewDidLoad { [super viewDidLoad]; GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:30.692408 longitude:76.767556 zoom:14]; GMSMapView *mapView = [GMSMapView mapWithFrame:CGRectZero camera:camera]; mapView.myLocationEnabled = YES; // Creates markers in the center of the map. GMSMarker *marker = [[GMSMarker alloc] init]; marker.position = CLLocationCoordinate2DMake(30.6936659, 76.77201819999999); marker.title = @"Chandigarh 47c"; marker.snippet = @"Hello World"; marker.map = mapView; GMSMarker *marker1 = [[GMSMarker alloc] init]; marker1.position = CLLocationCoordinate2DMake(30.742138, 76.818756); marker1.title = @"Sukhna Lake"; marker1.map = mapView; //creating a path GMSMutablePath *path = [GMSMutablePath path]; [path addCoordinate:CLLocationCoordinate2DMake(@(30.6936659).doubleValue,@(76.77201819999999).doubleValue)]; [path addCoordinate:CLLocationCoordinate2DMake(@(30.742138).doubleValue,@(76.818756).doubleValue)]; GMSPolyline *rectangle = [GMSPolyline polylineWithPath:path]; rectangle.strokeWidth = 2.f; rectangle.map = mapView; self.view=mapView; }