Skip to content

Commit

Permalink
fix(bmap): bmap event moveend is always triggered when dragging or …
Browse files Browse the repository at this point in the history
…zoomend. (#12558)
  • Loading branch information
plainheart authored Aug 4, 2020
1 parent 38bd9eb commit 57914fb
Show file tree
Hide file tree
Showing 3 changed files with 601 additions and 6 deletions.
9 changes: 7 additions & 2 deletions extension-src/bmap/BMapCoordSys.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,13 @@ BMapCoordSys.create = function (ecModel, api) {
var center = bmapModel.get('center');
var zoom = bmapModel.get('zoom');
if (center && zoom) {
var pt = new BMap.Point(center[0], center[1]);
bmap.centerAndZoom(pt, zoom);
var bmapCenter = bmap.getCenter();
var bmapZoom = bmap.getZoom();
var centerOrZoomChanged = bmapModel.centerOrZoomChanged([bmapCenter.lng, bmapCenter.lat], bmapZoom);
if (centerOrZoomChanged) {
var pt = new BMap.Point(center[0], center[1]);
bmap.centerAndZoom(pt, zoom);
}
}

bmapCoordSys = new BMapCoordSys(bmap, api);
Expand Down
6 changes: 2 additions & 4 deletions extension-src/bmap/BMapView.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,10 @@ export default echarts.extendComponentView({
}

bmap.removeEventListener('moving', this._oldMoveHandler);
// FIXME
// Moveend may be triggered by centerAndZoom method when creating coordSys next time
// bmap.removeEventListener('moveend', this._oldMoveHandler);
bmap.removeEventListener('moveend', this._oldMoveHandler);
bmap.removeEventListener('zoomend', this._oldZoomEndHandler);
bmap.addEventListener('moving', moveHandler);
// bmap.addEventListener('moveend', moveHandler);
bmap.addEventListener('moveend', moveHandler);
bmap.addEventListener('zoomend', zoomEndHandler);

this._oldMoveHandler = moveHandler;
Expand Down
Loading

0 comments on commit 57914fb

Please sign in to comment.