add a removeMarker() function

git-svn-id: http://svn.openlayers.org/trunk/openlayers@519 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
euzuro
2006-06-05 16:57:06 +00:00
parent 28ae47184c
commit d4253603fb

View File

@@ -40,6 +40,24 @@ OpenLayers.Layer.Markers.prototype =
}
},
/**
* @param {OpenLayers.Marker} marker
*/
removeMarker: function(marker) {
var index = null;
for(var i=0; i < this.markers.length; i++) {
if (this.markers[i] == marker) {
index = i;
}
}
if (index != null) {
this.markers.splice(index, 1);
}
if ((marker.icon != null) && (marker.icon.imageDiv != null) &&
(marker.icon.imageDiv.parentNode == this.div) ) {
this.div.removeChild(marker.icon.imageDiv);
}
},
/** clear all the marker div's from the layer and then redraw all of them.
* Use the map to recalculate new placement of markers.