Skip to content

Commit aa6ceff

Browse files
committed
improve sensitive area popup
1 parent c474852 commit aa6ceff

File tree

2 files changed

+34
-11
lines changed

2 files changed

+34
-11
lines changed

src/app/components/map-trek-viz/map-trek-viz.component.ts

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -760,19 +760,29 @@ export class MapTrekVizComponent implements OnDestroy, OnChanges {
760760
});
761761

762762
this.map.on('click', 'sensitive-areas', (e: MapLayerMouseEvent) => {
763-
if (e.features && e.features.length > 0) {
764-
const feature = e.features[0];
765-
const name = feature.properties!['name'];
763+
const features: any = this.map
764+
.queryRenderedFeatures(e.point)
765+
.filter((feature: any) => {
766+
return feature.source !== 'sensitive-areas';
767+
});
768+
if (!features || !(features.length > 0)) {
769+
if (e.features && e.features.length > 0) {
770+
const feature = e.features[0];
771+
const name = feature.properties!['name'];
772+
773+
if (name) {
774+
if (this.sensitiveAreaPopup) {
775+
this.sensitiveAreaPopup.remove();
776+
}
766777

767-
if (name) {
768-
if (this.sensitiveAreaPopup) {
769-
this.sensitiveAreaPopup.remove();
778+
this.sensitiveAreaPopup = new Popup({
779+
closeOnClick: false,
780+
className: 'sensitive-area-popup'
781+
})
782+
.setLngLat(e.lngLat)
783+
.setHTML(`<b>${name}</b>`)
784+
.addTo(this.map);
770785
}
771-
772-
this.sensitiveAreaPopup = new Popup({ closeOnClick: false })
773-
.setLngLat(e.lngLat)
774-
.setHTML(`<b>${name}</b>`)
775-
.addTo(this.map);
776786
}
777787
}
778788
});
@@ -1083,6 +1093,9 @@ export class MapTrekVizComponent implements OnDestroy, OnChanges {
10831093
checked ? 'visible' : 'none'
10841094
)
10851095
);
1096+
if (layersName === 'sensitive-areas' && this.sensitiveAreaPopup) {
1097+
this.sensitiveAreaPopup.remove();
1098+
}
10861099
}
10871100

10881101
public handleClustersInteraction(): void {

src/global.scss

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,3 +231,13 @@ app-search {
231231
object-fit: contain;
232232
height: auto;
233233
}
234+
235+
.sensitive-area-popup {
236+
.maplibregl-popup-content {
237+
padding-top: 32px;
238+
}
239+
.maplibregl-popup-close-button {
240+
font-size: 32px;
241+
padding-right: 0px 6px 0px 6px;
242+
}
243+
}

0 commit comments

Comments
 (0)