Skip to content

Commit

Permalink
Fixes #1167: OL3 GoogleLayer reset on map change
Browse files Browse the repository at this point in the history
  • Loading branch information
mbarto committed Nov 3, 2016
1 parent 8e628c8 commit 67fafc1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions web/client/components/map/openlayers/Layer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
7 changes: 6 additions & 1 deletion web/client/components/map/openlayers/plugins/GoogleLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
}

});
7 changes: 7 additions & 0 deletions web/client/utils/openlayers/Layers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 67fafc1

Please sign in to comment.