我在获取设备最新位置并在地图上更新标记时遇到问题,当我的车辆设备移动时,标记会跳到新位置并闪烁。我该如何避免闪烁,或让标记平滑移动?谢谢您的帮助。
var map;
var marker;
var markerarray =[];
setInterval(function(){
$.ajax({
type: "post",
url: "vehiclecordinates.php",
success: function(data){
coordinates = data.latlng;
vehiclename = data.vehiclename;
for (var i = 0; i < coordinates.length; i++) {
newcoordinate = new google.maps.LatLng(coordinates[i].split(",")[0],coordinates[i].split(",")[1]);
marker = new MarkerWithLabel({
map:map,
labelClass: "mylabels",
labelStyle: {opacity: 1.0},
labelContent: '<div>'+ vehiclename[i]+'</div>',
icon:{
//some options here
},
});
marker.setPosition(newcoordinate);
markerarray.push(marker);
}
}
});
setTimeout(function () {
removeMarkers();
delete marker;
}, 1000);
},5000);
function removeMarkers() {
for(var i = 0; i < markerarray.length; i++) {
markerarray[i].setMap(null);
}
}