收藏
回答

includePoints在组件中使用无效?

includePoints在页面中使用正常,在组件中使用无效,success和fail也没有触发(页面里面有触发)

wxml:<map id="mapstyle="width:100%;height:100%;position:fixed;top: 0;left: 0;right: 0;bottom: 0;longitude="{{longitude}}" latitude="{{latitude}}"></map>

js:let mapC = wx.createMapContext('map');

      console.log('======', mapC)

      mapC.includePoints({

        points: [{

          "latitude": 30.259433598978386,

          "longitude": 120.0117004409193

        }, {

          "latitude": 30.257973471323258,

          "longitude": 120.0117003182772

        }

        padding: [10, 10, 10, 10], // 设置视野边距

        success: (res) => {

          console.log('res', res)

        },

        fail: (err) => {

          console.log('err', err)

        }


回答关注问题邀请回答
收藏

3 个回答

  • 一笑皆春
    一笑皆春
    02-08

    组件中创建需要加一个this,

    let mapC = wx.createMapContext('map'this);
    

    02-08
    有用
    回复
  • CRMEB
    CRMEB
    02-08

    在组件的 ready 生命周期函数中调用 includePoints 方法,确保组件已经渲染完成。

    02-08
    有用
    回复
  • 小葛
    小葛
    02-07

    代码片段:https://developers.weixin.qq.com/s/eW2OENmi7WXQ

    02-07
    有用
    回复 1
    • 一笑皆春
      一笑皆春
      02-08
      let mapC = wx.createMapContext('map', this);
      02-08
      回复
登录 后发表内容