You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Sep 4, 2021. It is now read-only.
Repository navigation
This repository was archived by the owner on Sep 4, 2021. It is now read-only.
Cannot read property 'geocodePosition' of undefined #62
I created the project with react-native init I added the <uses-permission android: name = "android.permission.ACCESS_FINE_LOCATION" /> to AndroidManifest.xml and I used the react-native link to link.
But when I run the project this returns latitude and longitude to then display an error screen:
I really have not found the error, what can it be?
I ended up giving up using the library, through the help I received in stackoverflow, I solved my problem by performing the requisition for google api:
componentWillMount() {
navigator.geolocation.getCurrentPosition(
(position) => {
this.setState({
latitude: position.coords.latitude,
longitude: position.coords.longitude,
error: null,
}, () => this.getGeocode()); // call the api after getCurrentPosition is finished
},
(error) => this.setState({ error: error.message }),
{ enableHighAccuracy: true, timeout: 20000 },
);
}
getGeocode() {
axios.get('https://maps.googleapis.com/maps/api/geocode/json?address='+ this.state.latitude +','+ this.state.longitude +'&key=__API_KEY__') // be sure your api key is correct and has access to the geocode api
.then(response => {
console.log(response);
this.setState({
place: response.data.results[0].formatted_address // access from response.data.results[0].formatted_address
})
}).catch((error) => { // catch is called after then
this.setState({ error: error.message })
});
}
But I still want to find out why I can not do it with the library.
Activity
deniscapp commentedon Nov 1, 2017
Having the same problem here!
Mate38 commentedon Nov 1, 2017
I ended up giving up using the library, through the help I received in stackoverflow, I solved my problem by performing the requisition for google api:
But I still want to find out why I can not do it with the library.
SaifulBashar commentedon Nov 2, 2017
Facing same problem
Vnicius commentedon Jan 27, 2018
Run
react-native link react-native-geocoderand rebuild work for meankitsinghania94 commentedon Feb 2, 2018
Better to link manually