大家好
我在做小程序地图标注的时候,
用makers在开发工具里能够全部展示,
但是通过手机去预览程序,
发现标注的点全不在地图上,
大家知道这个是什么原因吗,
代码如下:
Page({
data: {
markers: [],
scale: 14,
},
onShow: function () {
var that = this
console.log(‘onShow’)
//var that = this
var checkTimer = setInterval(function () {
var markerArray = []
wx.request({
url: ‘XXXXXXXXXXXXXXXXXX’,
header: {//请求头
“Content-Type”: “applciation/json”
},
method: “GET”,
success: function (res) {
var busArr = res.data.localist
for (var i = 0; i < busArr.length; i++) {
var busLat = res.data.localist[i].la
var busLong = res.data.localist[i].lo
var id = Number(res.data.localist[i].id)
var marker = {
latitude: busLat,
longitude: busLong,
iconPath: “…/…/images/my.png”,
id: id,
width: 20,
height: 40
}
markerArray.push(marker)
}
that.setData({
markers: markerArray
})
},
complete: function () {
console.log(“请求complete”)
setTimeout(function () {
wx.hideToast()
})
}
})
}, 3000)
},
})