Skip to content

Commit

Permalink
fix #1028 :redraw layer when map's view is changed, and check geos to…
Browse files Browse the repository at this point in the history
… draw when is rotating or moving
  • Loading branch information
fuzhenn committed Nov 15, 2019
1 parent f2cdbc2 commit 7c6f63d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/renderer/layer/CanvasRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class CanvasRenderer extends Class {
*/
needToRedraw() {
const map = this.getMap();
if (map.isInteracting()) {
if (map.isInteracting() || map.getRenderer().isViewChanged()) {
// don't redraw when map is moving without any pitch
return !(!map.getPitch() && map.isMoving() && !map.isZooming() && !map.isRotating() && !this.layer.options['forceRenderOnMoving']);
}
Expand Down
14 changes: 6 additions & 8 deletions src/renderer/layer/vectorlayer/VectorLayerCanvasRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,13 @@ class VectorLayerRenderer extends OverlayLayerCanvasRenderer {
const map = this.getMap();
//refresh geometries on zooming
const count = this.layer.getCount();
const res = this.getMap().getResolution();
if (map.isZooming() &&
map.options['seamlessZoom'] &&
this._geosToDraw.length < count) {
const res = this.getMap().getResolution();
if (this._drawnRes !== undefined && res > this._drawnRes * 1.5) {
this.prepareToDraw();
this.forEachGeo(this.checkGeo, this);
this._drawnRes = res;
}
map.options['seamlessZoom'] && this._drawnRes !== undefined && res > this._drawnRes * 1.5 &&
this._geosToDraw.length < count || map.isMoving() || map.isInteracting()) {
this.prepareToDraw();
this.forEachGeo(this.checkGeo, this);
this._drawnRes = res;
}
for (let i = 0, l = this._geosToDraw.length; i < l; i++) {
const geo = this._geosToDraw[i];
Expand Down
10 changes: 6 additions & 4 deletions src/renderer/map/MapCanvasRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class MapCanvasRenderer extends MapRenderer {
if (!this.map) {
return false;
}
delete this._isViewChanged;
const map = this.map;
map._fireEvent('framestart');
this.updateMapDOM();
Expand Down Expand Up @@ -534,12 +535,13 @@ class MapCanvasRenderer extends MapRenderer {
* @return {Boolean}
*/
isViewChanged() {
if (this._isViewChanged !== undefined) {
return this._isViewChanged;
}
const previous = this._mapview;
const view = this._getMapView();
if (!previous || !equalMapView(previous, view)) {
return true;
}
return false;
this._isViewChanged = !previous || !equalMapView(previous, view);
return this._isViewChanged;
}

_recordView() {
Expand Down

0 comments on commit 7c6f63d

Please sign in to comment.