Skip to content

Commit 81366eb

Browse files
authored
Merge pull request SuperMap#15 from zhang6685979/master
修复mapvLayer在浏览器缩放时元素位置不正确问题
2 parents fbdd843 + a8c818d commit 81366eb

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

src/mapboxgl/overlay/MapvLayer.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,15 +117,15 @@ export class MapvLayer {
117117
canvas.style.position = 'absolute';
118118
canvas.style.top = 0 + "px";
119119
canvas.style.left = 0 + "px";
120-
canvas.width = parseInt(this.map.getCanvas().style.width);
121-
canvas.height = parseInt(this.map.getCanvas().style.height);
122-
canvas.style.width = this.map.getCanvas().style.width;
123-
canvas.style.height = this.map.getCanvas().style.height;
124120
var global$2 = typeof window === 'undefined' ? {} : window;
125121
var devicePixelRatio = this.devicePixelRatio = global$2.devicePixelRatio;
122+
canvas.width = parseInt(this.map.getCanvas().style.width)*devicePixelRatio;
123+
canvas.height = parseInt(this.map.getCanvas().style.height)*devicePixelRatio;
126124
if (this.mapVOptions.context == '2d') {
127125
canvas.getContext(this.mapVOptions.context).scale(devicePixelRatio, devicePixelRatio);
128126
}
127+
canvas.style.width = this.map.getCanvas().style.width;
128+
canvas.style.height = this.map.getCanvas().style.height;
129129
return canvas;
130130
}
131131

src/mapboxgl/overlay/mapv/MapvRenderer.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,8 +308,11 @@ export class MapvRenderer extends BaseLayer {
308308
canvas.style.position = 'absolute';
309309
canvas.style.top = 0 + "px";
310310
canvas.style.left = 0 + "px";
311-
canvas.width = parseInt(this.map.getCanvas().style.width);
312-
canvas.height = parseInt(this.map.getCanvas().style.height);
311+
var global$2 = typeof window === 'undefined' ? {} : window;
312+
var devicePixelRatio = this.canvasLayer.devicePixelRatio = global$2.devicePixelRatio;
313+
canvas.width = parseInt(this.map.getCanvas().style.width)*devicePixelRatio;
314+
canvas.height = parseInt(this.map.getCanvas().style.height)*devicePixelRatio;
315+
313316
canvas.style.width = this.map.getCanvas().style.width;
314317
canvas.style.height = this.map.getCanvas().style.height;
315318
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy