It seems as though it is not possible to Show the user's location on the map using Mapbox-gl-js. There are examples in the documentation that discuss doing this with Mapbox IOS/Android however, nothing with MapboxGl JS.
What I've Tried:
I am currently able to add a Geolocate Control that does this feature with a button:
map.addControl(
new mapboxgl.GeolocateControl({
positionOptions: {enableHighAccuracy: true},
trackUserLocation: true,
showUserHeading: true,
})
);
However, this is not live tracking of the user, as shown in the linked example above.
Is anoyone able to help?
You're doing it right - GeolocateControl will track the user on the map as a blue pulsing dot. If it's not doing that for you, something is going wrong - perhaps you haven't granted permissions, or perhaps you're not running in a context where the browser can get the user's location. For instance, you need to be serving the page on https, not http.