MCPcopy Index your code
hub / github.com/SuperMap/iClient-JavaScript / _createMap

Method _createMap

src/common/mapping/WebMapV2.js:338–423  ·  view source on GitHub ↗
(mapInfo)

Source from the content-addressed store, hash-verified

336 }
337
338 async _createMap(mapInfo) {
339 // 获取字体样式
340 const fontFamilys = this._getLabelFontFamily(mapInfo);
341 const center = this._getMapCenter(mapInfo);
342 // zoom
343 let zoom = mapInfo.level || 0;
344 let zoomBase = 0;
345 let { bounds, minZoom, maxZoom } = this.mapOptions;
346 const interactive = this.mapOptions.interactive;
347 const tileSize = mapInfo.baseLayer.tileSize;
348
349 if (isNaN(minZoom)) {
350 minZoom = mapInfo.minScale
351 ? this._transformScaleToZoom(mapInfo.minScale, mapRepo.CRS.get(this.baseProjection), tileSize)
352 : 0;
353 }
354 if (isNaN(maxZoom)) {
355 maxZoom = mapInfo.maxScale
356 ? this._transformScaleToZoom(mapInfo.maxScale, mapRepo.CRS.get(this.baseProjection), tileSize)
357 : 22;
358 }
359 if (mapInfo.visibleExtent && mapInfo.visibleExtent.length === 4 && !bounds) {
360 bounds = [
361 this._unproject([mapInfo.visibleExtent[0], mapInfo.visibleExtent[1]]),
362 this._unproject([mapInfo.visibleExtent[2], mapInfo.visibleExtent[3]])
363 ];
364 }
365 if (minZoom > maxZoom) {
366 [minZoom, maxZoom] = [maxZoom, minZoom];
367 }
368 if (!bounds) {
369 if (mapInfo.minScale && mapInfo.maxScale) {
370 const scales = await this._getScales(mapInfo);
371 zoomBase = Math.min(
372 this._transformScaleToZoom(scales[0] || mapInfo.minScale, mapRepo.CRS.get(this.baseProjection), tileSize),
373 this._transformScaleToZoom(mapInfo.maxScale, mapRepo.CRS.get(this.baseProjection), tileSize)
374 );
375 } else {
376 zoomBase = +Math.log2(
377 this._getResolution(mapRepo.CRS.get(this.baseProjection).getExtent()) / this._getResolution(mapInfo.extent)
378 ).toFixed(2);
379 }
380 zoom += zoomBase;
381 }
382
383 // 初始化 map
384 this.map = new MapManager({
385 ...this.mapOptions,
386 container: this.target,
387 center: this.center || center,
388 zoom: this.zoom || zoom,
389 minZoom,
390 maxZoom,
391 bearing: this.bearing || 0,
392 pitch: this.pitch || 0,
393 interactive: interactive === void 0 ? true : interactive,
394 style: {
395 version: 8,

Callers 2

_loadLayersMethod · 0.95

Calls 15

_getLabelFontFamilyMethod · 0.95
_getMapCenterMethod · 0.95
_transformScaleToZoomMethod · 0.95
_unprojectMethod · 0.95
_getScalesMethod · 0.95
_getResolutionMethod · 0.95
minMethod · 0.80
handleProxyMethod · 0.80
handleWithCredentialsMethod · 0.80
indexOfMethod · 0.80
isIportalResourceUrlMethod · 0.80
handleParentResMethod · 0.80

Tested by

no test coverage detected