mapbox-maps-android
mapbox-maps-android copied to clipboard
Make possible to zoom to a FeatureCollection or a list of Points
New Feature
Add on CameraBoundsOptions.Builder the possibility to zoom to bounds made by a FeatureCollection and/or by multiple Points. (If this feature already exists please make it clear on documentation)
Why
On v9 sdk it was possible to zoom to a LatLngBound builded by a list of LatLng, now in v10 sdk is impossible to do the same with Point and CoordinateBounds. Now if i want to display a route on map and zoom to it i don't know how to do it, so I think this is a feature that almost everyone needs.
@gdgcentrica you can use the following methods to set the camera to a specific geometry or coordinates:
- cameraForGeometry if you'd like to center the camera on a particular shape
- cameraForCoordinateBounds if you'd like to specify coordinate bounds you with the camera to stay inside
- cameraForCoordinates will allow you to center the camera over a series of coordinates.
@gdgcentrica you can use the following methods to set the camera to a specific geometry or coordinates:
- cameraForGeometry if you'd like to center the camera on a particular shape
- cameraForCoordinateBounds if you'd like to specify coordinate bounds you with the camera to stay inside
- cameraForCoordinates will allow you to center the camera over a series of coordinates.
cameraForCoordinates
only takes a list of Points
though. Would be great to have List<Geometry>
@VincentJoshuaET if you use cameraForGeometry you can pass a line string or any geometry instead of a list of points.
@ZiZasaurus thank you very much, it was exactly what i was searching for.
I think that this feature is important and needs to be highlighted here: Guides and/or here: Examples
How to get CoordinateBounds, I want to get its east, west, north and south?
After I use this I still need to zoom the correct amount. How I can zoom in the right amount to include two points (origin and destination) on android SDK V10?
At the moment I'm doing this:
val origin = Point.fromLngLat(lonOrigin, latOrigin)
val destination = Point.fromLngLat(lonDestination, latDestination)
val cameraOptions = binding.map.getMapboxMap().cameraForCoordinates(coordinates = listOf<Point>(origin, destination))
map.getMapboxMap().easeTo(cameraOptions)
It centers correctly but does not zoom in.