Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(poi-layer): feature selectable below min zoom level #880

Merged
merged 1 commit into from
Jan 13, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 26 additions & 28 deletions app/component/map/tile-layer/PoiVectorTileLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,18 @@ export default class PoiVectorTileLayer {
const layerFeature = layerData.feature(index);

[[layerFeature.geom]] = layerFeature.loadGeometry();
const feature = pick(layerFeature, ['geom', 'properties']);

if (
!PoiVectorTileLayer.visibleCategories[
feature.properties.category3
]
) {
return null;
}
return feature;
return pick(layerFeature, ['geom', 'properties']);
})
.filter(Boolean);
.filter(feature => {
const poiLayer = getLayerByCode(
feature.properties.category3,
this.config,
);
return (
PoiVectorTileLayer.visibleCategories[poiLayer.code] &&
this.tile.coords.z >= poiLayer.properties.layer.min_zoom
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

visibility z level may differ by category, what should be taken into account here, no?

Copy link
Collaborator Author

@andreashelms andreashelms Jan 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

poiLayer is a specific poi layer selected by category code. So min_zoom is already applied individually for each category.

);
});

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

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

if (svgElement) {
svgElement.id = `icon-${layerCode}`;
svgElement.style.zIndex = layer.priority;
svgElement.style.display = 'none';
if (svgElement) {
svgElement.id = `icon-${layerCode}`;
svgElement.style.zIndex = layer.priority;
svgElement.style.display = 'none';

document.body.appendChild(svgElement);
document.body.appendChild(svgElement);

drawIcon(
`icon-${feature.properties.category3}`,
this.tile,
feature.geom,
this.imageSize,
svgElement.style,
);
}
drawIcon(
`icon-${feature.properties.category3}`,
this.tile,
feature.geom,
this.imageSize,
svgElement.style,
);
}
}
});
Expand Down
Loading