apicloud地图导航

  //百度导航     //同步返回结果:
            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)