Merge pull request #207 from florianf/master

Fix for #172, add support for removing canvas layers
This commit is contained in:
Vladimir Agafonkin 2011-07-26 01:35:14 -07:00
commit f58a1c7369
3 changed files with 17 additions and 2 deletions

View File

@ -38,12 +38,17 @@
--js ../src/layer/marker/Marker.js \
--js ../src/layer/marker/Marker.Popup.js \
--js ../src/layer/vector/Path.js \
--js ../src/layer/vector/Path.VML.js \
--js ../src/layer/vector/Path.Popup.js \
--js ../src/layer/vector/Path.SVG.js \
--js ../src/layer/vector/Path.VML.js \
--js ../src/layer/vector/canvas/Path.Canvas.js \
--js ../src/layer/vector/Polyline.js \
--js ../src/layer/vector/canvas/Polyline.Canvas.js \
--js ../src/layer/vector/Polygon.js \
--js ../src/layer/vector/canvas/Polygon.Canvas.js \
--js ../src/layer/vector/MultiPoly.js \
--js ../src/layer/vector/Circle.js \
--js ../src/layer/vector/canvas/Circle.Canvas.js \
--js ../src/layer/vector/CircleMarker.js \
--js ../src/layer/GeoJSON.js \
--js ../src/handler/Handler.js \

View File

@ -79,5 +79,9 @@
polygon.bindPopup('I am a polygon');
</script>
<div style='position:absolute;z-index:100;right: 10px; top: 10px; cursor:pointer; background-color: #ccc' onclick="map.removeLayer(path)">Remove path</div>
<div style='position:absolute;z-index:100;right: 10px; top: 30px; cursor:pointer; background-color: #ccc' onclick="map.removeLayer(circle)">Remove circle</div>
</body>
</html>

View File

@ -136,5 +136,11 @@ L.Path = (L.Path.SVG && !window.L_PREFER_CANVAS) || !L.Browser.canvas ? L.Path :
if (this._containsPoint(e.layerPoint)) {
this.fire('click', e);
}
},
onRemove: function(map) {
map.off('viewreset', this._projectLatlngs, this);
map.off(this._updateTrigger, this._updatePath, this);
map.fire(this._updateTrigger);
}
});