Skip to content

Commit

Permalink
fit bounds only once
Browse files Browse the repository at this point in the history
  • Loading branch information
ckroeger committed Jul 25, 2024
1 parent d1c4cc4 commit e0b5d22
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ L.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", {

if (navigator.geolocation) {
var marker, circle;
var fitBounds = false;
setInterval(() => {
navigator.geolocation.getCurrentPosition(onLocationFound);
}, 2500);
Expand All @@ -23,6 +24,10 @@ if (navigator.geolocation) {
radius: position.coords.accuracy,
});
var featureGroup = L.featureGroup([marker, circle]).addTo(map);
map.fitBounds(featureGroup.getBounds());
if (!fitBounds) {
console.log("fitBounds");
fitBounds = true;
map.fitBounds(featureGroup.getBounds());
}
}
}

0 comments on commit e0b5d22

Please sign in to comment.