Skip to content

Commit

Permalink
if map object not created yet, do not do anything
Browse files Browse the repository at this point in the history
  • Loading branch information
kylerchin committed Jul 19, 2024
1 parent 170af2b commit cc10ab8
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/routes/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -969,7 +969,9 @@
if (localStorage.getItem('cachegeolocation')) {
const [long, lat] = localStorage.getItem('cachegeolocation')!.split(',');
centerinit = [parseFloat(long), parseFloat(lat)];
mapglobal.setCenter(centerinit);
if (mapglobal) {
mapglobal.setCenter(centerinit);
}
} else {
try {
/**
Expand All @@ -988,7 +990,9 @@
// set the center of the map to the user's location
// in case the map is already initialized (rare), set the center to the user's location
mapglobal.setCenter(centerinit);
if (mapglobal) {
mapglobal.setCenter(centerinit);
}
// store the user's location in localStorage, as we do with regular browser provided geolocation
localStorage.setItem('cachegeolocation', `${geo_api_response.geo_resp.longitude},${geo_api_response.geo_resp.latitude}`);
Expand Down

0 comments on commit cc10ab8

Please sign in to comment.