繁体   English   中英

带有多个目标的苹果或谷歌地图的ios导航

[英]ios navigation with apple or google maps with several targets

我可以从我的应用程序中打开苹果地图应用程序,以计算从当前位置到我的地标的路线,并且效果很好。

但是现在我有了给定顺序的几个地标列表,并希望将它们发送到maps应用程序,以用作从第一个到最后一个地标的路线之间的目标。 这可能吗?

我可以替代地在safari上启动google map,从而可以在url中设置多个目标: https : //maps.google.com/maps? saddr = first & daddr = second & daddr = third+to: final&hl= zh- CN

我使用下面的代码,它可以正常工作几个月,但是现在新版的Google地图在线版本不再支持这样要求的多个目标。

因此,您需要像这样调整网址: https//www.google.com/maps/dir/longitude,纬度/ 经度,纬度

在这里您可以找到有关url搜索的更多信息: http : //gearside.com/easily-link-to-locations-and-directions-using-the-new-google-maps/

我当前的解决方案是使用链接在safari上打开google地图,在其中添加+至:目标之间的目标:

for (int i == 0; int i < route.count; i++) {
        if (i == 0) {
            NSString *start = [NSString stringWithFormat:@"http://maps.google.com/maps?saddr=%f,%f", latitude, longitude];
            locationString = start;
        }

        if (i != 0 && i != route.count - 1) {
            NSString *between = [NSString stringWithFormat:@"+to:%f,%f", latitude, longitude];
            locationString = [locationString stringByAppendingString:between];
        }

        if (i == route.count - 1) {
            NSString *end = [NSString stringWithFormat:@"&daddr=%f,%f", latitude, longitude];
            NSString *type = @"&dirflg=w";
            locationString = [locationString stringByAppendingString:end];
            locationString = [locationString stringByAppendingString:type];
        }
    }

NSURL *url = [NSURL URLWithString:locationString];
[[UIApplication sharedApplication] openURL:url];

如果我使用的是iOS 5或6 sSimulator,它将在Safari上的maps.google.com移动版上打开链接,则此方法可以正常工作

但是当我在iOS 5设备上以及可能在安装了Google Maps的iOS6设备上运行它时,链接会在Google Maps中启动,并且路线绘制错误(特别是有许多目标),并且中间的目标没有注释...

有人知道如何强制在Safari中打开链接蜂吗?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM