mapbox-maps-android icon indicating copy to clipboard operation
mapbox-maps-android copied to clipboard

How to ease camera to polygon bounds?

Open djavid opened this issue 4 years ago • 4 comments

Before v10 I can do it

`LatLngBounds.Builder builder = new LatLngBounds.Builder(); .include(aaaaaaaaaa) .include(bbbbbbbb) .include(cccccccccc)

mapBoxMapView.getMapBoxMap().easeCamera(CameraUpdateFactory.newLatLngBounds( builder.build(), paddingStart, paddingTop, paddingEnd, paddingBottom));`

Now how to do ? Thanks

Originally posted by @xiaxiayige in https://github.com/mapbox/mapbox-maps-android/issues/715#issuecomment-939280584

djavid avatar Oct 25 '21 13:10 djavid

+1. I have exactly the same question. I don't want to restrict the camera to these bounds, I just want to have the camera positioned to fit the polygon on the screen, with the appropriate zoom level calculated automatically.

samcrawford avatar Oct 25 '21 20:10 samcrawford

I think I've found the answer: https://docs.mapbox.com/android/maps/api/10.0.0-rc.7/-mapbox%20-maps%20-android/com.mapbox.maps/-mapbox-map/#com.mapbox.maps/MapboxMap/cameraForCoordinateBounds/#com.mapbox.maps.CoordinateBounds#com.mapbox.maps.EdgeInsets#kotlin.Double?#kotlin.Double?/PointingToDeclaration/

This works for me, but I'm then hitting the issue described in https://github.com/mapbox/mapbox-maps-android/issues/611.

samcrawford avatar Oct 25 '21 20:10 samcrawford

@djavid @samcrawford Thank you for reaching out. I have reproduced this behavior with the latest version of our SDK. At the moment, we are awaiting a fix from another team which will resolve this issue.

ZiZasaurus avatar Nov 03 '21 16:11 ZiZasaurus

hey, are there any updates? we try to use mapboxMap.setCamera(mapboxMap.cameraForGeometry(polygon, EdgeInsets(1.0, 1.0, 1.0, 1.0))) and it doesn't seem to work, points zoomed far out of the polygon's bounds. Same for easeTo

anathefish avatar Nov 29 '23 12:11 anathefish