Skip to content

Open Infrastructure Map, a view of infrastructure data in OpenStreetMap

Tidy up using new on(layers) feature

Russ Garrett1c94aaa190d8
diff --git a/web/src/infopopup.ts b/web/src/infopopup.ts
index 95e0bb4..bb920fb 100644
--- a/web/src/infopopup.ts
+++ b/web/src/infopopup.ts
@@ -78,24 +78,23 @@ class InfoPopup {
add(map: maplibregl.Map) {
this._map = map
- for (const layer of this.layers) {
- map.on('click', layer, (e) => {
- if (this._map.getZoom() > this.min_zoom) {
- this.popup(e)
- }
- })
+ map.on('click', this.layers, (e) => {
+ if (this._map.getZoom() > this.min_zoom) {
+ this.popup(e)
+ }
+ })
- map.on('mouseenter', layer, () => {
- if (this._map.getZoom() > this.min_zoom) {
- map.getCanvas().style.cursor = 'pointer'
- }
- })
- map.on('mouseleave', layer, () => {
- if (this._map.getZoom() > this.min_zoom) {
- map.getCanvas().style.cursor = ''
- }
- })
- }
+ map.on('mouseenter', this.layers, () => {
+ if (this._map.getZoom() > this.min_zoom) {
+ map.getCanvas().style.cursor = 'pointer'
+ }
+ })
+
+ map.on('mouseleave', this.layers, () => {
+ if (this._map.getZoom() > this.min_zoom) {
+ map.getCanvas().style.cursor = ''
+ }
+ })
}
osmLink(id: number, is_node: boolean) {