mapbox-gl-js icon indicating copy to clipboard operation
mapbox-gl-js copied to clipboard

Malformed GeolocateControl Error

Open spencermize opened this issue 6 months ago • 4 comments

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


spencermize avatar Oct 24 '25 20:10 spencermize

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?

ibesora avatar Nov 05 '25 20:11 ibesora

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.

spencermize avatar Nov 05 '25 20:11 spencermize

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!

ibesora avatar Nov 07 '25 16:11 ibesora

Thanks @ibesora ! I realized I didn't actually answer your question entirely - we use the code field - message isn't used (in our case).

spencermize avatar Nov 07 '25 16:11 spencermize

Is this what we are looking for? -> https://github.com/mapbox/mapbox-gl-js/pull/13597

lucavb avatar Dec 12 '25 08:12 lucavb