Skip to content

Commit

Permalink
[fix] fix a bug that re-create echarts layer is not working after dis…
Browse files Browse the repository at this point in the history
…posed.
  • Loading branch information
plainheart committed Jun 15, 2020
1 parent 3c02347 commit c338d66
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/GMapCoordSys.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,8 @@ function createOverlayCtor() {
Overlay.prototype = new google.maps.OverlayView();

Overlay.prototype.onAdd = function() {
this.getMap().__overlayProjection = this.getProjection();
var gmap = this.getMap();
gmap.__overlayProjection = this.getProjection();
gmap.getDiv().querySelector(".gm-style > div").appendChild(this._root);
};

Expand Down
13 changes: 12 additions & 1 deletion src/GMapView.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,24 @@ export default echarts.extendComponentView({
},

dispose: function(ecModel, api) {
this._oldRenderHandler && this._oldRenderHandler.remove();
this._oldRenderHandler = null;

var component = ecModel.getComponent("gmap");
var gmapInstance = component.getGoogleMap();

// remove injected projection
delete gmapInstance.__overlayProjection;

// clear all listeners of map instance
google.maps.event.clearInstanceListeners(gmapInstance);

var mapDiv = gmapInstance.getDiv();
mapDiv.parentNode.remove(mapDiv);
mapDiv.parentNode.removeChild(mapDiv);

component.setGoogleMap(null);
component.setEChartsLayer(null);
component.coordinateSystem.setGoogleMap(null);
component.coordinateSystem = null;
}
});

0 comments on commit c338d66

Please sign in to comment.