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

Auto Zoom cameraForCoordinates is not working

Open nmssalman opened this issue 3 years ago • 5 comments
trafficstars

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 avatar Jun 16 '22 16:06 nmssalman

@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.

ZiZasaurus avatar Jun 21 '22 22:06 ZiZasaurus

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.

jdomagni-iabbb avatar Jul 14 '22 09:07 jdomagni-iabbb

@nmssalman @jdomagni-iabbb thank you for reporting. Can you please verify whether you are experiencing this behavior on our most recent version, v10.7?

ZiZasaurus avatar Jul 30 '22 02:07 ZiZasaurus

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 avatar Jul 31 '22 09:07 jdomagni-iabbb

@jdomagni-iabbb can you please provide a screenshot of the exception that you are receiving?

ZiZasaurus avatar Aug 18 '22 19:08 ZiZasaurus

Closing this ticket but please feel free to reopen if you continue to experience this behavior.

ZiZasaurus avatar Nov 01 '22 12:11 ZiZasaurus