Skip to content

Commit c0990b4

Browse files
committed
Change zIndex of location dot based on current zoom level
1 parent 5feab8c commit c0990b4

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

scripts/map.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,17 @@ function getLocation(zoom = true, followLocationOverride) {
414414
let feature = currentLocationLayer.getSource().getFeatures()[0];
415415
feature.setStyle(iconStyle);
416416
feature.getGeometry().setCoordinates(ol.proj.fromLonLat(pos));
417+
418+
// Update the zIndex based on zoom level
419+
const currentZoom = map.getView().getZoom();
420+
const animating = map.getView().getAnimating();
421+
if (currentZoom < 13.5 && !animating) {
422+
currentLocationLayer.setZIndex(99);
423+
} else {
424+
currentLocationLayer.setZIndex(1);
425+
}
426+
console.log("currentZoom: " + currentZoom);
427+
console.log("currentLocationLayer zIndex: " + currentLocationLayer.getZIndex());
417428
}
418429

419430
if (followLocation && !(rotationMode === "compass" || rotationMode === "route")) {

0 commit comments

Comments
 (0)