Add geolocate control to the map
Lets the user center the map on their current location, with an accuracy circle and continuous tracking.
This commit is contained in:
1 parent
d813dd0b20
commit
008e034932
1 file changed
+9
@@ -1,6 +1,7 @@
|
||||
import {
|
||||
Map as MaplibreMap,
|
||||
NavigationControl,
|
||||
GeolocateControl,
|
||||
addProtocol,
|
||||
} from "/vendor/maplibre-gl/maplibre-gl.mjs";
|
||||
import { RadarControl } from "/js/radar.js";
|
||||
@@ -70,6 +71,14 @@ const map = new MaplibreMap({
|
||||
});
|
||||
|
||||
map.addControl(new NavigationControl(), "top-right");
|
||||
map.addControl(
|
||||
new GeolocateControl({
|
||||
positionOptions: { enableHighAccuracy: true },
|
||||
trackUserLocation: true,
|
||||
showAccuracyCircle: true,
|
||||
}),
|
||||
"top-right",
|
||||
);
|
||||
map.addControl(new RadarControl(map), "top-right");
|
||||
|
||||
const layerToggle = new LayerToggleControl(applyStyle);
|
||||
|
||||
Reference in new issue
Block a user