Mapbox camera goes to totally different location

Issue

I am using mapbox in Android with kotlin.
I want to set the map camera location but when i set it, it goes to a totally different place.
I tested in debugging mode and the coordinates are correct.
For example I am in Portugal and it goes to Madagascar.

map.flyTo( cameraOptions {

    center( Point.fromLngLat( location.latitude, location.longitude) )
},
MapAnimationOptions.mapAnimationOptions {
    duration(7000)
})

What am I missing?

Solution

The API is LngLat and your parameters are latitude, longitude.

From MapBox:

"These coordinates use longitude, latitude coordinate order (as
opposed to latitude, longitude) to match the GeoJSON specification,
which is equivalent to the OGC:CRS84 coordinate reference system."

So try:

center( Point.fromLngLat( location.longitude, location.latitude) )

Answered By – Gardener

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published