Skip to content

Commit 88b1a73

Browse files
修复雪碧图地址错误
1 parent c34a560 commit 88b1a73

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

src/mapboxgl/mapping/webmap/v3/WebMap.js

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,20 @@ export const LEGEND_STYLE_KEYS = {
2929
};
3030

3131
export class WebMap extends mapboxgl.Evented {
32-
constructor(mapId, options) {
32+
/**
33+
* @constructs
34+
* @version 9.1.2
35+
*/
36+
constructor(mapId, options, mapOptions) {
3337
super();
3438
this.mapId = mapId;
3539
this.server = options.server;
3640
this.withCredentials = options.withCredentials;
3741
this.target = options.target;
42+
this.center = mapOptions.center;
43+
this.zoom = mapOptions.zoom;
44+
this.bearing = mapOptions.bearing;
45+
this.pitch = mapOptions.pitch;
3846
this.mapResourceUrl = Util.transformUrl(Object.assign({ url: `${this.server}web/maps/${mapId}` }, this.options));
3947
this._layersOfV3 = [];
4048
this._layerIdMapList = {};
@@ -67,9 +75,13 @@ export class WebMap extends mapboxgl.Evented {
6775
*/
6876
_createMap() {
6977
let { name, crs, center = new mapboxgl.LngLat(0, 0), zoom = 0, bearing = 0, pitch = 0, minzoom, maxzoom, sprite } = this._mapInfo;
78+
center = this.center || center;
7079
if (this._mapInfo.center && crs === 'EPSG:3857') {
7180
center = Util.unproject(center);
7281
}
82+
zoom = this.zoom || zoom;
83+
bearing = this.bearing || bearing;
84+
pitch = this.pitch || pitch;
7385
const fontFamilys = this._getLabelFontFamily();
7486
// 初始化 map
7587
const mapOptions = {
@@ -259,6 +271,16 @@ export class WebMap extends mapboxgl.Evented {
259271
return this._legendList;
260272
}
261273

274+
cleanWebMap() {
275+
if (this.map) {
276+
this.map = null;
277+
this._legendList = [];
278+
this.center = null;
279+
this.zoom = null;
280+
this._appreciableLayers = [];
281+
}
282+
}
283+
262284
/**
263285
* @private
264286
* @function WebMap.prototype._generateV2LayersStructure
@@ -333,6 +355,7 @@ export class WebMap extends mapboxgl.Evented {
333355
* @description 获取雪碧图信息。
334356
*/
335357
_getSpriteDatas(spriteUrl) {
358+
spriteUrl = this.server + spriteUrl.split('/iportal')[1];
336359
return FetchRequest.get(spriteUrl, null, { withCredentials: this.withCredentials })
337360
.then((response) => {
338361
return response.json();
@@ -355,7 +378,7 @@ export class WebMap extends mapboxgl.Evented {
355378
layerId: layer.id
356379
};
357380
if (keyName === 'color') {
358-
let symbolId = simpleStyle['symbolsContent'].value.symbol;
381+
let symbolId = simpleStyle['symbolsContent'] && simpleStyle['symbolsContent'].value.symbol;
359382
if (symbolId) {
360383
let symbolInfo = this._spriteDatas[symbolId];
361384
styleList[keyName].values.forEach((info) => {

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