调用系统路线导航

想参考米途订酒店客户端来做酒店地图那一块,调用系统的地图来标示出导航路线;
于是找了下例子,
NSString *theString = [NSString stringWithFormat:@"http://maps.google.com/maps?saddr=Current Location&daddr=%f,%f",Location.latitude, Location.longitude];
    theString =  [theString stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding];
   
    NSURL *url = [[NSURL alloc] initWithString:theString];
    [[UIApplication sharedApplication] openURL:url];
这段代码就是调用自带的googlemap,模拟器显示的是webView,真机显示才会是调用系统的东西;


NSString *urlString = [[NSString alloc]
     initWithFormat:@"http://maps.google.com/maps?saddr=%f,%f&daddr=%f,%f&dirfl=d",
        curLocation.latitude,
        curLocation.longitude,
        stationLocation.latitude,
        stationLocation.longitude];

NSURL *aURL = [NSURL URLWithString:urlString];
[urlString release];
[[UIApplication sharedApplication] openURL:aURL];

调用这个貌似也一样,但是比前面那个网址多了个&dirfl=d,没什么区别,我也是网上看到的别人写的,不知道这里的不同会不会有什么区别,目前从效果上是没看到任何区别的;


 [[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://maps.google.com/maps?saddr=%f,%f&daddr=%@",loc.latitude,loc.longitude,中国山东济南市某某街某某号]]];
出发地选用的参数为经纬度,可以通过手机gps获得(具体实现在下篇),目的地可以是位置名称,也可以是经纬度(没用过)。http://blog.sina.com.cn/s/blog_68eb52b3010141pe.html

目的地可以是位置名称,不一定是经纬度;

刚开始用这个 http://maps.apple.com/maps?saddr=%f,%f&daddr=%f,%f  原来这个是不可用的;
参考 http://www.cnblogs.com/zhulin/archive/2012/11/09/2761926.html


另外 画线路图有个什么overlay的东西;没仔细研究过

posted @ 2013-01-15 09:31  xiaoou  阅读(183)  评论(0编辑  收藏  举报