1
votes

I am using https://github.com/marlove/react-native-geocoding to get coordinates in react-native.

Sample code

`Geocoder.from("visakhapatnam,andhra pradesh,india")
.then(json => {
var location = json.results[0].geometry.location;
console.log("location",location)
})
.catch(error => console.warn("routeMap Err",error));`

I am getting error

{"code": 4, "message": "Error from the server while geocoding. The received datas are in the error's 'origin' field. Check it for more informations.", "origin": {"error_message": "You must enable Billing on the Google Cloud Project at https://console.cloud.google.com/project/_/billing/enable Learn more at https://developers.google.com/maps/gmp-get-started", "results": [], "status": "REQUEST_DENIED"}}

3

3 Answers

1
votes

To use the Geocoding API you must have an API key. The API key is a unique identifier that is used to authenticate requests associated with your project for usage and billing purposes.

To get an API key:

  1. Visit the Google Cloud Platform Console.
  2. Click the project drop-down and select or create the project for which you want to add an API key.
  3. Click the menu button and select APIs & Services > Credentials.
  4. On the Credentials page, click Create credentials > API key. The API key created dialog displays your newly created API key.
  5. Click Close. The new API key is listed on the Credentials page under API keys. (Remember to restrict the API key before using it in production.)

OR You need try enable billing like an error message.

  1. Go to the Payment Account Management page in the Google Cloud Platform Console and log in.
  2. Select the My Projects tab to display the list of projects and the payment accounts associated with each project.
  3. In the list of projects, locate the project for which you want to re-enable payments, and then click the menu (more_vert) next to it.
  4. Select Change payment and select the destination payment account you want.
0
votes

did you provide api key to geocoded like this Geocoder.init('your api key'); // use a valid API key

0
votes

I had this problem because my google cloud free trial plan ended. When I upgraded to Blaze plan the error stopped happening.