-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MapView addressForCoordinate method is throwing error as "Cannot read properties of undefined(reading apply)" #3955
Comments
@mechazod Any ideas? |
@sarulathadurai, please use |
@mechazod same error is thrown |
@sarulathadurai Have you solved this problem? I have the same problem now |
@mechazod Have you solved this problem? I have the same problem now |
#3911 (comment) isn't helpful for me either. The Only It's all in
|
@sarulathadurai, please reopen this issue, so the issue is visible in the Similarly, #3775 #3850 #3854 #3911 should stay open as well. |
No not yet |
Nothing to do with this issue, but a workaround solution could be using a reverse geolocation api. import env from "../env.json" // your private api keys / tokens
export default async function (coords) {
let { latitude, longitude } = coords;
let resp = await fetch(`https://api.opencagedata.com/geocode/v1/json?q=${latitude}+${longitude}&key=${env.geolocationServiceAPIKey}`)
let data = await resp.json();
return data.results[0] // this gets location info such as country, state, city, address...
} |
Not really, looks like a big issue :( |
For those in need, if you don't use |
@bruno-de-queiroz can you share your code? |
This is more a missing feature and a lack of documentation, than a bug. @bruno-de-queiroz the following works on both Android and iOS, but not when using Google Maps on iOS. import React, {useRef} from 'react';
import {StyleSheet} from 'react-native';
import MapView, {Region} from 'react-native-maps';
export default function App() {
const mapRef = useRef<MapView>(null);
const regionChangeCompleteHandler = async ({latitude, longitude}: Region) => {
console.log(
await mapRef.current?.addressForCoordinate({
latitude,
longitude,
}),
);
};
return (
<MapView
ref={mapRef}
style={styles.mapView}
onRegionChangeComplete={regionChangeCompleteHandler}
/>
);
}
const styles = StyleSheet.create({
mapView: {
flex: 1,
},
}); If anyone could open a pull request to clearly state in the docs that addressForCoordinate is Android and Apple Maps only, that would be extremely helpful. |
This comment was marked as off-topic.
This comment was marked as off-topic.
🎉 This issue has been resolved in version 0.31.0-beta.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
🎉 This issue has been resolved in version 0.31.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This isn't solved in version react-native-maps": "^1.7.1. Its working on Android but on iOS it still throws error Cannot read properties of undefined (reading 'apply'). |
Bug report
Summary
I am trying to get the address onPress event by passing the coordinates to addressForCooordinate method but it throws error.
Environment info
react-native info
output:Code
According to readme it should return promise with resolved address but
throws error as
The text was updated successfully, but these errors were encountered: