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

2019-08-01  本文已影响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 {

            }


        })
上一篇下一篇

猜你喜欢

热点阅读