美文网首页
判断ios还是安卓,以此调用百度地图app

判断ios还是安卓,以此调用百度地图app

作者: 文朝明 | 来源:发表于2019-08-01 15:00 被阅读0次
    $('#baidumap').click(function() {
                // alert(lat + '3' + lng)
    
                // location.href = "baidumap://map/direction?mode=[transit:公交,driving:驾车]&origin=" + lat + "," + lng + "&destination=" + lat + "," + lng + "®ion=332"
                // 判断ios还是安卓
                // var themath = 0
                var u = navigator.userAgent,
                    isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1
                isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/)
                    // alert('是否是Android:' + isAndroid);
                    // alert('是否是iOS:' + isiOS);
                if (isAndroid == true) {
                    // android 端
                    // alert("location=" + shareLat + "," + shareLng)
                    location.href = "bdapp://map/marker?location=" + shareLat + "," + shareLng + "&title=" + sharaTitle + "&content=" + shareaddr + "&traffic=on&src=andr.baidu.openAPIdemo'"
                } else if (isiOS == true) {
                    // ios 端
                    location.href = "baidumap://map/navi?location=" + shareLat + "," + shareLng + "coord_type=bd09ll&type=BLK&src=ios.baidu.openAPIdemo"
                } else {
    
                }
    
    
            })
    

    相关文章

      网友评论

          本文标题:判断ios还是安卓,以此调用百度地图app

          本文链接:https://www.haomeiwen.com/subject/zloqdctx.html