当前项目是uniapp项目,若不是需要替换uni.showActionSheet选择api
onMap(address = '', organName = '', longitude = 0, latitude = 0){var ua = navigator.userAgent.toLowerCase();var isWeixin = ua.indexOf('micromessenger') != -1;if(isWeixin) {const mapUrl_tx = "http://apis.map.qq.com/uri/v1/marker?marker=coord:" + latitude + "," + longitude + ";title:" + organName + ";addr:" + address + "&referer=yellowpage";window.open(mapUrl_tx)return false}const actions = [{id:1, name: '腾讯地图' }, {id:2, name: '百度地图' }, {id:3, name: '高德地图' }]uni.showActionSheet({itemList: actions.map(item => item.name),success: (res)=> {let url = "";const u = navigator.userAgent;const isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);const isAndroid = u.indexOf('Android') > -1 || u.indexOf('Linux') >-1;let index = actions[res.tapIndex].idif(isAndroid){switch (index) {case 1:url = `qqmap://map/geocoder?coord=${latitude},${longitude}&referer=H7JBZ-5WUWN-BHDFN-SEHOK-RREKF-I3BD5`;break;case 2:url = `baidumap://map/marker?location=${latitude},${longitude}&title=${address}&coord_type=gcj02&src=andr.baidu.openAPIdemo`;break;case 3:url = `androidamap://viewMap?sourceApplication=appname&poiname=${address}&lat=${latitude}&lon=${longitude}&dev=0`;break;default:break;}if (url != "") {window.open(url,"_blank")}}else if(isiOS){switch (index) {case 1:url = `qqmap://map/geocoder?coord=${latitude},${longitude}&referer=H7JBZ-5WUWN-BHDFN-SEHOK-RREKF-I3BD5`;break;case 2:url = `baidumap://map/marker?location=${latitude},${longitude}&title=${address}&content=${address}&src=ios.baidu.openAPIdemo&coord_type=gcj02`;break;case 3:url = `iosamap://viewMap?sourceApplication=applicationName&poiname=${address}&lat=${latitude}&lon=${longitude}&dev=0`;break;default:break;}if (url != "") {window.open(url,"_blank")}}},fail: function (res) {console.log(res.errMsg)}})
}