地图模块的导航页不显示地址和名称?
发布于 6 年前 作者 tanjuan 7905 次浏览 来自 问答
在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](/user/param) {*} e 
   */
  bindregionchange(e) {
    console.log('=bindregiοnchange=', e)
  },

  /**
   * 点击地图事件,有经纬度信息返回
   * [@param](/user/param) {*} e 
   */
  bindtapMap(e) {
    console.log('=bindtapMap=', e)
  }
})
1 回复

补充一个图片

回到顶部