2

I have the same question as in the link below. That question remains unanswered: Why different requests return same geolocation with google geolocation api

I have the same question, Why do I get the same google data response on every request? The data I get is always the same.

If I send the curl POST request to Google, I get the same response no matter the value in the JSON key value.

If I send POST request using Python 2.7 using requests I always to the same response no mater the value I set in my variable use for the URL POST request.

Any ideals, what key values would be needed, so I can pull the desired data. For example I want to parse the "locationAreaCode" for various area codes, and I want the request to return the "lat" and "lng" for each lookup.

Using the terminal in MAC OS:

curl -d @your_filename.json -H "Content-Type: application/json" -i https://www.googleapis.com/geolocation/v1/geolocate?key=[use your Google API key]

Note: "your_filename.json" is the literal name for the .json file. This .json file is currently configured below(I have tried various key values):

[
  "cellTowers",
  [
  "locationAreaCode",
  415
  ]
]

When I use python 2.7 with the request syntax, I will get a "response 200" and I will get the exact same data returned.

I always get the same response: Confirming Status Code is: 200

This is the POST url sent to Google [link - had to remove since new user to stackoverflow] Data Returned on the POST request is:

{
 "location": {
  "lat": 25.7459338,
  "lng": -80.30449569999999
 },
 "accuracy": 37571.0
}

Output from python 2.7:

python API_json2-6.py
[link - had to remove since new user to stackoverflow]
Status Code is:  200
Confirming Status Code is:  200
This is the POST url sent to Google 
https://www.googleapis.com/geolocation/v1/geolocate?key=[your google api KEY]&locationAreaCode=415
Data Returned on the POST request is: 

    {
     "location": {
      "lat": 25.7459338,
      "lng": -80.30449569999999
     },
     "accuracy": 37571.0
    }

Thanks!

Community
  • 1
  • 1
Tiburon
  • 55
  • 1
  • 1
  • 6

1 Answers1

0

As detailed in Geocoding Strategies, the basic architecture for a server-side geocoding application is the following:

  • A server based application sends an address to the server's geocoding script.
  • The script checks the cache to see if the address has recently been geocoded.
  • If it has, the script returns that geocode to the original application.
  • If it has not, the script sends a geocoding request to Google. Once it has a result, it caches it, and then returns the geocode to the original application.
  • Sometime later, the geocode is used to display data on a Google Map.

Please note also on the given quota considerations for the things to be avoided when running client-side geocode requests at periodic intervals and on caching considerations wherein The Google Maps API allows you to cache geocodes (i.e. store them on your server for a limited period). Caching can be useful if you have to repeatedly look up the same address.

Teyam
  • 7,686
  • 3
  • 15
  • 22
  • You're talking about geocoding. This is different from the OP's question which talks about geolocation. They are two separate API endpoints. – Mike Kormendy Jun 20 '18 at 15:49