Skip to content

Commit 27489bc

Browse files
committed
fix v3文本标签图例由显示图层名改为字段名称 review by xiongjj
1 parent e84d343 commit 27489bc

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/common/mapping/WebMapV3.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -908,6 +908,7 @@ export function createWebMapV3Extending(SuperClass, { MapManager, mapRepo, crsMa
908908
_createLayerLegendList(layer, styleSetting) {
909909
const layerId = layer.id;
910910
const layerTitle = layer.title;
911+
const textFieldName = styleSetting.type === 'text' && styleSetting.textField && styleSetting.textField.value.replace(/^\{|\}$/g, '');
911912
const commonStyleOptions = {
912913
themeField: layer.themeField || styleSetting.field,
913914
layerId,
@@ -971,7 +972,7 @@ export function createWebMapV3Extending(SuperClass, { MapManager, mapRepo, crsMa
971972
...commonStyleOptions,
972973
styleGroup: [
973974
{
974-
fieldValue: layerTitle || layerId,
975+
fieldValue: textFieldName || layerTitle || layerId,
975976
style: {
976977
...simpleResData,
977978
shape

test/mapboxgl/mapping/WebMapV3Spec.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1116,6 +1116,12 @@ describe('mapboxgl-webmap3.0', () => {
11161116
const webMapV3 = mapstudioWebmap._getWebMapInstance();
11171117
expect(map).not.toBeUndefined();
11181118
expect(webMapV3.getLegends().length).toBe(9);
1119+
const testLegend= webMapV3.getLegends().filter((item) => {
1120+
return item.layerId === "上海市可校外学习中心(1)";
1121+
})
1122+
expect(testLegend.length).toBe(2);
1123+
expect(testLegend[0].styleGroup[0].fieldValue).toBe("上海市可校外学习中心(1)");
1124+
expect(testLegend[1].styleGroup[0].fieldValue).toBe("学习中心(点)名称");
11191125
mbglmap.prototype.getL7Scene = undefined;
11201126
spyTest.calls.reset();
11211127
done();

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