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
{{ message }}
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
Method for getting map camera settings from polyline, bearing, bounds and insets #9809
This method should accept a polyline, a bearing, a bounding rectangle in pixels and an object defining padding in pixels on all sides. It should then return a center coordinate and a zoom level appropriate for showing the given polyline in the given bounds at the given bearing.
This is basically what's already happening in fitBounds. The only difference is that this returns the calculated values so that the developer can handle the fitting of the bounds using any transition they want.
This sounds a lot like the existing -[MGLMapView cameraFittingCoordinateBounds:edgePadding:] method, except that it takes a polyline instead of a coordinate bounds and allows the rotation to be specified. There's an mbgl::Map::cameraForLatLngs() method that does something similar. It could be exposed as -cameraFittingShape:edgePadding: or -cameraForShowingAnnotation:, playing off existing method names.
Would it be desirable to automatically choose an optimal rotation (within some threshold, to avoid overrotation)? I recall that Bing's API even goes so far as to choose an optimal pitch when the map is tilted.
except that it takes a polyline instead of a coordinate bounds
This, I believe, is the tricky part. The viewport of the device in heading-up navigation is at an arbitrary bearing. You can't simply take the northeast and southwest coordinates and make a bounding box that will work. There needs to be some translation going on in order to calculate the proper zoom level.
Would it be desirable to automatically choose an optimal rotation (within some threshold, to avoid overrotation)? I recall that Bing's API even goes so far as to choose an optimal pitch when the map is tilted.
Could you explain the overrotation problem. As for the pitch, It would be really great to have that.
The viewport of the device in heading-up navigation is at an arbitrary bearing. You can't simply take the northeast and southwest coordinates and make a bounding box that will work. There needs to be some translation going on in order to calculate the proper zoom level.
mbgl::Map::cameraForLatLngs() correctly fits the polygon given the map’s current camera heading.
Activity
1ec5 commentedon Aug 21, 2017
This sounds a lot like the existing
-[MGLMapView cameraFittingCoordinateBounds:edgePadding:]method, except that it takes a polyline instead of a coordinate bounds and allows the rotation to be specified. There's anmbgl::Map::cameraForLatLngs()method that does something similar. It could be exposed as-cameraFittingShape:edgePadding:or-cameraForShowingAnnotation:, playing off existing method names.Would it be desirable to automatically choose an optimal rotation (within some threshold, to avoid overrotation)? I recall that Bing's API even goes so far as to choose an optimal pitch when the map is tilted.
d-prukop commentedon Aug 21, 2017
This, I believe, is the tricky part. The viewport of the device in heading-up navigation is at an arbitrary bearing. You can't simply take the northeast and southwest coordinates and make a bounding box that will work. There needs to be some translation going on in order to calculate the proper zoom level.
d-prukop commentedon Aug 21, 2017
Could you explain the overrotation problem. As for the pitch, It would be really great to have that.
1ec5 commentedon Aug 22, 2017
mbgl::Map::cameraForLatLngs()correctly fits the polygon given the map’s current camera heading.1ec5 commentedon Aug 22, 2017
I just meant that we may want to avoid rotating nearly 180° from the current camera just for something slightly more optimal than the current camera.
d-prukop commentedon Aug 22, 2017
This is great news.
zugaldia commentedon Aug 22, 2017
cc: @cammace @danesfeder for visibility on the Android side.