效果图:
核心代码:
要显示地图并可以实现导航时,只需要调用如下函数,然后传入要显示在地图中的经纬度和要进行导航的位置名称
/**
* 查看位置
* latitude longitude 表要展示在地图中的经纬度
* name 表示要导航的位置名称
*/
viewLocation: function (latitude = 30.791611,longitude = 111.310880, name = '夷陵区殡仪馆') {
wx.getSetting({
success: (res) => {
if (res.authSetting['scope.userLocation'] != undefined && res.authSetting['scope.userLocation'] != true) {
wx.showModal({
title: '是否授权当前位置',
content: '需要获取您的地理位置,请确认授权,否则地图定位功能将无法使用',
success: