@@ -3378,20 +3378,31 @@ export class WebMap extends Observable {
33783378 * @param {object } mapInfo - 地图信息
33793379 */
33803380 getMBStyle ( mapInfo ) {
3381- let baseLayer = mapInfo . baseLayer ,
3382- url = baseLayer . dataSource . url ,
3383- layerInfo = { } ;
3384- return FetchRequest . get ( this . getRequestUrl ( url ) ) . then ( result => {
3381+ let _this = this ,
3382+ baseLayer = mapInfo . baseLayer ,
3383+ dataSource = baseLayer . dataSource || { } ,
3384+ { url, serverId } = dataSource ,
3385+ layerInfo = { } ,
3386+ styleUrl ;
3387+ styleUrl = serverId !== undefined ? `${ this . server } web/datas/${ serverId } /download` : url ;
3388+ return FetchRequest . get ( this . getRequestUrl ( styleUrl ) , null , {
3389+ withCredentials : this . withCredentials ,
3390+ withoutFormatSuffix : true ,
3391+ headers : {
3392+ 'Content-Type' : 'application/json;chartset=uft-8'
3393+ }
3394+ } ) . then ( result => {
33853395 return result . json ( ) ;
33863396 } ) . then ( styles => {
3397+ _this . _matchStyleObject ( styles ) ;
33873398 let extent = styles . metadata . mapbounds ;
33883399 baseLayer . extent = extent ; // 这里把extent保存一下
33893400
33903401 layerInfo . projection = mapInfo . projection ,
33913402 layerInfo . epsgCode = mapInfo . projection ,
33923403 layerInfo . visible = baseLayer . visible ,
33933404 layerInfo . name = baseLayer . name ,
3394- layerInfo . url = url ,
3405+ layerInfo . url = styleUrl ,
33953406 layerInfo . sourceType = 'VECTOR_TILE' ,
33963407 layerInfo . layerType = 'VECTOR_TILE' ,
33973408 layerInfo . styles = styles ,
@@ -3408,6 +3419,23 @@ export class WebMap extends Observable {
34083419 } )
34093420 }
34103421
3422+ /**
3423+ * @private
3424+ * @function mapboxgl.supermap.WebMap.prototype._matchStyleObject
3425+ * @description 恢复 style 为标准格式。
3426+ * @param {Object } style - mapbox 样式。
3427+ */
3428+ _matchStyleObject ( style ) {
3429+ let { sprite, glyphs } = style ;
3430+ if ( sprite && typeof sprite === 'object' ) {
3431+ style . sprite = Object . values ( sprite ) [ 0 ] ;
3432+ }
3433+ if ( glyphs && typeof glyphs === 'object' ) {
3434+ style . glyphs = Object . values ( glyphs ) [ 0 ] ;
3435+ }
3436+ }
3437+
3438+
34113439 /**
34123440 * @private
34133441 * @function ol.supermap.WebMap.prototype.createMVTLayer
0 commit comments