幾度設(shè)計(jì)網(wǎng)站軟文推廣新聞發(fā)布
需求
- 小程序中有個(gè)按鈕點(diǎn)擊以后會(huì)調(diào)用手機(jī)中第三方地圖進(jìn)行導(dǎo)航。
- 參數(shù) 位置信息 經(jīng)度 與緯度。
實(shí)現(xiàn)方法
uni.openLocation({latitude: Number('地址緯度'),longitude: Number('地址經(jīng)度'),name: '地址名稱(chēng)',address: '地址詳情',success: function (res) {console.log('打開(kāi)系統(tǒng)位置地圖成功')},fail: function (error) {console.log(error)}
原本以為一切順利,結(jié)果在微信開(kāi)發(fā)者工具中顯示如下:
location參數(shù)格式錯(cuò)誤,請(qǐng)正確填寫(xiě)
經(jīng)過(guò)測(cè)試發(fā)現(xiàn),因?yàn)槲以谖⑿判〕绦蛑惺褂?#xff0c;所以默認(rèn)會(huì)使用騰訊地圖來(lái)顯示。
而我的經(jīng)度和緯度的信息源開(kāi)其他地圖軟件,格式上好像是不兼容的。
騰訊地圖獲取坐標(biāo)點(diǎn)工具如下
https://lbs.qq.com/getPoint/
在這里獲取到的坐標(biāo)點(diǎn),就可以正常顯示了。
我的最終代碼如下:
uni.openLocation({longitude: Number(118.797962),latitude: Number(32.086816), name: '南京站',address: '江蘇省南京市玄武區(qū)龍?bào)绰?#39;,success: function (res) {console.log('打開(kāi)系統(tǒng)位置地圖成功')},fail: function (error) {console.log(error)}
從明面上來(lái)看坐標(biāo)的精度是保存小數(shù)點(diǎn)后6位
注意事項(xiàng)
latitude 緯度
longitude 經(jīng)度
不要搞返了,我一開(kāi)始就搞返了
參考
uniapp下各端調(diào)用三方地圖導(dǎo)航
https://juejin.cn/post/7262941534528700453
https://uniapp.dcloud.net.cn/api/location/open-location.html