Skip to content

Commit d2e5257

Browse files
author
caoxinke@supermap.com
committed
fix mapboxgl专题图拖动放手会有瞬间偏移的问题;mapboxgl专题图小级别比例尺下拖动地图,底图未动但专题图移动的问题。
1 parent 64a8c99 commit d2e5257

File tree

6 files changed

+53
-53
lines changed

6 files changed

+53
-53
lines changed

dist/iclient9-mapboxgl.js

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -52222,20 +52222,19 @@ var Theme = function () {
5222252222
}
5222352223
}, {
5222452224
key: 'moveStartEvent',
52225-
value: function moveStartEvent(e) {
52225+
value: function moveStartEvent() {
5222652226
if (this.loadWhileAnimating || !this.visibility) {
5222752227
return;
5222852228
}
5222952229
this.startPitch = this.map.getPitch();
5223052230
this.startBearing = this.map.getBearing();
52231-
if (e.originalEvent) {
52232-
this.startMoveX = e.originalEvent.pageX;
52233-
this.startMoveY = e.originalEvent.pageY;
52234-
}
52231+
var startMovePoint = this.map.project(new _mapboxGl2.default.LngLat(0, 0));
52232+
this.startMoveX = startMovePoint.x;
52233+
this.startMoveY = startMovePoint.y;
5223552234
}
5223652235
}, {
5223752236
key: 'moveEvent',
52238-
value: function moveEvent(e) {
52237+
value: function moveEvent() {
5223952238
if (this.loadWhileAnimating || !this.visibility) {
5224052239
this.redrawThematicFeatures(this.map.getBounds());
5224152240
return;
@@ -52249,8 +52248,9 @@ var Theme = function () {
5224952248
this.mapContainer.style.perspective = this.map.transform.cameraToCenterDistance + 'px';
5225052249
var tPitch = this.map.getPitch() - this.startPitch;
5225152250
var tBearing = -this.map.getBearing() + this.startBearing;
52252-
var tMoveX = this.startMoveX && e.originalEvent ? e.originalEvent.pageX - this.startMoveX : 0;
52253-
var tMoveY = this.startMoveY && e.originalEvent ? e.originalEvent.pageY - this.startMoveY : 0;
52251+
var endMovePoint = this.map.project(new _mapboxGl2.default.LngLat(0, 0));
52252+
var tMoveX = endMovePoint.x - this.startMoveX;
52253+
var tMoveY = endMovePoint.y - this.startMoveY;
5225452254
this.div.style.transform = 'rotateX(' + tPitch + 'deg)' + ' rotateZ(' + tBearing + 'deg)' + ' translate3d(' + tMoveX + 'px, ' + tMoveY + 'px, 0px)';
5225552255
}
5225652256
}, {
@@ -53289,20 +53289,19 @@ var HeatMapLayer = exports.HeatMapLayer = function () {
5328953289
}
5329053290
}, {
5329153291
key: '_moveStartEvent',
53292-
value: function _moveStartEvent(e) {
53292+
value: function _moveStartEvent() {
5329353293
if (this.loadWhileAnimating || !this.visibility) {
5329453294
return;
5329553295
}
5329653296
this.startPitch = this.map.getPitch();
5329753297
this.startBearing = this.map.getBearing();
53298-
if (e.originalEvent) {
53299-
this.startMoveX = e.originalEvent.pageX;
53300-
this.startMoveY = e.originalEvent.pageY;
53301-
}
53298+
var startMovePoint = this.map.project(new _mapboxGl2.default.LngLat(0, 0));
53299+
this.startMoveX = startMovePoint.x;
53300+
this.startMoveY = startMovePoint.y;
5330253301
}
5330353302
}, {
5330453303
key: '_moveEvent',
53305-
value: function _moveEvent(e) {
53304+
value: function _moveEvent() {
5330653305
if (this.loadWhileAnimating || !this.visibility) {
5330753306
this.refresh();
5330853307
return;
@@ -53316,8 +53315,9 @@ var HeatMapLayer = exports.HeatMapLayer = function () {
5331653315
this.mapContainer.style.perspective = this.map.transform.cameraToCenterDistance + 'px';
5331753316
var tPitch = this.map.getPitch() - this.startPitch;
5331853317
var tBearing = -this.map.getBearing() + this.startBearing;
53319-
var tMoveX = this.startMoveX && e.originalEvent ? e.originalEvent.pageX - this.startMoveX : 0;
53320-
var tMoveY = this.startMoveY && e.originalEvent ? e.originalEvent.pageY - this.startMoveY : 0;
53318+
var endMovePoint = this.map.project(new _mapboxGl2.default.LngLat(0, 0));
53319+
var tMoveX = endMovePoint.x - this.startMoveX;
53320+
var tMoveY = endMovePoint.y - this.startMoveY;
5332153321
this.rootCanvas.style.transform = 'rotateX(' + tPitch + 'deg)' + ' rotateZ(' + tBearing + 'deg)' + ' translate3d(' + tMoveX + 'px, ' + tMoveY + 'px, 0px)';
5332253322
}
5332353323
}, {
@@ -80575,20 +80575,19 @@ var MapvRenderer = exports.MapvRenderer = function (_BaseLayer) {
8057580575
}
8057680576
}, {
8057780577
key: 'moveStartEvent',
80578-
value: function moveStartEvent(e) {
80578+
value: function moveStartEvent() {
8057980579
this.startPitch = this.map.getPitch();
8058080580
this.startBearing = this.map.getBearing();
80581-
if (e.originalEvent) {
80582-
this.startMoveX = e.originalEvent.pageX;
80583-
this.startMoveY = e.originalEvent.pageY;
80584-
}
80581+
var startMovePoint = this.map.project(new _mapboxGl2.default.LngLat(0, 0));
80582+
this.startMoveX = startMovePoint.x;
80583+
this.startMoveY = startMovePoint.y;
8058580584
if (this.animation) {
8058680585
this.stopAniamation = true;
8058780586
}
8058880587
}
8058980588
}, {
8059080589
key: 'moveEvent',
80591-
value: function moveEvent(e) {
80590+
value: function moveEvent() {
8059280591
if (this.rotating || this.zooming) {
8059380592
return;
8059480593
}
@@ -80598,8 +80597,9 @@ var MapvRenderer = exports.MapvRenderer = function (_BaseLayer) {
8059880597
this.canvasLayer.mapContainer.style.perspective = this.map.transform.cameraToCenterDistance + 'px';
8059980598
var tPitch = this.map.getPitch() - this.startPitch;
8060080599
var tBearing = -this.map.getBearing() + this.startBearing;
80601-
var tMoveX = this.startMoveX && e.originalEvent ? e.originalEvent.pageX - this.startMoveX : 0;
80602-
var tMoveY = this.startMoveY && e.originalEvent ? e.originalEvent.pageY - this.startMoveY : 0;
80600+
var endMovePoint = this.map.project(new _mapboxGl2.default.LngLat(0, 0));
80601+
var tMoveX = endMovePoint.x - this.startMoveX;
80602+
var tMoveY = endMovePoint.y - this.startMoveY;
8060380603
var canvas = this.getContext().canvas;
8060480604
canvas.style.transform = 'rotateX(' + tPitch + 'deg)' + ' rotateZ(' + tBearing + 'deg)' + ' translate3d(' + tMoveX + 'px, ' + tMoveY + 'px, 0px)';
8060580605
}
@@ -82298,7 +82298,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
8229882298
}
8229982299

8230082300
function Promise(fn) {
82301-
if (!(this instanceof Promise)) throw new TypeError('Promises must be constructed via new');
82301+
if (_typeof(this) !== 'object') throw new TypeError('Promises must be constructed via new');
8230282302
if (typeof fn !== 'function') throw new TypeError('not a function');
8230382303
this._state = 0;
8230482304
this._handled = false;
@@ -82422,9 +82422,9 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
8242282422
};
8242382423

8242482424
Promise.all = function (arr) {
82425+
var args = Array.prototype.slice.call(arr);
82426+
8242582427
return new Promise(function (resolve, reject) {
82426-
if (!arr || typeof arr.length === 'undefined') throw new TypeError('Promise.all accepts an array');
82427-
var args = Array.prototype.slice.call(arr);
8242882428
if (args.length === 0) return resolve([]);
8242982429
var remaining = args.length;
8243082430

dist/iclient9-mapboxgl.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"build-docs-openlayers": "jsdoc -c ./build/jsdocs/openlayers/docs.json -R ./build/jsdocs/openlayers/index.md",
3535
"build-docs-mapboxgl": "jsdoc -c ./build/jsdocs/mapboxgl/docs.json -R ./build/jsdocs/mapboxgl/index.md",
3636
"build-docs-classic": "jsdoc -c ./build/jsdocs/classic/docs.json -R ./build/jsdocs/classic/index.md",
37-
"release-publish": "npm publish ./src/common && npm publish ./src/leaflet && npm publish ./src/openlayers && npm publish ./src/mapboxgl && npm publish ./src/classic"
37+
"release-publish": "cd ./src/common && npm publish && cd ../leaflet && npm publish && cd ../openlayers && npm publish && cd ../mapboxgl && npm publish && cd ../classic && npm publish"
3838
},
3939
"keywords": [
4040
"SuperMap",

src/mapboxgl/overlay/HeatMapLayer.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -640,19 +640,18 @@ export class HeatMapLayer {
640640
this._show();
641641
}
642642

643-
_moveStartEvent(e) {
643+
_moveStartEvent() {
644644
if (this.loadWhileAnimating || !this.visibility) {
645645
return;
646646
}
647647
this.startPitch = this.map.getPitch();
648648
this.startBearing = this.map.getBearing();
649-
if (e.originalEvent) {
650-
this.startMoveX = e.originalEvent.pageX;
651-
this.startMoveY = e.originalEvent.pageY;
652-
}
649+
var startMovePoint = this.map.project(new mapboxgl.LngLat(0, 0));
650+
this.startMoveX = startMovePoint.x;
651+
this.startMoveY = startMovePoint.y;
653652
}
654653

655-
_moveEvent(e) {
654+
_moveEvent() {
656655
if (this.loadWhileAnimating || !this.visibility) {
657656
this.refresh();
658657
return;
@@ -666,8 +665,9 @@ export class HeatMapLayer {
666665
this.mapContainer.style.perspective = this.map.transform.cameraToCenterDistance + 'px';
667666
var tPitch = this.map.getPitch() - this.startPitch;
668667
var tBearing = -this.map.getBearing() + this.startBearing;
669-
var tMoveX = this.startMoveX && e.originalEvent ? e.originalEvent.pageX - this.startMoveX : 0;
670-
var tMoveY = this.startMoveY && e.originalEvent ? e.originalEvent.pageY - this.startMoveY : 0;
668+
var endMovePoint = this.map.project(new mapboxgl.LngLat(0, 0));
669+
var tMoveX = endMovePoint.x - this.startMoveX;
670+
var tMoveY = endMovePoint.y - this.startMoveY;
671671
this.rootCanvas.style.transform = 'rotateX(' + tPitch + 'deg)' + ' rotateZ(' + tBearing + 'deg)' + ' translate3d(' + tMoveX + 'px, ' + tMoveY + 'px, 0px)';
672672
}
673673

src/mapboxgl/overlay/mapv/MapvRenderer.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -310,19 +310,18 @@ export class MapvRenderer extends BaseLayer {
310310
this._show();
311311
}
312312

313-
moveStartEvent(e) {
313+
moveStartEvent() {
314314
this.startPitch = this.map.getPitch();
315315
this.startBearing = this.map.getBearing();
316-
if (e.originalEvent) {
317-
this.startMoveX = e.originalEvent.pageX;
318-
this.startMoveY = e.originalEvent.pageY;
319-
}
316+
var startMovePoint = this.map.project(new mapboxgl.LngLat(0, 0));
317+
this.startMoveX = startMovePoint.x;
318+
this.startMoveY = startMovePoint.y;
320319
if (this.animation) {
321320
this.stopAniamation = true;
322321
}
323322
}
324323

325-
moveEvent(e) {
324+
moveEvent() {
326325
if (this.rotating || this.zooming) {
327326
return;
328327
}
@@ -332,8 +331,9 @@ export class MapvRenderer extends BaseLayer {
332331
this.canvasLayer.mapContainer.style.perspective = this.map.transform.cameraToCenterDistance + 'px';
333332
var tPitch = this.map.getPitch() - this.startPitch;
334333
var tBearing = -this.map.getBearing() + this.startBearing;
335-
var tMoveX = this.startMoveX && e.originalEvent ? e.originalEvent.pageX - this.startMoveX : 0;
336-
var tMoveY = this.startMoveY && e.originalEvent ? e.originalEvent.pageY - this.startMoveY : 0;
334+
var endMovePoint = this.map.project(new mapboxgl.LngLat(0, 0));
335+
var tMoveX = endMovePoint.x - this.startMoveX;
336+
var tMoveY = endMovePoint.y - this.startMoveY;
337337
var canvas = this.getContext().canvas;
338338
canvas.style.transform = 'rotateX(' + tPitch + 'deg)' + ' rotateZ(' + tBearing + 'deg)' + ' translate3d(' + tMoveX + 'px, ' + tMoveY + 'px, 0px)';
339339
}

src/mapboxgl/overlay/theme/ThemeLayer.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -381,19 +381,18 @@ export class Theme {
381381
this._show();
382382
}
383383

384-
moveStartEvent(e) {
384+
moveStartEvent() {
385385
if (this.loadWhileAnimating || !this.visibility) {
386386
return;
387387
}
388388
this.startPitch = this.map.getPitch();
389389
this.startBearing = this.map.getBearing();
390-
if (e.originalEvent) {
391-
this.startMoveX = e.originalEvent.pageX;
392-
this.startMoveY = e.originalEvent.pageY;
393-
}
390+
var startMovePoint = this.map.project(new mapboxgl.LngLat(0, 0));
391+
this.startMoveX = startMovePoint.x;
392+
this.startMoveY = startMovePoint.y;
394393
}
395394

396-
moveEvent(e) {
395+
moveEvent() {
397396
if (this.loadWhileAnimating || !this.visibility) {
398397
this.redrawThematicFeatures(this.map.getBounds());
399398
return;
@@ -407,8 +406,9 @@ export class Theme {
407406
this.mapContainer.style.perspective = this.map.transform.cameraToCenterDistance + 'px';
408407
var tPitch = this.map.getPitch() - this.startPitch;
409408
var tBearing = -this.map.getBearing() + this.startBearing;
410-
var tMoveX = this.startMoveX && e.originalEvent ? e.originalEvent.pageX - this.startMoveX : 0;
411-
var tMoveY = this.startMoveY && e.originalEvent ? e.originalEvent.pageY - this.startMoveY : 0;
409+
var endMovePoint = this.map.project(new mapboxgl.LngLat(0, 0));
410+
var tMoveX = endMovePoint.x - this.startMoveX;
411+
var tMoveY = endMovePoint.y - this.startMoveY;
412412
this.div.style.transform = 'rotateX(' + tPitch + 'deg)' + ' rotateZ(' + tBearing + 'deg)' + ' translate3d(' + tMoveX + 'px, ' + tMoveY + 'px, 0px)';
413413
}
414414

0 commit comments

Comments
 (0)