我的相关代码如下:
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;
},
你好,麻烦提供出现问题的具体机型、微信版本号、系统版本号,以及能复现问题的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)
// maker.joinCluster = true
// maker.clusterId = _item.id
// maker.title = _item.cph
// 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}
确定接口请求成功了吗
我反复试了一下是偏移量的问题,没有设置偏移量的话,就会显示,设置了偏移量就不显示,不知道是什么原因!