Check map maxBounds in Geolocate control - #8756
Conversation
|
This won't entirely fix #4872, since the underlying issue there is requesting a If we decide in #4872 to require the API user to make their own check, then in my opinion this proposed solution is the way to go. We make that check first internally in GeolocateControl, and then only flyTo if it's valid, and then emit an error back to the API user so they can decide what to do (like show an alert), exactly how you've done this PR. In lieu of a decision on #4872, I think it's good to implement this PR even if just for the time being (although based on my comment at #4872 (comment), I do think this is probably the right approach). |
|
cc @ryanhamley I'm happy with this change, are we good to merge or should I wait for someone from Mapbox to have a chance to review? |
|
Looks good to me! Thanks @MoradiDavijani and @andrewharvey |
Launch Checklist
Changes:
The GeolocateControl with a
maxBoundsset on the map when a user is located outside of themaxBounds, keeps trying to move the camera outside of themaxBoundsand causes a bad experience for users. In this PR, I checked mapmaxBoundson geolocate success callback and if the located position is out ofmaxBounds, remove location dot marker, update controlclassList, emit an event calledoutofmaxboundsand return to avoid camera update.Related issue: #4872
@mapbox/studioand/or@mapbox/maps-designif this PR includes style spec changes@mapbox/gl-nativeif this PR includes shader changes or needs a native port