Home > Blockchain >  Mapbox camera goes to totally different location
Mapbox camera goes to totally different location

Time:06-11

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?

CodePudding user response:

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) )
  • Related