Skip to content

Commit

Permalink
Expandera kartan när nära-mig-knappen klickas på
Browse files Browse the repository at this point in the history
  • Loading branch information
bonny committed Jul 1, 2024
1 parent 4a0533b commit 9753bd3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
5 changes: 3 additions & 2 deletions public/css/events-map.css
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,11 @@ body.map-is-expanded .SiteHeader {
display: block;
}

.EventsMap .leaflet-marker-icon,
/* .EventsMap .leaflet-marker-icon,
.EventsMap .leaflet-marker-shadow {
/* animation: fadein 0.75s; */
animation: fadein 0.75s;
}
*/

.EventsMap .leaflet-popup {
max-width: 80vw;
Expand Down
26 changes: 14 additions & 12 deletions public/js/events-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,14 +157,14 @@ function setLayerIcon(layer, map, classToAdd = "", innerText = "") {
function getLayerIcon(layer, map, classToAdd = "", innerText = "") {
const zoomLevel = map.getZoom();

let markerType; // normal | cluster | spiderfied
if (layer instanceof L.MarkerCluster) {
markerType = "cluster";
} else if (layer instanceof L.Marker) {
markerType = "normal";
} else {
console.log("Unknown marker type", layer);
}
// let markerType; // normal | cluster | spiderfied
// if (layer instanceof L.MarkerCluster) {
// markerType = "cluster";
// } else if (layer instanceof L.Marker) {
// markerType = "normal";
// } else {
// console.log("Unknown marker type", layer);
// }
// console.log("markerType", markerType);

// Brottstyp utan mellanslag mellan ord (så max 1 mellanslag efter varandra).
Expand Down Expand Up @@ -348,11 +348,14 @@ class EventsMap {
}
});

this.map.on("locateactivate", () => {
expandMap(this.map);
});

/**
* Set icons depending on zoom level.
*/
this.map.on("zoomend", () => {
console.log("on zoomend");
// For each marker, set the icon.
this.map.eachLayer(function (layer) {
// Ensure to act only on markers with crime events data.
Expand Down Expand Up @@ -386,14 +389,13 @@ class EventsMap {
'&copy; <a href="https://www.openstreetmap.org/copyright">OSM</a>',
}).addTo(this.map);

let x = L.control
L.control
.ExpandButton({
position: "bottomright",
})
.addTo(this.map);
window.expandButtonControl = x;

L.control
window.locateControl = L.control
.locate({
locateOptions: {
maxZoom: 11,
Expand Down

0 comments on commit 9753bd3

Please sign in to comment.