@@ -48,6 +48,7 @@ export class WebMap extends mapboxgl.Evented {
4848 if ( this . _mapInfo . center && crs === 'EPSG:3857' ) {
4949 center = Util . unproject ( center ) ;
5050 }
51+ const fontFamilys = this . _getLabelFontFamily ( ) ;
5152 // 初始化 map
5253 const mapOptions = {
5354 container : this . target ,
@@ -63,7 +64,8 @@ export class WebMap extends mapboxgl.Evented {
6364 minzoom,
6465 maxzoom,
6566 bearing,
66- pitch
67+ pitch,
68+ localIdeographFontFamily : fontFamilys || ''
6769 } ;
6870 this . map = new mapboxgl . Map ( mapOptions ) ;
6971 this . fire ( 'mapinitialized' , { map : this . map } ) ;
@@ -244,7 +246,7 @@ export class WebMap extends mapboxgl.Evented {
244246 * @param {Array<Object> } layers - 图层信息。
245247 */
246248 _generateV2LayersStructure ( ) {
247- const originLayers = this . _mapResourceInfo . layers . filter ( item => item . visible ) ;
249+ const originLayers = this . _mapResourceInfo . catalogs . filter ( item => item . visible ) ;
248250 const layers = originLayers . map ( layer => {
249251 const { themeSetting = { } , title } = layer ;
250252 const realLayerId = this . _layerIdMapList [ layer . id ] ;
@@ -266,4 +268,22 @@ export class WebMap extends mapboxgl.Evented {
266268 } )
267269 return layers ;
268270 }
271+
272+ /**
273+ * @private
274+ * @function mapboxgl.supermap.WebMap.prototype._getLabelFontFamily
275+ * @description 获取图层字体类型。
276+ */
277+ _getLabelFontFamily ( ) {
278+ const fonts = [ ] ;
279+ const layers = this . _mapInfo . layers ;
280+ if ( layers && layers . length > 0 ) {
281+ layers . forEach ( layer => {
282+ const textFont = layer . layout && layer . layout [ 'text-font' ] || [ ] ;
283+ fonts . push ( ...textFont ) ;
284+ } ) ;
285+ }
286+ const fontFamilys = fonts . join ( ',' ) ;
287+ return fontFamilys ;
288+ }
269289}
0 commit comments