@@ -29,12 +29,18 @@ export const LEGEND_STYLE_KEYS = {
2929} ;
3030
3131export class WebMap extends mapboxgl . Evented {
32- constructor ( mapId , options ) {
32+ constructor ( mapId , options , mapOptions ) {
3333 super ( ) ;
3434 this . mapId = mapId ;
3535 this . server = options . server ;
3636 this . withCredentials = options . withCredentials ;
3737 this . target = options . target ;
38+ this . mapOptions = {
39+ center : mapOptions . center ,
40+ zoom : mapOptions . zoom ,
41+ bearing : mapOptions . bearing ,
42+ pitch : mapOptions . pitch
43+ }
3844 this . mapResourceUrl = Util . transformUrl ( Object . assign ( { url : `${ this . server } web/maps/${ mapId } ` } , this . options ) ) ;
3945 this . _layersOfV3 = [ ] ;
4046 this . _layerIdMapList = { } ;
@@ -67,9 +73,13 @@ export class WebMap extends mapboxgl.Evented {
6773 */
6874 _createMap ( ) {
6975 let { name, crs, center = new mapboxgl . LngLat ( 0 , 0 ) , zoom = 0 , bearing = 0 , pitch = 0 , minzoom, maxzoom, sprite } = this . _mapInfo ;
76+ center = this . mapOptions . center || center ;
7077 if ( this . _mapInfo . center && crs === 'EPSG:3857' ) {
7178 center = Util . unproject ( center ) ;
7279 }
80+ zoom = this . mapOptions . zoom || zoom ;
81+ bearing = this . mapOptions . bearing || bearing ;
82+ pitch = this . mapOptions . pitch || pitch ;
7383 const fontFamilys = this . _getLabelFontFamily ( ) ;
7484 // 初始化 map
7585 const mapOptions = {
@@ -259,6 +269,15 @@ export class WebMap extends mapboxgl.Evented {
259269 return this . _legendList ;
260270 }
261271
272+ cleanWebMap ( ) {
273+ if ( this . map ) {
274+ this . map = null ;
275+ this . _legendList = [ ] ;
276+ this . mapOptions = { } ;
277+ this . _appreciableLayers = [ ] ;
278+ }
279+ }
280+
262281 /**
263282 * @private
264283 * @function WebMap.prototype._generateV2LayersStructure
@@ -333,6 +352,7 @@ export class WebMap extends mapboxgl.Evented {
333352 * @description 获取雪碧图信息。
334353 */
335354 _getSpriteDatas ( spriteUrl ) {
355+ spriteUrl = this . server + spriteUrl . split ( '/iportal' ) [ 1 ] ;
336356 return FetchRequest . get ( spriteUrl , null , { withCredentials : this . withCredentials } )
337357 . then ( ( response ) => {
338358 return response . json ( ) ;
@@ -355,7 +375,7 @@ export class WebMap extends mapboxgl.Evented {
355375 layerId : layer . id
356376 } ;
357377 if ( keyName === 'color' ) {
358- let symbolId = simpleStyle [ 'symbolsContent' ] . value . symbol ;
378+ let symbolId = simpleStyle [ 'symbolsContent' ] && simpleStyle [ 'symbolsContent' ] . value . symbol ;
359379 if ( symbolId ) {
360380 let symbolInfo = this . _spriteDatas [ symbolId ] ;
361381 styleList [ keyName ] . values . forEach ( ( info ) => {
0 commit comments