小程序map中markers不显示的问题

在这里插入图片描述
今天做个地图显示当前位置,开始的时候markers没有出现在地图上,
看看控制器时发现markers和经纬度并没有在map标签上渲染出来,但是在data里却看到有markers和经纬度数据, 下面直接上代码

<map
	wx:if="{{mapShow}}"
	style="width: 100%; height: 100%;"
	latitude="{{latitude}}"
	longitude="{{longitude}}"
	markers="{{markers}}"
 ></map>
data: {
	scale: 18,
	latitude: '',
	longitude: '',
	mapShow: false
},
onLoad: function () {
    let that = this
    wx.getLocation({
          type: 'gcj02',
          success(res) {
                const latitude  = res.latitude
                const longitude  = res.longitude
                  const markers= [{
                          id: 1,
                          latitude: latitude,
                          longitude: longitude,
                          width: 50,
                          height: 50,
                          iconPath: '/images/icon/location.png',
                    }];
                that.setData({
                      latitude: latitude,
                      longitude: longitude,
                      markers: markers
                })
          }
    });
 },
发布了40 篇原创文章 · 获赞 0 · 访问量 979

猜你喜欢

转载自blog.csdn.net/HXH_csdn/article/details/103967791
今日推荐