Skip to content

Commit

Permalink
fix: Newest open marker on top and above clusters (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
purplebugs authored Nov 6, 2024
1 parent 74c8ed7 commit 239a86d
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/alpaca-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,8 @@ export default class AlpacaMap extends LitElement {
this.map.mapTypes.set("styled_map", styledMapType);
this.map.setMapTypeId("styled_map");

let zIndexMax = Number(10000000);

const markers = this.farms.map((farm) => {
const content = document.createElement("alpaca-map-marker");
content.setAttribute("linkToFarmPage", this.linkToFarmPage);
Expand Down Expand Up @@ -333,16 +335,20 @@ export default class AlpacaMap extends LitElement {
content,
position: farm.location.lat_lng,
title: farm?.name,
zIndex: zIndexMax,
});

// markers can only be keyboard focusable when they have click listeners

// toggle marker summary/details when marker is clicked
marker.addListener("click", () => {
const highlighted = marker.content.getAttribute("highlight");
zIndexMax = Number(zIndexMax + 1);

if (highlighted === "true") {
marker.content.setAttribute("highlight", "false");
} else {
marker.zIndex = Number(zIndexMax);
marker.content.setAttribute("highlight", "true");
}
});
Expand Down

0 comments on commit 239a86d

Please sign in to comment.