Skip to content

Commit b88c50a

Browse files
committed
fix map.checkSize when map is tilting
1 parent 7264d24 commit b88c50a

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

src/map/Map.js

+14-6
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,7 @@ class Map extends Handlerable(Eventable(Renderable(Class))) {
487487
// const pitch = this.getPitch();
488488
// const visualDistance = this.height / 2 * Math.tan(visualPitch * Math.PI / 180);
489489
// return this.height / 2 + visualDistance * Math.tan((90 - pitch) * Math.PI / 180);
490+
visualPitch = visualPitch || 1E-2;
490491

491492
const pitch = (90 - this.getPitch()) * Math.PI / 180;
492493
const fov = this.getFov() * Math.PI / 180;
@@ -1338,21 +1339,28 @@ class Map extends Handlerable(Eventable(Renderable(Class))) {
13381339
return this;
13391340
}
13401341
const center = this.getCenter();
1341-
this._updateMapSize(watched);
13421342

13431343
if (!this.options['fixCenterOnResize']) {
1344-
const resizeOffset = new Point((oldWidth - watched.width) / 2, (oldHeight - watched.height) / 2);
1345-
this._offsetCenterByPixel(resizeOffset);
1344+
// fix northwest's geo coordinate
1345+
const vh = this._getVisualHeight(this.getPitch());
1346+
const nwCP = new Point(0, this.height - vh);
1347+
const nwCoord = this._containerPointToPrj(nwCP);
1348+
this._updateMapSize(watched);
1349+
const vhAfter = this._getVisualHeight(this.getPitch());
1350+
const nwCPAfter = new Point(0, this.height - vhAfter);
1351+
this._setPrjCoordAtContainerPoint(nwCoord, nwCPAfter);
13461352
// when size changed, center is updated but panel's offset remains.
13471353
this._mapViewCoord = this._getPrjCenter();
1354+
} else {
1355+
this._updateMapSize(watched);
13481356
}
13491357

13501358
const hided = (watched['width'] === 0 || watched['height'] === 0 || oldWidth === 0 || oldHeight === 0);
13511359

13521360
if (justStart || hided) {
1353-
this._noEvent = true;
1361+
this._eventSilence = true;
13541362
this.setCenter(center);
1355-
delete this._noEvent;
1363+
delete this._eventSilence;
13561364
}
13571365
/**
13581366
* resize event when map container's size changes
@@ -1659,7 +1667,7 @@ class Map extends Handlerable(Eventable(Renderable(Class))) {
16591667

16601668

16611669
_fireEvent(eventName, param) {
1662-
if (this._noEvent) {
1670+
if (this._eventSilence) {
16631671
return;
16641672
}
16651673
//fire internal events at first

0 commit comments

Comments
 (0)