diff --git a/web/client/components/map/openlayers/Layer.jsx b/web/client/components/map/openlayers/Layer.jsx index 72809a3d4d..63a1d55ed5 100644 --- a/web/client/components/map/openlayers/Layer.jsx +++ b/web/client/components/map/openlayers/Layer.jsx @@ -61,6 +61,7 @@ const OpenlayersLayer = React.createClass({ this.props.map.removeLayer(this.layer); } } + Layers.removeLayer(this.props.type, this.props.options, this.props.map, this.props.mapId, this.layer); }, render() { if (this.props.children) { diff --git a/web/client/components/map/openlayers/plugins/GoogleLayer.js b/web/client/components/map/openlayers/plugins/GoogleLayer.js index 87e6133e8b..d5d3beab94 100644 --- a/web/client/components/map/openlayers/plugins/GoogleLayer.js +++ b/web/client/components/map/openlayers/plugins/GoogleLayer.js @@ -193,6 +193,11 @@ Layers.registerType('google', { gmaps[mapId].setCenter(new google.maps.LatLng(center[1], center[0])); gmaps[mapId].setZoom(view.getZoom()); } + }, + remove(options, map, mapId) { + if (rendererItem === options.name) { + rendererItem = undefined; + delete gmaps[mapId]; + } } - }); diff --git a/web/client/utils/openlayers/Layers.js b/web/client/utils/openlayers/Layers.js index 4ba54a50d7..4c3055080c 100644 --- a/web/client/utils/openlayers/Layers.js +++ b/web/client/utils/openlayers/Layers.js @@ -45,6 +45,13 @@ var Layers = { } } }, + removeLayer: function(type, options, map, mapId, layer) { + var layerCreator = layerTypes[type]; + if (layerCreator && layerCreator.remove) { + return layerCreator.remove(options, map, mapId, layer); + } + return null; + }, renderLayer: function(type, options, map, mapId, layer) { var layerCreator = layerTypes[type]; if (layerCreator && layerCreator.render) {