Skip to content

Commit 54c7f1f

Browse files
committed
[fix]处理layer visible为布尔和字符串的情况
1 parent 27cba57 commit 54c7f1f

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/common/mapping/WebMapV2.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,6 @@ export function createWebMapV2Extending(SuperClass, { MapManager, mapRepo }) {
320320

321321
_createMVTBaseLayer(layerInfo, addedCallback) {
322322
let url = layerInfo.dataSource.url;
323-
const visible = layerInfo.visible;
324323
if (url.indexOf('/restjsr/') > -1 && !/\/style\.json$/.test(url)) {
325324
url += '/style.json';
326325
}
@@ -334,7 +333,7 @@ export function createWebMapV2Extending(SuperClass, { MapManager, mapRepo }) {
334333
return;
335334
}
336335
style.layers.forEach(layer => {
337-
layer.layout && (layer.layout.visibility = visible ? 'visible' : 'none');
336+
layer.layout && (layer.layout.visibility = this._getVisibility(layerInfo.visible));
338337
})
339338
this.map.addStyle(style);
340339
const layerIds = [];
@@ -2410,7 +2409,7 @@ export function createWebMapV2Extending(SuperClass, { MapManager, mapRepo }) {
24102409
minzoom: minzoom || 0,
24112410
maxzoom: maxzoom || 22,
24122411
layout: {
2413-
visibility: visibility ? 'visible' : 'none'
2412+
visibility: this._getVisibility(visibility)
24142413
}
24152414
},
24162415
parentLayerId
@@ -2981,5 +2980,10 @@ export function createWebMapV2Extending(SuperClass, { MapManager, mapRepo }) {
29812980
_isDataflowLayer(layerType) {
29822981
return layerType === 'DATAFLOW_POINT_TRACK' || layerType === 'DATAFLOW_HEAT';
29832982
}
2983+
2984+
_getVisibility(visible) {
2985+
const visibility = (visible === true || visible === 'visible') ? 'visible' : 'none';
2986+
return visibility;
2987+
}
29842988
};
29852989
}

0 commit comments

Comments
 (0)