MCPcopy Create free account
hub / github.com/SuperMap/iClient-JavaScript / getZoomByResolution

Function getZoomByResolution

src/common/util/MapCalculateUtil.js:237–250  ·  view source on GitHub ↗
(resolution, resolutions)

Source from the content-addressed store, hash-verified

235 * ```
236 */
237export function getZoomByResolution(resolution, resolutions) {
238 let zoom = 0;
239 let minDistance;
240 for (let i = 0; i < resolutions.length; i++) {
241 if (i === 0) {
242 minDistance = Math.abs(resolution - resolutions[i]);
243 }
244 if (minDistance > Math.abs(resolution - resolutions[i])) {
245 minDistance = Math.abs(resolution - resolutions[i]);
246 zoom = i;
247 }
248 }
249 return zoom;
250}
251
252/**
253 * @private

Callers 2

getZoomFunction · 0.90
getZoomByResolutionFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected