API方法
wx.openLocation
我們需要用到微信官方文檔的位置API wx.openLocation
其中的參數有很多,具體可參考官方文檔:微信官方文檔-位置
所需參數
latitude(必填) :緯度,范圍為-90~90,負數表示南緯。使用 gcj02 國測局坐標系;
longitude(必填) :經度,范圍為-180~180,負數表示西經。使用 gcj02 國測局坐標系;
scale(非必填) :縮放比例,范圍5~18;
name(非必填) :位置名稱(打開第三方導航前的定位描述);
address(非必填) :詳細地址信息(打開導航后的地址描述);
wxml
bindtap="gomap"
<view class="flex" style="align-items: center;" bindtap="gomap" data-name="{{item}}" data-page="map">
導航
</view>
JS
gomap(e) {
const item=e.currentTarget.dataset.name
wx.openLocation({
latitude: item.currLatitude, //維度
longitude: item.currLongitude, //經度
name: item.branchAdress, //目的地定位名稱
scale: 15, //縮放比例
address: item.branchAdress+item.branchName //導航詳細地址
})
},
效果圖