我正在添加这样的制造商:
var markers = [];
var map = null;
$.ajax({
type:"GET",
dataType:"json",
url:"<?php echo site_url("sandbox_faizan/get_coordinates") ?>",
success: function(result)
{
for(var i=0;i<result.length;i++)
{
var obj = [] ;
obj.lat=result[i].lat;
obj.lng=result[i].lng;
obj.count=result[i].Count;
// points.push(new google.maps.LatLng(result[i].lat,result[i].lng));
markers.push(obj);
//console.log(points[i]);
console.log(markers[i]);
}
addMarkers();
}
});
function addMarkers() {
// when the map is initialized and the points have been initialized, add them to the map
if ((map != null) && (markers.length > 0)) {
for (var i = 0; i < markers.length; i++) {
var marker = new MarkerWithLabel({
map: map,
position: new google.maps.LatLng(markers[i].lat,markers[i].lng),
icon: pinImage,
shadow: pinShadow,
labelContent: markers[i].count,
labelAnchor: new google.maps.Point(12, -5),
labelClass: "labels"
});
bounds.extend (new google.maps.LatLng(markers[i].lat,markers[i].lng));
map.fitBounds (bounds);
}
}
}
我正在清除这样的标记:
function remove_markers(){
google.maps.Map.prototype.clearMarkers = function() {
for(var i=0; i < this.markers.length; i++){
this.markers[i].setMap(null);
alert("removing now"); // THIS DOES NOT ALERT
}
this.markers = new Array();
};
}
它什么都不做,我尝试了其他使用 setMap(null) 的方法,以前它给了我错误未捕获的类型错误 setMap 未在控制台中定义。
我究竟做错了什么?