这种情况下bindmarkertap为什么失效?
发布于 6 年前 作者 duangang 11135 次浏览 来自 问答

Test.wxml如下:

<map  id=“MainMap”   longitude=“117.275100” latitude=“31.86384” scale=“5”   markers="{{markers}}"   bindmarkertap=“markertap”  class=“mapclass”    >    </map>

 Test.js如下:

        var markers = [];

        const db = wx.cloud.database();

        Page({

          onLoad: function (options) {    this.mapCtx = wx.createMapContext(‘MainMap’)  },

          onShow: function () {  },

          onReady: function () {

            var that = this

            this.mapCtx.getScale({

              success: function (res) {

                  db.collection(‘MarkerTest’).where({ _id: ‘Testid’ }).get({

                  success(res) {

                    that.setData({ markers: res.data })

                  }

                })

              }

            })

          },

          markertap(e) {

            console.log(e.markerId)

          },

        })

Test.wss如下:

        .mapclass{

          width:100%;

          height:60vh;

        }

用到的云开发数据如下:

        集合名称:MarkerTest

        记录:"_id":Testid

  • "_openid":略

  • "latitude":31.86384

  • "longitude":117.2751

遇到的问题是:点击地图上的marker,函数markertap(e)不会被执行。

期望得到的结果是:点击地图上的marker,会执行markertap(e),即返回console.log(e.markerId)的值。

1 回复

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

回到顶部