Skip to content

Commit

Permalink
fix hash positioning on community map
Browse files Browse the repository at this point in the history
  • Loading branch information
secondl1ght committed Jun 3, 2024
1 parent d23c227 commit 5de45f9
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions src/routes/communities/map/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,20 @@
}
}
// use url hash if present
else if (location.hash) {
try {
const coords = location.hash.split('/');
map.setView([Number(coords[1]), Number(coords[2])], Number(coords[0].slice(1)));
} catch (error) {
map.setView([0, 0], 3);
errToast(
'Could not set map view to provided coordinates, please try again or contact BTC Map.'
);
console.log(error);
}
}
// set view to all communities as default
else if (communities.length) {
try {
Expand All @@ -197,6 +211,8 @@
);
console.log(error);
}
} else {
map.setView([0, 0], 3);
}
mapLoading = 100;
Expand Down Expand Up @@ -227,22 +243,6 @@
// add map and tiles
map = leaflet.map(mapElement);
// use url hash if present
if (location.hash) {
try {
const coords = location.hash.split('/');
map.setView([Number(coords[1]), Number(coords[2])], Number(coords[0].slice(1)));
} catch (error) {
map.setView([0, 0], 3);
errToast(
'Could not set map view to provided coordinates, please try again or contact BTC Map.'
);
console.log(error);
}
} else {
map.setView([0, 0], 3);
}
// add tiles and basemaps
const baseMaps = layers(leaflet, map);
Expand Down

0 comments on commit 5de45f9

Please sign in to comment.