您当前的位置: 首页 >  ios

培根芝士

暂无认证

  • 1浏览

    0关注

    446博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

iOS调用程序外地图导航

培根芝士 发布时间:2015-09-09 11:42:28 ,浏览量:1

        //导航

        if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"baidumap://map/"]]) {

            //百度app导航

            NSString *urlstr = [NSString stringWithFormat:@"baidumap://map/direction?origin=%f,%f&destination=%f,%f&mode=driving&src=iHope", _newCoordinate.latitude, _newCoordinate.longitude, _destLocation.latitude, _destLocation.longitude];

            NSLog(@"%@", urlstr);

            [[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlstr]];

        }

        else {

            //系统地图导航

            MKMapItem *currentLocation = [MKMapItem mapItemForCurrentLocation];

            MKMapItem *toLocation = [[MKMapItem alloc] initWithPlacemark:[[MKPlacemark alloc] initWithCoordinate:_destLocationaddressDictionary:nil]];

            toLocation.name = self.destName;

            

            [MKMapItem openMapsWithItems:@[currentLocation, toLocation]

                           launchOptions:@{MKLaunchOptionsDirectionsModeKey: MKLaunchOptionsDirectionsModeDriving,MKLaunchOptionsShowsTrafficKey: [NSNumber numberWithBool:YES]}];

        }

关注
打赏
1660824269
查看更多评论
立即登录/注册

微信扫码登录

0.0386s