* @private * @function WebMapV3.prototype._createMap * @description 创建地图。
()
| 267 | * @description 创建地图。 |
| 268 | */ |
| 269 | _createMap() { |
| 270 | let { |
| 271 | name = '', |
| 272 | center = new mapRepo.LngLat(0, 0), |
| 273 | zoom = 0, |
| 274 | bearing = 0, |
| 275 | pitch = 0, |
| 276 | minzoom, |
| 277 | maxzoom, |
| 278 | sprite = '' |
| 279 | } = this._mapInfo; |
| 280 | center = this.mapOptions.center || center; |
| 281 | zoom = this.mapOptions.zoom || zoom; |
| 282 | bearing = this.mapOptions.bearing || bearing; |
| 283 | pitch = this.mapOptions.pitch || pitch; |
| 284 | const fontFamilys = this._getLabelFontFamily(); |
| 285 | // 初始化 map |
| 286 | const mapOptions = { |
| 287 | ...this.mapOptions, |
| 288 | transformRequest: this._getTransformRequest(), |
| 289 | container: this.options.target, |
| 290 | crs: this._baseProjection, |
| 291 | center, |
| 292 | zoom, |
| 293 | style: { |
| 294 | sprite, |
| 295 | name, |
| 296 | version: 8, |
| 297 | sources: {}, |
| 298 | layers: [] |
| 299 | }, |
| 300 | minZoom: minzoom, |
| 301 | maxZoom: maxzoom, |
| 302 | bearing, |
| 303 | pitch, |
| 304 | localIdeographFontFamily: fontFamilys || '' |
| 305 | }; |
| 306 | this.map = new MapManager(mapOptions); |
| 307 | this._sprite = sprite; |
| 308 | this.fire('mapinitialized', { map: this.map }); |
| 309 | this.map.on('load', () => { |
| 310 | this._initLayers(); |
| 311 | }); |
| 312 | } |
| 313 | |
| 314 | _getTransformRequest() { |
| 315 | if (this.mapOptions.transformRequest) { |
no test coverage detected