收藏
回答

地图模块的导航页不显示地址和名称?

在data数据的name和address不能传出来,下面的名字和地址显示不出Page({
  data: {
    longitude: 113.14278//地图界面中心的经度
    latitude: 23.02882//地图界面中心的纬度
    markers: [ //标志点的位置
      //位置0
      {
        id: 0,
        iconPath: "/image/1.png",
        latitude: 21.859222,
        longitude: 111.975107,
        name:'地点名称1',
        address:'地址的详细说明',
        width28,
        height32,
        callout:{
          content:'lcw'
          }, 
      },
      //位置1
      {
        id: 1,
        iconPath: "/image/1.png",
        latitude: 23.051546,
        longitude: 112.472529,
        name:'地点名称1',
        address:'地址的详细说明',
        width28,
        height32,
        callout:{
          content:'hxp' 
          },
      },
      //位置2
      {
        id: 2,
        iconPath: "/image/1.png",
        latitude: 22.26654,
        longitude: 113.5435,
        name:'地点名称1',
        address:'地址的详细说明',
        width28,
        height32,
        callout:{
          content:'hrs'
          },
      },
      //位置3
      {
        id: 3,
        iconPath: "/image/1.png",
        latitude: 21.37721,
        longitude: 110.25003,
        name:'地点名称1',
        address:'地址的详细说明',
        width28,
        height32,
        callout:{
          content:'zzh'
          },
      },
      //位置4
      {
        id: 4,
        iconPath: "/image/1.png",
        latitude: 22.547,
        longitude: 114.085947,
        name:'地点名称1',
        address:'地址的详细说明',
        width28,
        height32,
        callout:{
          content:'xpl',
          },
      },
    ]
  },


  onLoad(){
    let that = this
    wx.getLocation({
    type: 'wgs84',
    success(res) {
    console.log(res)
    that.setData({
    lat:res.latitude,
    lon:res.longitude,
    }) 
    } 
    })   
    },
    bindmarkertap(e){
    console.log(e.markerId)
    this.data.markers.forEach((item)=>{
    if (item.id == e.markerId){
    wx.openLocation({
    latitude: parseFloat(item.latitude),  
    longitude: parseFloat(item.longitude),
    name: parseFloat(item.name),
    address: parseFloat(item.address)
    })   
    }   
    })  
    },


  onReady: function () {


  },


  /**
   * 地图放大缩小事件触发
   * @param {*} e 
   */
  bindregionchange(e) {
    console.log('=bindregiοnchange=', e)
  },


  /**
   * 点击地图事件,有经纬度信息返回
   * @param {*} e 
   */
  bindtapMap(e) {
    console.log('=bindtapMap=', e)
  }
})
回答关注问题邀请回答
收藏

1 个回答

  • Liuxr
    Liuxr
    2021-05-21

    补充一个图片

    2021-05-21
    有用 1
    回复 1
    • Liuxr
      Liuxr
      2021-05-21
      改成下面的即可
      2021-05-21
      回复
登录 后发表内容