Skip to content

Commit e43ccd3

Browse files
committed
fix: 线图层的图片符号height统一10px。在vue-iclient中处理具体绘制
AI-GEN: 100% doubao-seed-2.1-pro (reviewed by xjj)
1 parent 215712e commit e43ccd3

2 files changed

Lines changed: 26 additions & 2 deletions

File tree

‎src/common/mapping/WebMapV3.js‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ const MAP_LAYER_TYPE_2_SYMBOL_TYPE = {
165165
};
166166

167167
const LEGEND_LINE_WIDTH = 100;
168+
const LEGEND_LINE_IMAGE_HEIGHT = 10;
168169
const LINE_WIDTH_KEY = 'line-width';
169170

170171
export const LEGEND_STYLE_TYPES = {
@@ -1434,7 +1435,9 @@ export function createWebMapV3Extending(SuperClass, { MapManager, mapRepo, crsMa
14341435
const imageLineSymbol = symbolStyles[0];
14351436
if (hasImageLine) {
14361437
const imageId = this._getImageIdByLegendType(imageLineSymbol, legendRenderType);
1437-
const styleOptions = { ...cssStyle, ...nextCustomValue, height: cssStyle.width, width: LEGEND_LINE_WIDTH };
1438+
// 普通线图层的图片符号高度统一,动画线保持原来逻辑
1439+
const imageHeight = legendRenderType === LEGEND_RENDER_TYPE.LINE ? LEGEND_LINE_IMAGE_HEIGHT : cssStyle.width;
1440+
const styleOptions = { ...cssStyle, ...nextCustomValue, height: imageHeight, width: LEGEND_LINE_WIDTH };
14381441
if (legendRenderType === LEGEND_RENDER_TYPE.ANIMATELINE && nextCustomValue.textureBlend === 'replace') {
14391442
styleOptions.backgroundColor = 'transparent';
14401443
}

‎test/common/mapping/WebMapV3Spec.js‎

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2396,19 +2396,39 @@ describe('WebMapV3 - _parseLegendtyle types', () => {
23962396
expect(result.lineStyles[0].color).toBe('red');
23972397
});
23982398

2399-
it('LINE with image symbol should return sprite image style', () => {
2399+
it('LINE with image symbol should return sprite image style with unified height', () => {
24002400
const { instance } = createTestContext();
24012401
instance._sprite = 'http://localhost:8190/iportal/web/maps/1/sprites/sprite';
24022402
instance._spriteDatas = { 'line-tex': { width: 8, height: 4 } };
24032403
const result = instance._parseLegendtyle({
24042404
legendRenderType: 'LINE',
24052405
customValue: {
2406+
width: 6,
24062407
symbolsContent: { style: [{ paint: { 'line-pattern': 'line-tex' } }] }
24072408
}
24082409
});
24092410
expect(result.type).toBe('image');
24102411
expect(result.sprite).toEqual({ width: 8, height: 4 });
24112412
expect(result.url).toBe('http://localhost:8190/iportal/web/maps/1/sprites/sprite.png');
2413+
// 普通线图层图片符号高度统一为 10、宽度 100,不使用线宽或图片尺寸
2414+
expect(result.height).toBe(10);
2415+
expect(result.width).toBe(100);
2416+
});
2417+
2418+
it('ANIMATELINE with image symbol should keep original height logic', () => {
2419+
const { instance } = createTestContext();
2420+
instance._sprite = 'http://localhost:8190/iportal/web/maps/1/sprites/sprite';
2421+
instance._spriteDatas = { 'anim-tex': { width: 8, height: 8 } };
2422+
const result = instance._parseLegendtyle({
2423+
legendRenderType: 'ANIMATELINE',
2424+
customValue: {
2425+
symbolsContent: { style: [{ layout: { 'icon-image': 'anim-tex' } }] }
2426+
}
2427+
});
2428+
expect(result.type).toBe('image');
2429+
expect(result.width).toBe(100);
2430+
// 动画线图片符号高度保持 cssStyle.width 的原逻辑,不使用统一高度
2431+
expect(result.height).toBe(20);
24122432
});
24132433

24142434
it('ANIMATELINE replacing color should return transparent background image', () => {
@@ -2424,6 +2444,7 @@ describe('WebMapV3 - _parseLegendtyle types', () => {
24242444
});
24252445
expect(result.type).toBe('image');
24262446
expect(result.backgroundColor).toBe('transparent');
2447+
expect(result.height).toBe(20);
24272448
});
24282449

24292450
it('FILL simple solid color should be vector style without url', () => {

0 commit comments

Comments
 (0)