Malformed GeolocateControl Error
mapbox-gl-js version
v3.15.0 and v3.16.0
Browser and version
Chrome 141
Expected behavior
In 3.14.0, the geolocate error shape is this:
{
PERMISSION_DENIED: 1
POSITION_UNAVAILABLE: 2
TIMEOUT:3
code: 1
message:"User denied Geolocation"
target: GeolocateControl {options: {…}, _onSuccess: ƒ, _onError: ƒ, _onZoom: ƒ, _finish: ƒ, …}
type: "error"
}
and starting in 3.15/16, it changed to this:
{
target: GeolocateControl {options: {…}, _onSuccess: ƒ, _onError: ƒ, _onZoom: ƒ, _finish: ƒ, …}
type: "error"
}
I believe the error in 3.14 is the correct one, and 3.15/16 are actually broken.
Actual behavior
No response
Link to the demonstration
No response
Steps to trigger the unexpected behavior
No response
Relevant log output
Hi @spencermize thanks for opening the issue.
Can you provide more information about your use case? Do you use/need the code and message fields?
Yes - we were using those fields to provide better messaging to users on why they might have had a geolocation error. Generally, our users have permissions errors (they didn't allow access to geolocation somewhere along the line), and so popping a generic error "Sorry, something went wrong" wasn't nearly as helpful as "Check your permissions".
If there's another way to access this information, I'm happy to do so, but removing those fields was a breaking change in our application.
removing those fields was a breaking change in our application
I'm sorry to hear that, I'll work to reinstate those fields. Thanks for the report!
Thanks @ibesora ! I realized I didn't actually answer your question entirely - we use the code field - message isn't used (in our case).
Is this what we are looking for? -> https://github.com/mapbox/mapbox-gl-js/pull/13597