(mapInfo)
| 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, |
no test coverage detected