I am using react-native-maps
(version 1.20.1) in my React Native project, and I am facing an issue where markers and the user location (blue dot) are not displaying consistently.
The first time I load the app (after clearing the Expo cache with npx expo start -c
), everything works fine, but on subsequent reloads or when I navigate back to the map screen, the markers and user location disappear. Occasionally, they appear randomly but are not consistent.
At first i tried to debug using the logs
useEffect(() => {
if (markers) {
console.log("Markers loaded ", markers);
}
}, [markers]);
in the terminal is said the Markers Loaded and with markers info but nothing was shown in the Map Page.
Then I thought the issue was with the AsyncStorage
, so thought to clear it.
const clearStorage = async () => {
try {
await AsyncStorage.clear();
console.log('AsyncStorage cleared!');
} catch (error) {
console.error('Failed to clear AsyncStorage:', error);
}
};
// Clear AsyncStorage when the app loads
useEffect(() => {
clearStorage();
}, []);
still did not work as expected.
Ajay sb is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.