@@ -29,12 +29,20 @@ export const LEGEND_STYLE_KEYS = {
29
29
} ;
30
30
31
31
export class WebMap extends mapboxgl . Evented {
32
- constructor ( mapId , options ) {
32
+ /**
33
+ * @constructs
34
+ * @version 9.1.2
35
+ */
36
+ constructor ( mapId , options , mapOptions ) {
33
37
super ( ) ;
34
38
this . mapId = mapId ;
35
39
this . server = options . server ;
36
40
this . withCredentials = options . withCredentials ;
37
41
this . target = options . target ;
42
+ this . center = mapOptions . center ;
43
+ this . zoom = mapOptions . zoom ;
44
+ this . bearing = mapOptions . bearing ;
45
+ this . pitch = mapOptions . pitch ;
38
46
this . mapResourceUrl = Util . transformUrl ( Object . assign ( { url : `${ this . server } web/maps/${ mapId } ` } , this . options ) ) ;
39
47
this . _layersOfV3 = [ ] ;
40
48
this . _layerIdMapList = { } ;
@@ -67,9 +75,13 @@ export class WebMap extends mapboxgl.Evented {
67
75
*/
68
76
_createMap ( ) {
69
77
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 ;
70
79
if ( this . _mapInfo . center && crs === 'EPSG:3857' ) {
71
80
center = Util . unproject ( center ) ;
72
81
}
82
+ zoom = this . zoom || zoom ;
83
+ bearing = this . bearing || bearing ;
84
+ pitch = this . pitch || pitch ;
73
85
const fontFamilys = this . _getLabelFontFamily ( ) ;
74
86
// 初始化 map
75
87
const mapOptions = {
@@ -259,6 +271,16 @@ export class WebMap extends mapboxgl.Evented {
259
271
return this . _legendList ;
260
272
}
261
273
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
+
262
284
/**
263
285
* @private
264
286
* @function WebMap.prototype._generateV2LayersStructure
@@ -333,6 +355,7 @@ export class WebMap extends mapboxgl.Evented {
333
355
* @description 获取雪碧图信息。
334
356
*/
335
357
_getSpriteDatas ( spriteUrl ) {
358
+ spriteUrl = this . server + spriteUrl . split ( '/iportal' ) [ 1 ] ;
336
359
return FetchRequest . get ( spriteUrl , null , { withCredentials : this . withCredentials } )
337
360
. then ( ( response ) => {
338
361
return response . json ( ) ;
@@ -355,7 +378,7 @@ export class WebMap extends mapboxgl.Evented {
355
378
layerId : layer . id
356
379
} ;
357
380
if ( keyName === 'color' ) {
358
- let symbolId = simpleStyle [ 'symbolsContent' ] . value . symbol ;
381
+ let symbolId = simpleStyle [ 'symbolsContent' ] && simpleStyle [ 'symbolsContent' ] . value . symbol ;
359
382
if ( symbolId ) {
360
383
let symbolInfo = this . _spriteDatas [ symbolId ] ;
361
384
styleList [ keyName ] . values . forEach ( ( info ) => {
0 commit comments