ios - 如何在ios的谷歌地图上实现道路路线导航

标签 ios google-maps

我要求使用 轮流GPS导航 .任何人都可以告诉如何集成谷歌地图轮流gps导航。

向我建议有关此问题的任何文档。我不想使用 URL Scheme 进行导航。

所以请指导我如何在我的应用程序中使用 map 导航。

最佳答案

如果您使用的是 Google Maps SDK,则使用它的方法来显示两个地方之间的路径:

-(void)drawPathFrom{

    NSString *baseUrl = [NSString stringWithFormat:@"https://maps.googleapis.com/maps/api/directions/json?origin=%@&destination=%@&sensor=true", @"Safdarjung enclave South delhi", @"chandni chownk new delhi"];

    NSURL *url = [NSURL URLWithString:[baseUrl stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
    NSLog(@"Url: %@", url);
    NSURLRequest *request = [NSURLRequest requestWithURL:url];

    [NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) {
        if(!connectionError){
            NSDictionary *result        = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
            NSArray *routes             = [result objectForKey:@"routes"];
            NSDictionary *firstRoute    = [routes objectAtIndex:0];
            NSString *encodedPath       = [firstRoute[@"overview_polyline"] objectForKey:@"points"];

            GMSPolyline *polyPath       = [GMSPolyline polylineWithPath:[GMSPath pathFromEncodedPath:encodedPath]];
            polyPath.strokeColor        =aNumber;
            polyPath.strokeWidth        = 5.5f;
            polyPath.map                = mapView;
        }
    }];
}

关于ios - 如何在ios的谷歌地图上实现道路路线导航,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31962372/

相关文章:

google-maps - 谷歌地图破坏 KML

ios - 将 Parse.com 导入 Xcode 的 Prefix.pch 的导入类生成错误

ios - Swift 中多个 UIViewContoller 中的 NSNotification 处理

android - Mapbox Android - 如何绘制带孔的 GeoJSON 多边形

android - 设计一个形状像谷歌信息窗口的 View

android - 如何将按钮添加到标记的信息窗口?

ios - 快速总结 Realm 对象数组中的属性

ios - 在 UIPageControl 中添加点边框

ios - 当应用程序未在 React-Native firebase 中运行时如何设置通知声音

javascript - Google map 标记数组对象未显示