Skip to content

Commit

Permalink
feat: add Mapbox GeolocateControl
Browse files Browse the repository at this point in the history
  • Loading branch information
th0rgall committed Nov 1, 2023
1 parent f6586c8 commit 25cd22b
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/lib/components/Map/Map.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,31 @@
map.resize();
});
const geolocationControl = new maplibregl.GeolocateControl({
trackUserLocation: true,
fitBoundsOptions: {
// Member: zoom in more
...($user?.superfan
? {
// Mapbox default
maxZoom: 15
}
: {
maxZoom: nonMemberMaxZoom
})
},
// Member: ask the device for a higher-accuracy location
positionOptions: {
...($user?.superfan
? {
enableHighAccuracy: true
}
: {})
}
});
map.addControl(geolocationControl);
map.on('load', () => {
loaded = true;
});
Expand Down

0 comments on commit 25cd22b

Please sign in to comment.