mapbox-maps-android
mapbox-maps-android copied to clipboard
Auto Zoom cameraForCoordinates is not working
Environment
- Android OS version: 8-12
- Devices affected: All
- Maps SDK Version:
implementation 'com.mapbox.maps:android:10.3.0' implementation "com.mapbox.navigation:android:2.3.0"
With the following Locations. first location is zooming properly. but the 2nd location (which is very close locations). these are not working to auto zoom.
1st Location: {"type":"Point","coordinates":[-113.58171,53.540624]} | {"type":"Point","coordinates":[-113.4279364,53.3426333]} 2nd Location (Zoom Not working) : {"type":"Point","coordinates":[-113.509833,53.4740635]} | {"type":"Point","coordinates":[-113.489816,53.4519209]}
val camOpt = mapView.getMapboxMap().cameraForCoordinates(listOf(ORIGIN_POINT, DESTINATION_POINT), EdgeInsets(0.0, 0.0, bottomSheetHeight * 1000 * 1.6, 0.0), null, null)
mapView.getMapboxMap().setCamera(camOpt)
@nmssalman what about the autozoom is not working? Do you have a recording or screenshot of how you expect it to look? When I run both sets of coordinates through, setCamera appears to behave as expected.
I have the same issue. Sometimes it fits as it should be sometimes it get zoom level 3, thought center coordinates are right. Only zoom is tricky.
@nmssalman @jdomagni-iabbb thank you for reporting. Can you please verify whether you are experiencing this behavior on our most recent version, v10.7?
After upgrading to 10.7, i start getting exception when calling cameraForCoordinates:"The exception that is thrown when an application attempts to perform a map operation on a worker thread". Run code on Main and it started working, but zoom is still wrong. My previous hack stopped working with 10.7 as well. Here is what i used, i was not able to find out zoom issue with this code on 10.6.1:
GlobalScope.launch {
val pointList = pointList.filter { it.opacity == 1.0 }
mbxMap.fitBounds(pointList)
delay(200) // TODO Find better way, so far it just only solution i found
if (mbxMap.cameraState.zoom <= 3) {
mbxMap.fitBounds(pointList)
}
}
fiBounds calls: var camera = cameraForCoordinates( points.map { Point.fromLngLat(it.coordinate.lon, it.coordinate.lat) }, EdgeInsets(60.0, 60.0, 60.0, 60.0) ) setCamera(camera)
@jdomagni-iabbb can you please provide a screenshot of the exception that you are receiving?
Closing this ticket but please feel free to reopen if you continue to experience this behavior.