[Bug]: defaultSettings centerCoordinates not applying
Mapbox Implementation
Mapbox
Mapbox Version
11.6.0
React Native Version
0.76.7
Platform
Android
@rnmapbox/maps version
10.1.37
Standalone component to reproduce
import React from 'react';
import {
MapView,
Camera,
} from '@rnmapbox/maps';
const MapExample=()=>{
return (
<MapView>
<Camera
defaultSettings={{
centerCoordinate: [-122.084, 37.4219983],
zoomLevel: 14,
}}
/>
</MapView>
)
}
Observed behavior and steps to reproduce
when opening the app for the first time provided the [-122.084, 37.4219983] coordinates initial camera position is in africa, if then updating the code
first time the app is opened:
when i reopen the app:
Expected behavior
camera position should be in the same positions as it is when the app is reopened
Notes / preliminary analysis
No response
Additional links and references
No response
Facing the same issue
I successfully reproduced this bug. The map doesn’t center randomly.
https://github.com/user-attachments/assets/16a2cc1a-499c-4ece-9f9a-181cfa17e490
After further analysis, I found the cause: during the first flyTo method call, Mapbox doesn’t center the map on the latitude. I’m not sure why it behaves this way.
My only idea for a fix is to call setInitialCamera twice (if the center doesn’t update correctly), but that feels like an inefficient workaround. @mfazekas — any hints on where to look for a proper solution?
Related issue: https://github.com/rnmapbox/maps/issues/3449
Could reproduce on Android, ~seems to be an upstream issue.~ Actually this is a race between defaultStop and initial stop. In this case the initial stop was empty. But in case it applied just after default stop