收藏
回答

map组件,设置了makers,开发工具中显示正常,真机调试时maker都不显示了,是什么原因呢?

我的相关代码如下:

wxml:

<map control="true" class="map" id="locationMap" longitude="{{longitude}}" latitude="{{latitude}}" scale="{{curScale}}" show-location="false" markers="{{markers}}" bindmarkertap="makertap"></map>


js:

app.BeeRequest(null, app.globalData.requestPositions,
          'GET', that,
          function (res) {
            if (res.code == 0) {
              if (res.data && res.data.length > 0) {
                let markers = []
                res.data.forEach((_item,idx) => {
                  let maker = that.createMaker(_item, idx)
                  if (maker) {
                    markers.push(maker)
                  }
                });
                  that.setData({markers})
              } else {
                that.setData({
                  nodata: true
                })
              }
            } else {
              that.setData({
                errTip: res.msg,
                error: true
              })
            }
          }) 

    createMaker(_item, idx) {
      let maker = {}
      maker.id = idx
      maker.longitude = _item.zxjd
      maker.latitude = _item.zxwd
      maker.joinCluster = true
      maker.clusterId = _item.id 
      maker.title = _item.cph
      maker.iconPath = "../../images/car_icon.png" 
      maker.anchor = {x:0.5,y:0.5}
      maker.callout = {content: _item.cph, color: '#ff0c28', borderRadius: 5, borderColor: '#ff0c28', borderWidth: 1, padding: 5, fontSize: 12,
        display: 'ALWAYS', textAlign: 'center', anchorX: 0, anchorY: 35}
      maker.rotate = _item.xsfx
      maker.width = 40
      maker.height = 40  
      return maker;
    },


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

3 个回答

  • 社区技术运营专员-Jahozheng
    社区技术运营专员-Jahozheng
    2021-12-26

    你好,麻烦提供出现问题的具体机型、微信版本号、系统版本号,以及能复现问题的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)

    2021-12-26
    有用
    回复 4
    • anjadeluo
      anjadeluo
      2021-12-27
      https://developers.weixin.qq.com/s/5uar8RmG7NvL
      2021-12-27
      回复
    • anjadeluo
      anjadeluo
      2021-12-27
      我做成代码片段的时候maker就也不显示了,只显示的maker.callout
      2021-12-27
      回复
    • anjadeluo
      anjadeluo
      2021-12-27
      请帮忙指导下,谢谢!!!
      2021-12-27
      回复
    • anjadeluo
      anjadeluo
      2021-12-27
      我又尝试了一下,注释掉maker以下设置,maker图标在真机上显示了,但是,我把callout加上以后,图标又不显示了,只显示callout了
      2021-12-27
      回复
  • brave
    brave
    2021-12-24

    确定接口请求成功了吗

    2021-12-24
    有用 1
    回复 1
    • anjadeluo
      anjadeluo
      2021-12-24
      请求成功的,数据拿到了的
      2021-12-24
      回复
  • anjadeluo
    anjadeluo
    2021-12-27

    我反复试了一下是偏移量的问题,没有设置偏移量的话,就会显示,设置了偏移量就不显示,不知道是什么原因!

    2021-12-27
    有用
    回复 1
    • 岁月静好
      岁月静好
      2023-09-06
      你好,我现在也遇到了同样的问题,我把偏移量去掉以后发现安卓可以显示,苹果初始化的时候不显示当点击加载更多数据的时候,才显示出来
      2023-09-06
      回复
登录 后发表内容