Reputation: 376
I'm using 'react-native-geocoder' library, where I have used this piece of code in my app:
//reverse - geocoding
var NY = {
lat: 40.7809261,
lng: -73.9637594
};
Geocoder.geocodePosition(NY).then(res => {
// res is an Array of geocoding object (see below)
//location details goes here
})
.catch(err => console.log(err))
But getting the error:
geocodePostion is undefined function
I'm using "react-native": "0.31.0", "react-native-geocoder": "^0.4.5"
and have followed the configuration steps mentioned in the library.
Upvotes: 0
Views: 2069
Reputation: 376
I got it fixed by this code.I was trying to get the place mark of latitude and longitude
var myAddress = ''
var NY = {
lat: this.state.position.coords.latitude,
lng: this.state.position.coords.longitude
};
Geocoder.fallbackToGoogle(MY_KEY);//MY_KEY -- enabled the key googleMapAPI portal.
// use the lib as usual
let ret = Geocoder.geocodePosition(NY).then((res)=>
{
console.log(res)
myAddress = res["0"].formattedAddress
console.log(myAddress);
this.setState({
MyAddress: myAddress
});
})
console.log(this.state.MyAddress);
I'm using "react-native": "0.31.0", "react-native-geocoder": "^0.4.5" and have followed the configuration steps mentioned in the library.
Upvotes: 3