-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Method to convert arbitrary CameraOptions to LatLngBounds #8499
Comments
|
(Side note: I made a major typo above. I meant to suggest
I think it’d be acceptable, as long as
We have |
@1ec5 @jfirebaugh I've implemented a naïve approach in #8510 - notice though that even this solution does not guarantee precise conversions between |
#8510 landed, so now it’s up to the platforms to use it. For iOS and macOS, I think we’d want to expose this functionality as |
This issue has been automatically detected as stale because it has not had recent activity and will be archived. Thank you for your contributions. |
This issue has been automatically detected as stale because it has not had recent activity and will be archived. Thank you for your contributions. |
mbgl::Map
should expose alatLngBoundsForCamera()
method that takes anmbgl::CameraOptions
and returns thembgl::LatLngBounds
that would be visible if the camera options were applied to the map. This method wouldn’t jump to a new location; it would only calculate what the extents would be.The iOS and macOS SDKs have an
-[MGLMapViewDelegate mapView:shouldChangeFromCamera:toCamera:]
method that makes it easy to constrain the map’s center to a particular area, but it isn’t easy to constrain the map so that no disallowed area is ever visible. mapbox/ios-sdk-examples#65 illustrates the problem: we’d have to perform a set-and-revert dance just to determine whether the viewable area lies beyond the designated area. WithlatLngBoundsForCamera()
and the corresponding SDK method, the delegate would be able to essentially do a “dry run” of the camera change associated with each gesture and use the resulting bounds to make this determination.latLngBoundsForCamera()
would essentially be the reverse operation ofcameraForLatLngBounds()
, so it may be desirable to ensure round-trippability. On the other hand, given #2259, I’m not sure we can ensure that at the moment./cc @jfirebaugh @brunoabinader @fabian-guerra @tobrun
The text was updated successfully, but these errors were encountered: