微信小程序打开内置地图并通过外部地图进行导航

效果图: 

核心代码:

要显示地图并可以实现导航时,只需要调用如下函数,然后传入要显示在地图中的经纬度和要进行导航的位置名称

   /**
   * 查看位置
   * 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: 

猜你喜欢

转载自blog.csdn.net/qq_35366269/article/details/107197484