diff --git a/lib/OpenLayers/Map.js b/lib/OpenLayers/Map.js index 6318009f9f..53e39b60c1 100644 --- a/lib/OpenLayers/Map.js +++ b/lib/OpenLayers/Map.js @@ -144,7 +144,28 @@ OpenLayers.Map.prototype = { this.events.triggerEvent("addlayer"); }, - /** + /** Removes a layer from the map by removing its visual element (the + * layer.div property), then removing it from the map's internal list + * of layers, setting the layer's map property to null. + * + * a "removelayer" event is triggered. + * + * very worthy of mention is that simply removing a layer from a map + * will not cause the removal of any popups which may have been created + * by the layer. this is due to the fact that it was decided at some + * point that popups would not belong to layers. thus there is no way + * for us to know here to which layer the popup belongs. + * + * A simple solution to this is simply to call destroy() on the layer. + * the default OpenLayers.Layer class's destroy() function + * automatically takes care to remove itself from whatever map it has + * been attached to. + * + * The correct solution is for the layer itself to register an + * event-handler on "removelayer" and when it is called, if it + * recognizes itself as the layer being removed, then it cycles through + * its own personal list of popups, removing them from the map. + * * @param {OpenLayers.Layer} layer */ removeLayer: function(layer) {