亚洲中字慕日产2020,大陆极品少妇内射AAAAAA,无码av大香线蕉伊人久久,久久精品国产亚洲av麻豆网站

資訊專(zhuān)欄INFORMATION COLUMN

H5內(nèi)喚醒百度、高德APP

oogh / 2191人閱讀

摘要:有好的想法可以評(píng)論一下。下面放相關(guān)代碼先走毫秒后調(diào)用鏈接這里放相關(guān)鏈接終端高德蘋(píng)果和安卓頭部不一樣百度蘋(píng)果和安卓頭部不一樣

前幾天,聯(lián)合黑卡反饋了一個(gè)需求,需要在H5中打開(kāi)百度APP或者是高德APP,于是我在網(wǎng)上查了相關(guān)文檔,下面放上鏈接: 1.高德地圖 2.百度地圖

具體思路就是點(diǎn)擊選擇地圖的時(shí)候,先去請(qǐng)求APP鏈接,800毫秒后無(wú)響應(yīng),再跳轉(zhuǎn)至H5鏈接。這樣的做法有一點(diǎn)不好就是不管跳不跳APP,都會(huì)跳到H5的鏈接。有好的想法可以評(píng)論一下。

下面放相關(guān)代碼:

         function  ToggleAppAndH5( AppUrl , AppCallback = () => {}){
             // 先走APP
            const ifr = document.createElement("iframe");
                ifr.src = AppUrl;
                ifr.style.display = "none";
                document.body.appendChild(ifr);
                setTimeout(function(){
                    document.body.removeChild(ifr);
                }, 3000);
            
                  // 800毫秒后調(diào)用H5鏈接
                let timer = setTimeout(function () {
                        clearTimeout(timer);
                        AppCallback();
                }, 800);
        
                window.onblur = function () {
                    clearInterval(timer);
                };
         }

        function Callback(){
           // 這里放相關(guān)H5鏈接
           if (mapType === "baidu") {
              frameDom.attr("src", "http://api.map.baidu.com/direction?origin=latlng:"+  curLat +","+ curLng +"|name:"+ currAddr +"&destination=latlng:"+  elat +","+ elng +"|name:"+ eaddr +"®ion="+ cityName +"&mode=driving&output=html&src=com.youbei.chefu");
           } else if (mapType === "amap") {
              frameDom.attr("src", "https://ditu.amap.com/dir?type=car&from[lnglat]="+ curLng +","+ curLat +"&from[name]="+currAddr+"&to[lnglat]="+ elng +","+ elat +"&to[name]="+eaddr+"&src=com.youbei.chefu");
           }
         }

         const u = navigator.userAgent;
         const isiOS = !!u.match(/(i[^;]+;( U;)? CPU.+Mac OS X/); //ios終端
         

1. 高德

   // 蘋(píng)果和安卓頭部不一樣
   let proto = isiOS ? "iosamap://path" : "amapuri://route/plan"  ;

   const AppUrl = proto + "?t= 0&slat="+curLat+"&slon="+curLng+"&sname="+currAddr+"&dlat="+elat+"&dlon="+elng+"&dname="+eaddr+"&src=xxx";

   ToggleAppAndH5(AppUrl,Callback)

2.百度

   // 蘋(píng)果和安卓頭部不一樣
   let proto = isiOS ? "baidumap://"  : "bdapp://" 

   const AppUrl = proto +  "map/direction?region="+cityName+"&origin=latlng:"+ curLat+","+ curLng +"|name:"+ currAddr +"&destination=latlng:"+ elat +","+ elng +"|name:"+ eaddr +"&coord_type=bd09ll&mode=driving&src=com.youbei.chefu";
   
   ToggleAppAndH5(AppUrl, Callback)
            

文章版權(quán)歸作者所有,未經(jīng)允許請(qǐng)勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。

轉(zhuǎn)載請(qǐng)注明本文地址:http://www.ezyhdfw.cn/yun/109580.html

相關(guān)文章

發(fā)表評(píng)論

0條評(píng)論

閱讀需要支付1元查看
<