You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The GeolocateControl doesn't expose events necessary to act on all of its states. trackuserlocationstart and trackuserlocationend aren't enough to detect some user actions. For instance, it's impossible to know if the user toggled off tracking.
To achieve this I currently have to use a MutationObserver on the .mapboxgl-ctrl-geolocate watching for classList changes.
Design
Fire a new statechange event on every _watchState change and pass along its value.
Implementation
Replace all this._watchState = ... with:
_setState(state)=>{if(this._watchState!==state){this._watchState=statethis.fire('statechange',state)// ... conditions logic to fire trackuserlocationstart and trackuserlocationend// bonus?this._updateUI(state)// centralize the different classList updates spread in _onSucces, _onError, _onClick...}}
The text was updated successfully, but these errors were encountered:
Motivation
Discussion started here: #4479 (comment)
The
GeolocateControl
doesn't expose events necessary to act on all of its states.trackuserlocationstart
andtrackuserlocationend
aren't enough to detect some user actions. For instance, it's impossible to know if the user toggled off tracking.To achieve this I currently have to use a
MutationObserver
on the.mapboxgl-ctrl-geolocate
watching forclassList
changes.Design
Fire a new
statechange
event on every_watchState
change and pass along its value.Implementation
Replace all
this._watchState = ...
with:The text was updated successfully, but these errors were encountered: