zoukankan      html  css  js  c++  java
  • iOS打开百度地图、高德地图导航

    1、判断手机里是否已经安装了百度地图或者高德地图:

            BOOL hasBaiduMap = NO;  
            BOOL hasGaodeMap = NO;  
              
            if ([[UIApplication sharedApplication]canOpenURL:[NSURL URLWithString:@"baidumap://map/"]]){  
                hasBaiduMap = YES;  
            }  
            if ([[UIApplication sharedApplication]canOpenURL:[NSURL URLWithString:@"iosamap://"]]){  
                hasGaodeMap = YES;  
            }    
    

     2、选择打开对应的地图进行导航:

            if ([@"使用百度地图导航" isEqualToString:title])  
            {  
                NSString *urlString = [[NSString stringWithFormat:@"baidumap://map/direction?origin=latlng:%f,%f|name:我的位置&destination=latlng:%f,%f|name:终点&mode=driving",currentLat, currentLon,_shopLat,_shopLon] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding] ;  
                  
                [[UIApplication sharedApplication]openURL:[NSURL URLWithString:urlString]];  
            }  
            else if ([@"使用高德地图导航" isEqualToString:title])  
            {  
                NSString *urlString = [[NSString stringWithFormat:@"iosamap://navi?sourceApplication=%@&backScheme=%@&poiname=%@&lat=%f&lon=%f&dev=1&style=2",@"app name", yourscheme, @"终点", _shopLat, _shopLon] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];  
      
                [[UIApplication sharedApplication]openURL:[NSURL URLWithString:urlString]];  
            }      
    
  • 相关阅读:
    csrf & xss
    android_sqlite
    android_error
    oracle笔记
    android_lesson_1
    mysql 设置编码
    前端进阶Event
    前端进阶Position
    chrome插件开发资料
    dom4j selectNodes
  • 原文地址:https://www.cnblogs.com/huahua0809/p/5235670.html
Copyright © 2011-2022 走看看