Skip to content

Commit

Permalink
【fix】修复单值专题图自定义样式是透明度调整地图加载报错的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
luoxiao-supermap committed Jul 26, 2024
1 parent e143c5e commit 66d54d2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
3 changes: 3 additions & 0 deletions src/mapboxgl/web-map/WebMapV2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1566,6 +1566,9 @@ export default class WebMap extends WebMapBase {
for (const key in expressionMap) {
if (Object.prototype.hasOwnProperty.call(expressionMap, key)) {
const expression = expressionMap[key];
if (!Array.isArray(expression)) {
continue;
}
const defaultStyleItem = defultLayerStyle[key] || defaultValueFactory[key];
const styleItem = { [key]: defaultStyleItem };
// 从customsetting里取了透明度和color一起处理了,layerinfo.style里的透明度就不需要了
Expand Down
2 changes: 1 addition & 1 deletion src/mapboxgl/web-map/__tests__/WebMapViewModel.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ describe('WebMapViewModel.spec', () => {
expect(item.renderLayers.length).toBeGreaterThanOrEqual(1);
})
expect(viewModel.map.getStyle().layers.find((item)=>{return item.type === 'fill'}).paint['fill-opacity']).toBe(1);
expect(viewModel.map.getStyle().layers.find((item)=>{return item.type === 'fill'}).paint['fill-color'][3]).toBe('rgba(213, 62, 79, 0.9)');
expect(viewModel.map.getStyle().layers.find((item)=>{return item.type === 'fill'}).paint['fill-color'][3]).toBe('rgba(230, 245, 153, 0.7)');
done();
};
viewModel.on({ addlayerssucceeded: callback });
Expand Down
6 changes: 3 additions & 3 deletions test/unit/mocks/data/WebMap/uniqueLayer_polygon.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
"layerType": "UNIQUE",
"visible": true,
"themeSetting": {
"themeField": "行政区划_c",
"themeField": "机场",
"customSettings": {
"四川省": {
"北京/首都": {
"strokeWidth": 1,
"fillColor": "#e6f599",
"fillOpacity": 0.9,
"fillOpacity": 0.7,
"lineDash": "solid",
"strokeColor": "#ffffff",
"type": "POLYGON",
Expand Down

0 comments on commit 66d54d2

Please sign in to comment.