Skip to content

Commit 468dc2f

Browse files
songyumengxilanhuaweidapao
authored andcommitted
【feature】leaflet initmap 对接tileset
1 parent 460bd4b commit 468dc2f

File tree

4 files changed

+299
-224
lines changed

4 files changed

+299
-224
lines changed

src/common/iServer/InitMapServiceBase.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,20 @@ export class InitMapServiceBase {
5353
* @returns {Promise}
5454
*/
5555
getMapInfo(callback) {
56-
return new Promise((resolve, reject) => {
57-
const mapService = this.createMapService();
58-
mapService.getMapInfo((res) => {
59-
callback(res, resolve, reject);
56+
const mapService = this.createMapService();
57+
if(callback){
58+
return new Promise((resolve, reject) => {
59+
mapService.getMapInfo((res) => {
60+
callback(res, resolve, reject);
61+
});
6062
});
61-
});
63+
}
64+
return mapService.getMapInfo();
65+
66+
}
67+
68+
getTilesets() {
69+
return this.createMapService().getTilesets();
6270
}
6371

6472
/**

src/common/util/MapCalculateUtil.js

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,26 @@ export function conversionDegree(degrees) {
137137
* const result = scalesToResolutions(scales, bounds, dpi, mapUnit);
138138
* ```
139139
*/
140-
export function scalesToResolutions(scales, bounds, dpi, mapUnit, level = 22) {
140+
export function scalesToResolutions(scales, bounds, dpi, mapUnit, level = 22, baseScale) {
141141
var resolutions = [];
142142
if (scales && scales.length > 0) {
143143
for (let i = 0; i < scales.length; i++) {
144144
resolutions.push(scaleToResolution(scales[i], dpi, mapUnit));
145145
}
146+
} else if (baseScale){
147+
const maxReolution = Math.abs(bounds.left - bounds.right) / 256;
148+
const baseRes = scaleToResolution(baseScale, dpi, mapUnit);
149+
let topRes = baseRes;
150+
for (let i = 0; i < level; i++) {
151+
const temp = baseRes * Math.pow(2, i);
152+
if(Math.abs(temp,maxReolution)<= 1E-6 || temp>maxReolution){
153+
topRes = temp;
154+
break;
155+
}
156+
}
157+
for (let i = 0; i < level; i++) {
158+
resolutions.push(topRes / Math.pow(2, i));
159+
}
146160
} else {
147161
const maxReolution = Math.abs(bounds.left - bounds.right) / 256;
148162
for (let i = 0; i < level; i++) {
@@ -220,6 +234,13 @@ export function scaleToResolution(scale, dpi, mapUnit) {
220234
return resolution;
221235
}
222236

237+
export function getDpi(scale, resolution, mapUnit) {
238+
const inchPerMeter = 1 / 0.0254;
239+
const meterPerMapUnitValue = getMeterPerMapUnit(mapUnit);
240+
const dpi = 1.0/resolution/(scale * inchPerMeter * meterPerMapUnitValue);
241+
return dpi;
242+
}
243+
223244
/**
224245
* 范围是否相交。
225246
* @param {Array} extent1 范围 1。

src/leaflet/core/Util.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
import {
77
getMeterPerMapUnit as MeterPerMapUnit,
88
getZoomByResolution,
9-
scalesToResolutions
9+
scalesToResolutions,
10+
getDpi
1011
} from '@supermap/iclient-common/util/MapCalculateUtil';
1112

1213
/**
@@ -230,5 +231,6 @@ export var getResolutionFromScaleDpi = function(scale, dpi, coordUnit, datumAxis
230231
};
231232
export {
232233
getZoomByResolution,
233-
scalesToResolutions
234+
scalesToResolutions,
235+
getDpi
234236
}

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