大家好
我在做微信小程序地图标注的时候,微信小程序体验版如何测试微信扫码。
用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)
},
})
本文网址:http://www.91bianli.com/kaifazhinan/70817.html