apicloud 打开高德地图进行导航

function openmap(lon,lat)
{
     
    var location = $api.getStorage('location');
    if(location){
     
      var mylon = location.lon;
      var mylat = location.lat;
    }
    else {
     
      $.alert('请允许程序获取当前位置');
      return false;
    }
    var uri="";
    uri +='androidamap://navi?';
    uri +='sourceApplication='+api.appName;
    uri +='&poiname=酒店';
    uri +='&lat='+lat+'&lon='+lon;
    uri +='&dev=1';
    uri +='&style=2';
    api.openApp({
     
        // androidPkg: 'com.autonavi.minimap',
        androidPkg: 'android.intent.action.VIEW',
        appParam:{
     
          lat:lat,
          lon:lon,
          dev:'0',
          style:'2',
          sourceApplication:api.appName
        },
        iosUrl:'iosamap://navi',
        uri: uri
    }, function(ret, err) {
     
        if (ret) {
     

        } else {
     
            console.log(JSON.stringify(err));
            $.toast('未安装高德地图');
        }
    });
}

参考链接1
参考链接2


  //百度导航     //同步返回结果:
            function baiduditu(){
     
               var systemType = api.systemType;
               var buttons = new Array();
               var amap_installed = false;
               var bmap_installed = false;
               if(systemType=='ios'){
     
                 var installed = api.appInstalled({
     
                     sync: true,
                     appBundle:'iosamap://'
                 });
                 if (installed) {
     
                     amap_installed = true;
                     buttons.push('高德地图');
                 }
                 var installed = api.appInstalled({
     
                     sync: true,
                     appBundle:'baidumap://'
                 });
                 if (installed) {
     
                     bmap_installed = true;
                     buttons.push('百度地图');
                 }
               }else{
     
                 var installed = api.appInstalled({
     
                     sync: true,
                     appBundle: 'com.autonavi.minimap'
                 });
                 if (installed) {
     
                     amap_installed = true;
                     buttons.push('高德地图');
                 }
                 var installed = api.appInstalled({
     
                     sync: true,
                     appBundle: 'com.baidu.BaiduMap'
                 });
                 if (installed) {
     
                     bmap_installed = true;
                     buttons.push('百度地图');
                 }
               }
               if(bmap_installed==false && amap_installed==false){
     
                 api.toast({
     
                   msg:'您没有安装任何地图软件'
                 });
                 return false;
               }

               var address = $('.latlng').attr('address');
               var latbaidu = $('.latlng').attr('latbaidu');
               var lngbaidu = $('.latlng').attr('lngbaidu');
               var latgaode = $('.latlng').attr('latgaode');
               var lnggaode = $('.latlng').attr('lnggaode');
               api.actionSheet({
     
                   cancelTitle: '取消',
                   buttons: buttons
               }, function(ret, err) {
     
                   var index = ret.buttonIndex;

                   switch (index) {
     
                     case 1:
                       if(amap_installed && bmap_installed){
     
                         if(systemType=='ios'){
     
                           api.openApp({
     
                               iosUrl: 'iosamap://path?sourceApplication=applicationName&sid=BGVIS1&did=BGVIS2&dlat='+latgaode+'&dlon='+lnggaode+'&dname='+address+'&dev=0&t=3',
                           }, function(ret, err) {
     

                           });
                         }else{
     
                           api.openApp({
     
                               androidPkg: 'android.intent.action.VIEW',
                               uri: 'amapuri://route/plan/?dlat='+latgaode+'&dlon='+lnggaode+'&dname='+address+'&dev=0&t=3'
                           }, function(ret, err) {
     

                           });
                         }
                       }else{
     
                         if(amap_installed){
     
                           if(systemType=='ios'){
     
                             api.openApp({
     
                                 iosUrl: 'iosamap://path?sourceApplication=applicationName&sid=BGVIS1&did=BGVIS2&dlat='+latgaode+'&dlon='+lnggaode+'&dname='+address+'&dev=0&t=3',
                             }, function(ret, err) {
     

                             });
                           }else{
     
                             api.openApp({
     
                                 androidPkg: 'android.intent.action.VIEW',
                                 uri: 'amapuri://route/plan/?dlat='+latgaode+'&dlon='+lnggaode+'&dname='+address+'&dev=0&t=3'
                             }, function(ret, err) {
     

                             });
                           }

                         }
                         if(bmap_installed){
     
                           if(systemType=='ios'){
     
                             api.openApp({
     
                                 iosUrl: 'baidumap://map/direction?destination=latlng:'+latbaidu+','+lngbaidu+'|name:'+address+'&mode=riding',
                             }, function(ret, err) {
     
                                 if (err) {
     

                                     //alert(JSON.stringify(err));
                                 }
                             });
                           }else{
     
                             api.openApp({
     
                                 androidPkg: 'android.intent.action.VIEW',
                                 uri: 'baidumap://map/direction?destination=latlng:'+latbaidu+','+lngbaidu+'|name:'+address+'&mode=riding'
                             }, function(ret, err) {
     

                             });
                           }
                         }
                         break;
                       }

                     case 2:
                       if(systemType=='ios'){
     
                         api.openApp({
     
                             iosUrl: 'baidumap://map/direction?destination=latlng:'+latbaidu+','+lngbaidu+'|name:'+address+'&mode=riding',
                         }, function(ret, err) {
     
                             if (err) {
     
                                 //alert(JSON.stringify(err));

                             }
                         });
                       }else{
     
                         api.openApp({
     
                             androidPkg: 'android.intent.action.VIEW',
                             uri: 'baidumap://map/direction?destination=latlng:'+latbaidu+','+lngbaidu+'|name:'+address+'&mode=riding'
                         }, function(ret, err) {
     
                             if (err) {
     
                                 //alert(JSON.stringify(err));
                             }
                         });
                       }
                       break;
                   }
               });
             }

你可能感兴趣的:(apicloud,apicloud地图导航)