From 8a10c50116cd4aeafa639419d5ee7d226a543130 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A4r=20Thernstr=C3=B6m?= Date: Tue, 2 Jul 2024 09:43:26 +0200 Subject: [PATCH] =?UTF-8?q?Tracking=20i=20tooltip-l=C3=A4nk=20och=20l?= =?UTF-8?q?=C3=A4gg=20inte=20till=20expandera-knapp=20p=C3=A5=20fullsk?= =?UTF-8?q?=C3=A4rmssidan?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/js/events-map.js | 68 +++++++++++++++++++++++------------------ 1 file changed, 38 insertions(+), 30 deletions(-) diff --git a/public/js/events-map.js b/public/js/events-map.js index e8100f0a..6fffdad1 100644 --- a/public/js/events-map.js +++ b/public/js/events-map.js @@ -230,31 +230,26 @@ class EventsMap { const markers = []; events.forEach((event) => { - const oneMarker = //.addTo(this.map) - L.marker([event.lat, event.lng], { - icon: getLayerIcon(null, map, "", ""), - crimeEventData: event, - }).bindPopup( - ` -
- -
-
${event.locations}
-

- - ${event.headline} - -

-
${event.time_human} • ${event.type}
-
+ const oneMarker = L.marker([event.lat, event.lng], { + icon: getLayerIcon(null, map, "", ""), + crimeEventData: event, + }).bindPopup( + ` +
+ +
+
${event.locations}
+

+ + ${event.headline} + +

+
${event.time_human} • ${event.type}
- `, - { direction: "bottom", permanent: false } - ); - // .on("click", function (evt) { - // const link = evt.target.options.crimeEventData.permalink + "?utm_source=brottsplatskartan&utm_medium=maplink"; - // window.open(link, "_blank"); - // }); +
+ `, + { direction: "bottom", permanent: false } + ); markers.push(oneMarker); }); @@ -360,8 +355,16 @@ class EventsMap { } }); + /** + * Expand map when locate is activated. + */ this.map.on("locateactivate", () => { - expandMap(this.map); + let isExpanded = map + .getContainer() + .classList.contains("is-expanded"); + if (!isExpanded) { + expandMap(this.map); + } }); /** @@ -401,11 +404,16 @@ class EventsMap { '© OSM', }).addTo(this.map); - L.control - .ExpandButton({ - position: "bottomright", - }) - .addTo(this.map); + /** + * Add expand button, but not if fullscreen, because then it's already expanded. + */ + if (this.options.size !== "fullscreen") { + L.control + .ExpandButton({ + position: "bottomright", + }) + .addTo(this.map); + } window.locateControl = L.control .locate({