Skip to content

Commit 7c1c175

Browse files
【fix】 修复ol webmap 打开iportal地图固定比例尺失效,图层可见比例尺失效 review by songym
1 parent 7e6c1d1 commit 7c1c175

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

src/openlayers/mapping/WebMap.js

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ export class WebMap extends Observable {
424424
baseLayerInfo.visibleScales.forEach(scale => {
425425
let value = 1 / scale;
426426
res = this.getResFromScale(value, coordUnit);
427-
scale = `1:${value.toLocaleString()}`;
427+
scale = `1:${value}`;
428428
//多此一举转换,因为toLocalString会自动保留小数点后三位,and当第二位小数是0就会保存小数点后两位。所有为了统一。
429429
resolutions[this.formatScale(scale)] = res;
430430
resolutionArray.push(res);
@@ -433,7 +433,7 @@ export class WebMap extends Observable {
433433
} else if (baseLayerInfo.layerType === 'WMTS') {
434434
baseLayerInfo.scales.forEach(scale => {
435435
res = this.getResFromScale(scale, coordUnit, 90.7);
436-
scale = `1:${scale.toLocaleString()}`;
436+
scale = `1:${scale}`;
437437
//多此一举转换,因为toLocalString会自动保留小数点后三位,and当第二位小数是0就会保存小数点后两位。所有为了统一。
438438
resolutions[this.formatScale(scale)] = res;
439439
resolutionArray.push(res);
@@ -480,7 +480,7 @@ export class WebMap extends Observable {
480480
getScaleFromRes(resolution, coordUnit = "DEGREE", dpi = 96) {
481481
let scale, mpu = metersPerUnit[coordUnit.toUpperCase()];
482482
scale = resolution * dpi * mpu / .0254;
483-
return '1:' + scale.toLocaleString();
483+
return '1:' + scale;
484484
}
485485
/**
486486
* @private
@@ -703,11 +703,20 @@ export class WebMap extends Observable {
703703
const scales = this.scales.map((scale) => {
704704
return 1 / scale.split(':')[1];
705705
});
706-
visibleScales = baseLayer.visibleScales || scales;
706+
if (Array.isArray(baseLayer.visibleScales) && baseLayer.visibleScales.length && baseLayer.visibleScales) {
707+
visibleScales = baseLayer.visibleScales;
708+
} else {
709+
visibleScales = scales;
710+
}
707711
minScale = 1 / mapInfo.minScale.split(':')[1];
708712
maxScale = 1 / mapInfo.maxScale.split(':')[1];
709713
}
710-
714+
if (minScale > maxScale) {
715+
let temp = null;
716+
temp = minScale;
717+
minScale = maxScale;
718+
maxScale = temp;
719+
}
711720
const minVisibleScale = this.findNearest(visibleScales, minScale);
712721
const maxVisibleScale = this.findNearest(visibleScales, maxScale);
713722
const minZoom = visibleScales.indexOf(minVisibleScale);
@@ -829,7 +838,7 @@ export class WebMap extends Observable {
829838
// if(options.baseLayer.visibleScales && options.baseLayer.visibleScales.length > 0){
830839
// maxZoom = options.baseLayer.visibleScales.length;
831840
// }
832-
this.map.setView(new View({ zoom, center, projection, maxZoom }));
841+
this.map.setView(new View({ zoom, center, projection, maxZoom, maxResolution }));
833842
let viewOptions = {};
834843

835844
if (baseLayer.scales && baseLayer.scales.length > 0 && baseLayer.layerType === "WMTS" ||

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