@@ -19,7 +19,7 @@ export class WebMap extends mapboxgl.Evented {
19
19
}
20
20
21
21
/**
22
- * @function mapboxgl.supermap. WebMap.prototype.createWebMap
22
+ * @function WebMap.prototype.createWebMap
23
23
* @description 登陆窗口后添加地图图层。
24
24
* @param {Object } mapInfo - map 信息。
25
25
* @param {Object } map - map 实例。
@@ -36,14 +36,15 @@ export class WebMap extends mapboxgl.Evented {
36
36
37
37
/**
38
38
* @private
39
- * @function mapboxgl.supermap. WebMap.prototype._createMap
39
+ * @function WebMap.prototype._createMap
40
40
* @description 创建地图。
41
41
*/
42
42
_createMap ( ) {
43
43
let { name, crs, center = new mapboxgl . LngLat ( 0 , 0 ) , zoom = 0 , bearing = 0 , pitch = 0 , minzoom, maxzoom } = this . _mapInfo ;
44
44
if ( this . _mapInfo . center && crs === 'EPSG:3857' ) {
45
45
center = Util . unproject ( center ) ;
46
46
}
47
+ const fontFamilys = this . _getLabelFontFamily ( ) ;
47
48
// 初始化 map
48
49
const mapOptions = {
49
50
container : this . target ,
@@ -59,7 +60,8 @@ export class WebMap extends mapboxgl.Evented {
59
60
minzoom,
60
61
maxzoom,
61
62
bearing,
62
- pitch
63
+ pitch,
64
+ localIdeographFontFamily : fontFamilys || ''
63
65
} ;
64
66
this . map = new mapboxgl . Map ( mapOptions ) ;
65
67
this . fire ( 'mapinitialized' , { map : this . map } ) ;
@@ -70,7 +72,7 @@ export class WebMap extends mapboxgl.Evented {
70
72
71
73
/**
72
74
* @private
73
- * @function mapboxgl.supermap. WebMap.prototype._initLayers
75
+ * @function WebMap.prototype._initLayers
74
76
* @description emit 图层加载成功事件。
75
77
*/
76
78
_initLayers ( ) {
@@ -94,7 +96,7 @@ export class WebMap extends mapboxgl.Evented {
94
96
95
97
/**
96
98
* @private
97
- * @function mapboxgl.supermap. WebMap.prototype._createMapRelatedInfo
99
+ * @function WebMap.prototype._createMapRelatedInfo
98
100
* @description 创建地图相关资源。
99
101
*/
100
102
_createMapRelatedInfo ( ) {
@@ -131,7 +133,7 @@ export class WebMap extends mapboxgl.Evented {
131
133
132
134
/**
133
135
* @private
134
- * @function mapboxgl.supermap. WebMap.prototype._getMapRelatedInfo
136
+ * @function WebMap.prototype._getMapRelatedInfo
135
137
* @description 获取地图关联信息的 JSON 信息。
136
138
*/
137
139
_getMapRelatedInfo ( ) {
@@ -141,7 +143,7 @@ export class WebMap extends mapboxgl.Evented {
141
143
} )
142
144
. catch ( ( error ) => {
143
145
/**
144
- * @event mapboxgl.supermap. WebMap#getmapfailed
146
+ * @event WebMap#getmapfailed
145
147
* @description 获取地图信息失败。
146
148
* @property {Object } error - 失败原因。
147
149
*/
@@ -151,7 +153,7 @@ export class WebMap extends mapboxgl.Evented {
151
153
152
154
/**
153
155
* @private
154
- * @function mapboxgl.supermap. WebMap.prototype._addLayersToMap
156
+ * @function WebMap.prototype._addLayersToMap
155
157
* @description emit 图层加载成功事件。
156
158
*/
157
159
_addLayersToMap ( ) {
@@ -168,7 +170,7 @@ export class WebMap extends mapboxgl.Evented {
168
170
169
171
/**
170
172
* @private
171
- * @function mapboxgl.supermap. WebMap.prototype._setUniqueId
173
+ * @function WebMap.prototype._setUniqueId
172
174
* @description 返回唯一 id 的 sources 和 layers。
173
175
* @param {Object } mapInfo - map 信息。
174
176
*/
@@ -202,7 +204,7 @@ export class WebMap extends mapboxgl.Evented {
202
204
203
205
/**
204
206
* @private
205
- * @function mapboxgl.supermap. WebMap.prototype._sortLayers
207
+ * @function WebMap.prototype._sortLayers
206
208
* @description 调整图层位置。
207
209
* @param {Array<Object> } layers - 图层信息。
208
210
*/
@@ -225,7 +227,7 @@ export class WebMap extends mapboxgl.Evented {
225
227
226
228
/**
227
229
* @private
228
- * @function mapboxgl.supermap. WebMap.prototype._sendMapToUser
230
+ * @function WebMap.prototype._sendMapToUser
229
231
* @description emit 图层加载成功事件。
230
232
*/
231
233
_sendMapToUser ( ) {
@@ -235,12 +237,12 @@ export class WebMap extends mapboxgl.Evented {
235
237
236
238
/**
237
239
* @private
238
- * @function mapboxgl.supermap. WebMap.prototype._generateV2LayersStructure
240
+ * @function WebMap.prototype._generateV2LayersStructure
239
241
* @description emit 图层加载成功事件。
240
242
* @param {Array<Object> } layers - 图层信息。
241
243
*/
242
244
_generateV2LayersStructure ( ) {
243
- const originLayers = this . _mapResourceInfo . layers . filter ( item => item . visible ) ;
245
+ const originLayers = this . _mapResourceInfo . catalogs . filter ( item => item . visible ) ;
244
246
const layers = originLayers . map ( layer => {
245
247
const { themeSetting = { } , title } = layer ;
246
248
const realLayerId = this . _layerIdMapList [ layer . id ] ;
@@ -262,4 +264,22 @@ export class WebMap extends mapboxgl.Evented {
262
264
} )
263
265
return layers ;
264
266
}
267
+
268
+ /**
269
+ * @private
270
+ * @function WebMap.prototype._getLabelFontFamily
271
+ * @description 获取图层字体类型。
272
+ */
273
+ _getLabelFontFamily ( ) {
274
+ const fonts = [ ] ;
275
+ const layers = this . _mapInfo . layers ;
276
+ if ( layers && layers . length > 0 ) {
277
+ layers . forEach ( layer => {
278
+ const textFont = layer . layout && layer . layout [ 'text-font' ] || [ ] ;
279
+ fonts . push ( ...textFont ) ;
280
+ } ) ;
281
+ }
282
+ const fontFamilys = fonts . join ( ',' ) ;
283
+ return fontFamilys ;
284
+ }
265
285
}
0 commit comments