Skip to content

Commit fd3da60

Browse files
authored
Merge pull request #880 from stadtnavi/fix/poi-layer-zoom-level
fix(poi-layer): feature selectable below min zoom level
2 parents e3cfb86 + 09f6cd2 commit fd3da60

File tree

1 file changed

+26
-28
lines changed

1 file changed

+26
-28
lines changed

app/component/map/tile-layer/PoiVectorTileLayer.js

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -58,18 +58,18 @@ export default class PoiVectorTileLayer {
5858
const layerFeature = layerData.feature(index);
5959

6060
[[layerFeature.geom]] = layerFeature.loadGeometry();
61-
const feature = pick(layerFeature, ['geom', 'properties']);
62-
63-
if (
64-
!PoiVectorTileLayer.visibleCategories[
65-
feature.properties.category3
66-
]
67-
) {
68-
return null;
69-
}
70-
return feature;
61+
return pick(layerFeature, ['geom', 'properties']);
7162
})
72-
.filter(Boolean);
63+
.filter(feature => {
64+
const poiLayer = getLayerByCode(
65+
feature.properties.category3,
66+
this.config,
67+
);
68+
return (
69+
PoiVectorTileLayer.visibleCategories[poiLayer.code] &&
70+
this.tile.coords.z >= poiLayer.properties.layer.min_zoom
71+
);
72+
});
7373

7474
this.features.forEach(feature => {
7575
const layerCode = feature.properties.category3;
@@ -78,26 +78,24 @@ export default class PoiVectorTileLayer {
7878
if (poiLayer) {
7979
const { icon, layer } = poiLayer.properties;
8080

81-
if (this.tile.coords.z >= layer.min_zoom) {
82-
const parser = new DOMParser();
83-
const docs = parser.parseFromString(icon.svg, 'image/svg+xml');
84-
const svgElement = docs.querySelector('svg');
81+
const parser = new DOMParser();
82+
const docs = parser.parseFromString(icon.svg, 'image/svg+xml');
83+
const svgElement = docs.querySelector('svg');
8584

86-
if (svgElement) {
87-
svgElement.id = `icon-${layerCode}`;
88-
svgElement.style.zIndex = layer.priority;
89-
svgElement.style.display = 'none';
85+
if (svgElement) {
86+
svgElement.id = `icon-${layerCode}`;
87+
svgElement.style.zIndex = layer.priority;
88+
svgElement.style.display = 'none';
9089

91-
document.body.appendChild(svgElement);
90+
document.body.appendChild(svgElement);
9291

93-
drawIcon(
94-
`icon-${feature.properties.category3}`,
95-
this.tile,
96-
feature.geom,
97-
this.imageSize,
98-
svgElement.style,
99-
);
100-
}
92+
drawIcon(
93+
`icon-${feature.properties.category3}`,
94+
this.tile,
95+
feature.geom,
96+
this.imageSize,
97+
svgElement.style,
98+
);
10199
}
102100
}
103101
});

0 commit comments

Comments
 (0)