Skip to content

Commit 949fb1e

Browse files
committed
【fix】处理字体图标带text-field字段的没显示,并且控制台有报错 review by neiqj
1 parent 8619a27 commit 949fb1e

File tree

1 file changed

+33
-13
lines changed

1 file changed

+33
-13
lines changed

src/mapboxgl/mapping/webmap/v3/WebMap.js

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export class WebMap extends mapboxgl.Evented {
1919
}
2020

2121
/**
22-
* @function mapboxgl.supermap.WebMap.prototype.createWebMap
22+
* @function WebMap.prototype.createWebMap
2323
* @description 登陆窗口后添加地图图层。
2424
* @param {Object} mapInfo - map 信息。
2525
* @param {Object} map - map 实例。
@@ -36,14 +36,15 @@ export class WebMap extends mapboxgl.Evented {
3636

3737
/**
3838
* @private
39-
* @function mapboxgl.supermap.WebMap.prototype._createMap
39+
* @function WebMap.prototype._createMap
4040
* @description 创建地图。
4141
*/
4242
_createMap() {
4343
let { name, crs, center = new mapboxgl.LngLat(0, 0), zoom = 0, bearing = 0, pitch = 0, minzoom, maxzoom } = this._mapInfo;
4444
if (this._mapInfo.center && crs === 'EPSG:3857') {
4545
center = Util.unproject(center);
4646
}
47+
const fontFamilys = this._getLabelFontFamily();
4748
// 初始化 map
4849
const mapOptions = {
4950
container: this.target,
@@ -59,7 +60,8 @@ export class WebMap extends mapboxgl.Evented {
5960
minzoom,
6061
maxzoom,
6162
bearing,
62-
pitch
63+
pitch,
64+
localIdeographFontFamily: fontFamilys || ''
6365
};
6466
this.map = new mapboxgl.Map(mapOptions);
6567
this.fire('mapinitialized', { map: this.map });
@@ -70,7 +72,7 @@ export class WebMap extends mapboxgl.Evented {
7072

7173
/**
7274
* @private
73-
* @function mapboxgl.supermap.WebMap.prototype._initLayers
75+
* @function WebMap.prototype._initLayers
7476
* @description emit 图层加载成功事件。
7577
*/
7678
_initLayers() {
@@ -94,7 +96,7 @@ export class WebMap extends mapboxgl.Evented {
9496

9597
/**
9698
* @private
97-
* @function mapboxgl.supermap.WebMap.prototype._createMapRelatedInfo
99+
* @function WebMap.prototype._createMapRelatedInfo
98100
* @description 创建地图相关资源。
99101
*/
100102
_createMapRelatedInfo() {
@@ -131,7 +133,7 @@ export class WebMap extends mapboxgl.Evented {
131133

132134
/**
133135
* @private
134-
* @function mapboxgl.supermap.WebMap.prototype._getMapRelatedInfo
136+
* @function WebMap.prototype._getMapRelatedInfo
135137
* @description 获取地图关联信息的 JSON 信息。
136138
*/
137139
_getMapRelatedInfo() {
@@ -141,7 +143,7 @@ export class WebMap extends mapboxgl.Evented {
141143
})
142144
.catch((error) => {
143145
/**
144-
* @event mapboxgl.supermap.WebMap#getmapfailed
146+
* @event WebMap#getmapfailed
145147
* @description 获取地图信息失败。
146148
* @property {Object} error - 失败原因。
147149
*/
@@ -151,7 +153,7 @@ export class WebMap extends mapboxgl.Evented {
151153

152154
/**
153155
* @private
154-
* @function mapboxgl.supermap.WebMap.prototype._addLayersToMap
156+
* @function WebMap.prototype._addLayersToMap
155157
* @description emit 图层加载成功事件。
156158
*/
157159
_addLayersToMap() {
@@ -168,7 +170,7 @@ export class WebMap extends mapboxgl.Evented {
168170

169171
/**
170172
* @private
171-
* @function mapboxgl.supermap.WebMap.prototype._setUniqueId
173+
* @function WebMap.prototype._setUniqueId
172174
* @description 返回唯一 id 的 sources 和 layers。
173175
* @param {Object} mapInfo - map 信息。
174176
*/
@@ -202,7 +204,7 @@ export class WebMap extends mapboxgl.Evented {
202204

203205
/**
204206
* @private
205-
* @function mapboxgl.supermap.WebMap.prototype._sortLayers
207+
* @function WebMap.prototype._sortLayers
206208
* @description 调整图层位置。
207209
* @param {Array<Object>} layers - 图层信息。
208210
*/
@@ -225,7 +227,7 @@ export class WebMap extends mapboxgl.Evented {
225227

226228
/**
227229
* @private
228-
* @function mapboxgl.supermap.WebMap.prototype._sendMapToUser
230+
* @function WebMap.prototype._sendMapToUser
229231
* @description emit 图层加载成功事件。
230232
*/
231233
_sendMapToUser() {
@@ -235,12 +237,12 @@ export class WebMap extends mapboxgl.Evented {
235237

236238
/**
237239
* @private
238-
* @function mapboxgl.supermap.WebMap.prototype._generateV2LayersStructure
240+
* @function WebMap.prototype._generateV2LayersStructure
239241
* @description emit 图层加载成功事件。
240242
* @param {Array<Object>} layers - 图层信息。
241243
*/
242244
_generateV2LayersStructure() {
243-
const originLayers = this._mapResourceInfo.layers.filter(item => item.visible);
245+
const originLayers = this._mapResourceInfo.catalogs.filter(item => item.visible);
244246
const layers = originLayers.map(layer => {
245247
const { themeSetting = {}, title } = layer;
246248
const realLayerId = this._layerIdMapList[layer.id];
@@ -262,4 +264,22 @@ export class WebMap extends mapboxgl.Evented {
262264
})
263265
return layers;
264266
}
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+
}
265285
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy