[Bug]: Android: onCameraChanged fires with [0,0] on launch
Nobody has claimed this yet.
- Dominant language
- Kotlin
- Stars
- 2.9k
- Forks
- 947
- Avg merge
- 6d 37m
- Merged PRs (30d)
- 1
Description
Mapbox Version
11.20.1
React Native Version
0.83.6
Platform
Android
@rnmapbox/maps version
10.3.1
Standalone component to reproduce
import React from "react";
import { View } from "react-native";
import Mapbox, { Camera, MapState, MapView } from "@rnmapbox/maps";
const onCameraChanged = (mapState) => {
const center = mapState?.properties?.center;
if (!Array.isArray(center)) return;
const [lng, lat] = center;
if (lng !== 0 && lat !== 0) return;
console.log(`COORDS ->> lng: ${lng} lat: ${lat}`);
};
const MapReproScreen = () => (
<View style={{ flex: 1 }}>
<MapView
style={{ flex: 1 }}
styleURL={Mapbox.StyleURL.Satellite}
onCameraChanged={onCameraChanged}>
<Camera
defaultSettings={{
centerCoordinate: [-93.265, 44.9778],
zoomLevel: 6,
}}
/>
</MapView>
</View>
);
export default MapReproScreen;
Observed behavior and steps to reproduce
On Android only, onCameraChanged fires twice on app launch with center=[0,0], even though the camera is initialized with a different defaultSettings.centerCoordinate.
Observed logs:
COORDS ->> lng: 0 lat: 0
COORDS ->> lng: 0 lat: 0
Expected behavior
Expected: onCameraChanged should not emit [0,0] during initialization when the configured initial camera center is [-93.265, 44.9778].
Question: should consumers gate onCameraChanged behind a specific map/camera readiness event, or is this a bug?
Notes / preliminary analysis
No response
Additional links and references
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue names no source files or tests. Start by running the supplied React Native reproduction on Android and tracing the initialization path for onCameraChanged against Camera defaultSettings. Done means initialization no longer emits [0,0], or the documented readiness behavior clearly explains how consumers should avoid those events.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, javascript, react-native
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100