微信小程序經緯度獲取地圖導航(導航接入第三方)


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 //導航詳細地址
    })
  },

效果圖
在這里插入圖片描述


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM