Skip to content

Commit f23a10e

Browse files
修改initMap version 为 11.0.1
1 parent fcbacbd commit f23a10e

File tree

3 files changed

+75
-2
lines changed

3 files changed

+75
-2
lines changed

src/common/util/MapCalculateUtil.js

Lines changed: 71 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,32 @@ export function conversionDegree(degrees) {
112112
return `${degree}°${fraction}'${second}`;
113113
}
114114

115-
export function scalesToResolutions(scales, bounds, dpi, mapUnit, level = 22) {
115+
/**
116+
* @function scalesToResolutions
117+
* @description 通过比例尺数组计算分辨率数组,没有传入比例尺数组时通过地图范围与地图最大级别进行计算。
118+
* @version 11.0.1
119+
* @param {Array} scales - 比例尺数组。
120+
* @param {Object} bounds - 地图范围。
121+
* @param {number} dpi - 屏幕分辨率。
122+
* @param {string} mapUnit - 地图单位。
123+
* @param {number} [level=22] - 地图最大级别。
124+
* @returns {number} 分辨率。
125+
* @usage
126+
* ```
127+
* // 浏览器
128+
* <script type="text/javascript" src="{cdn}"></script>
129+
* <script>
130+
* const result = {namespace}.scalesToResolutions(scales, bounds, dpi, mapUnit);
131+
*
132+
* </script>
133+
*
134+
* // ES6 Import
135+
* import { scalesToResolutions } from '{npm}';
136+
*
137+
* const result = scalesToResolutions(scales, bounds, dpi, mapUnit);
138+
* ```
139+
*/
140+
export function scalesToResolutions(scales, bounds, dpi, mapUnit, level = 22) {
116141
var resolutions = [];
117142
if (scales && scales.length > 0) {
118143
for (let i = 0; i < scales.length; i++) {
@@ -128,7 +153,28 @@ export function scalesToResolutions(scales, bounds, dpi, mapUnit, level = 22) {
128153
return b - a;
129154
});
130155
}
131-
156+
/**
157+
* @function getZoomByResolution
158+
* @description 通过分辨率获取地图级别。
159+
* @version 11.0.1
160+
* @param {number} resolution - 分辨率。
161+
* @param {Array} resolutions - 分辨率数组。
162+
* @returns {number} 地图级别。
163+
* @usage
164+
* ```
165+
* // 浏览器
166+
* <script type="text/javascript" src="{cdn}"></script>
167+
* <script>
168+
* const result = {namespace}.getZoomByResolution(resolution, resolutions);
169+
*
170+
* </script>
171+
*
172+
* // ES6 Import
173+
* import { getZoomByResolution } from '{npm}';
174+
*
175+
* const result = getZoomByResolution(resolution, resolutions);
176+
* ```
177+
*/
132178
export function getZoomByResolution(resolution, resolutions) {
133179
let zoom = 0;
134180
let minDistance;
@@ -144,6 +190,29 @@ export function getZoomByResolution(resolution, resolutions) {
144190
return zoom;
145191
}
146192

193+
/**
194+
* @function scaleToResolution
195+
* @description 通过比例尺计算分辨率。
196+
* @version 11.0.1
197+
* @param {number} scale - 比例尺。
198+
* @param {number} dpi - 屏幕分辨率。
199+
* @param {string} mapUnit - 地图单位。
200+
* @returns {number} 分辨率。
201+
* @usage
202+
* ```
203+
* // 浏览器
204+
* <script type="text/javascript" src="{cdn}"></script>
205+
* <script>
206+
* const result = {namespace}.scaleToResolution(scale, dpi, mapUnit);
207+
*
208+
* </script>
209+
*
210+
* // ES6 Import
211+
* import { scaleToResolution } from '{npm}';
212+
*
213+
* const result = scaleToResolution(scale, dpi, mapUnit);
214+
* ```
215+
*/
147216
export function scaleToResolution(scale, dpi, mapUnit) {
148217
const inchPerMeter = 1 / 0.0254;
149218
const meterPerMapUnitValue = getMeterPerMapUnit(mapUnit);

src/leaflet/mapping/initMap.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import proj4 from 'proj4';
1313
* @function initMap
1414
* @description 根据 SuperMap iServer 服务参数,创建地图与图层。目前仅支持SuperMap iServer 地图服务,创建的图层为 TiledMapLayer。
1515
* @category BaseTypes Util
16+
* @version 11.0.1
1617
* @example
1718
* initMap(url, {mapOptions, layerOptions});
1819
* @param {string} url - 服务地址,例如: http://{ip}:{port}/iserver/services/map-world/rest/maps/World。
@@ -64,6 +65,7 @@ export function initMap(url, options) {
6465
* @function crsFromMapJSON
6566
* @description 通过iServer REST地图的配置信息,构建地图的CRS(非平面投影、EPSG:3857、EPSG:4326需要先注册投影)。
6667
* @category BaseTypes Util
68+
* @version 11.0.1
6769
* @param {Object} mapJSONObj - 地图参数。
6870
* @param {Object} mapJSONObj.prjCoordSys - 投影配置。
6971
* @param {Object} mapJSONObj.bounds - 范围。

src/openlayers/mapping/InitMap.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ window.proj4 = proj4;
1414
* @function initMap
1515
* @description 根据 SuperMap iServer 服务参数,创建地图与图层。目前仅支持SuperMap iServer 地图服务,创建的图层为 ol.Tile。
1616
* @category BaseTypes Util
17+
* @version 11.0.1
1718
* @param {number} url - 服务地址,例如: http://{ip}:{port}/iserver/services/map-world/rest/maps/World。
1819
* @param {Object} options - 参数。
1920
* @param {Object} [options.mapOptions] - 地图配置,参数设置参考 {@link https://openlayers.org/en/v6.15.1/apidoc/module-ol_Map-Map.html}。
@@ -63,6 +64,7 @@ export function initMap(url, options = {}) {
6364
/**
6465
* @function viewOptionsFromMapJSON
6566
* @category BaseTypes Util
67+
* @version 11.0.1
6668
* @description 通过 iServer REST 地图参数构造 ol 视图对象。
6769
* @param {Object} mapJSONObj - 地图 JSON 对象。
6870
* @param {number} [level=22] - 地图最大级别。

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