第一大坑
在真机map组件marker的padding比真机上的要小得多,展示大小不一致,我这里建议改为padding: 6
第二大坑
addGroundOverlay函数执行的贴图要在真机上才可以显示,微信编辑器看不到效果,所以贴图位置调整就会异常麻烦
const offset = 0.002
mapContext.value.addGroundOverlay({
id: 1,
src: getJsonFirstImage(item.areaPlanInfo),
bounds: {
southwest: { // 西南角
latitude: latitude - offset,
longitude: longitude - offset,
},
northeast: { // 东北角
latitude: latitude + offset,
longitude: longitude + offset,
},
},
success(res) {
console.log('wp', res)
},
fail(err) {
console.log('wperr', err)
},
})
第三大坑
如果想要本身标记去掉,这里是不支持的,除非使用iconPath方法替换掉,并且要找一个透明贴图覆盖掉,这样标记就消失了,贴图如下,自取使用,使用完毕之后,要把anchorY向下30,代替原来标记的位置
p0-xtjj-private.juejin.cn/tos-cn-i-73…
areaOtherInfo.forEach((mark) => {
mapData.value.markers.push({
id: globalMarkerId++,
latitude: mark.latitude,
longitude: mark.longitude,
joinCluster: true,
title: mark.title || '',
data: item,
iconPath: '/static/images/touming.png', // 可自定义小区marker图标
width: 32,
height: 32,
callout: {
content: mark.title || '',
color: '#fff',
fontSize: 12,
borderRadius: 6,
bgColor: '#2563eb',
textAlign: 'center',
padding: 6,
display: 'ALWAYS',
anchorY: 30,
},
type: 'community',
})
})
第四大坑
如果使用了点聚合,joinCluster: true。地图上面使用了 @callouttap="callouttap"是可用的,@markertap="callouttap"是不可用的,但是如果未使用,callouttap方法在真机上是不会触发的,必须使用 @markertap="callouttap"来触发,但是微信开发者工具不会触发