当对markers通过that.setData赋值多个标记时,有的显示一个,有的不显示,检查坐标值是正确,
就是不显示出来,
不知道该怎么解决才好
wx.request({
url: ‘…’,
data: {
cityid: mycity,
},
method: ‘GET’,
header: { ‘content-type’: ‘application/x-www-form-urlencoded’ },
success: function (res) {
if (res.data.length == 0) { return; }
var citylat = res.data[0].sc_lat;
var citylng = res.data[0].sc_lng;
var l = that.data.markers;
for (var i = 0; i < res.data.length; i++) {
var sc_lat = res.data[i].sc_lat;
var sc_lng = res.data[i].sc_lng;
var centerM = {
iconPath: “…/…/images/hq3.png”,
id: res.data[i].id,
latitude: citylat,
longitude: citylng,
width: 40,
height: 40,
title: res.data[i].title,
};
if (sc_lat>0) {
//citylat = sc_lat;
//citylng = sc_lng;
l.push(centerM);
console.log(“getCityInfo sc_lat::==” + l.length);
}
}
setTimeout(function () {
var scale_ = 14;
that.setData({
//scale: scale_,
markers: l,
lat: citylat,
lng: citylng,
nearlat: citylat,
nearlng: citylng,
num: res.data[0].title,
now: l.length+‘cityinfo’
});
}, 1000);
}
})
去掉了延时也一样