TaoJoannes
TaoJoannes

Reputation: 594

Getting Lat and Long from Google Maps API v3

I'm building a standalone proximity search tool in python 2.7 (the intent is distributing it using py2exe and NSIS) and tkinter that takes a center point address, queries the database, and returns all addresses in the database within a certain range.

This is my first time venturing into the google api, and I am extremely confused about how to make use of it to retrieve this data.

I followed the code here: http://www.libertypages.com/clarktech/?p=315

And receive nothing but a 610.

I tried using this url instead, based on a question here on stack overflow and receive a Access Denied Error: http://maps.googleapis.com/maps/api/geocode/xml?

I've set up the project in the API console, enabled the maps service, added both a browser and a server api key, tried them both, and failed.

I've spent all morning pouring through the API documentation, and I can find NOTHING that tells me what URL to specify for a simple API information request for google maps api v3.

This is the actual code of my function, it's a slightly modified version of what I linked above, with some debugging output mixed in, when I ran it with http://maps.google.com/maps/geo? I received 610,0,0,0 :

def get_location(self, query): 


    params = { }
    params[ 'key' ] = "key from console" # the actual key, of course, is not provided here
    params[ 'sensor' ] = "false"
    params[ 'address' ] = query

    params = urllib.urlencode( params )
    print "http://maps.googleapis.com/maps/api/geocode/json?%s" % params

    try:
        f = urllib.urlopen( "http://maps.googleapis.com/maps/api/geocode/json?%s" % params )

Everything Runs perfectly, I just wind up with "610" and "Fail" as the lat and long for all the addresses in my database. :/

I've tried a server app API key and a browser app API key, an Oauth Client ID isn't an option, because I don't want my users to have to allow the access.

I'm REALLY hoping someone will just say "go read this document, you moron" and I can shuffle off with my tail between my legs.

UPDATE: I found this: https://developers.google.com/maps/documentation/geocoding/ implemented the changes it suggests, no change, but it's taking longer to give me the "ACCESS DENIED" response.

Upvotes: 1

Views: 2865

Answers (1)

TaoJoannes
TaoJoannes

Reputation: 594

The API Key is causing it to fail. I took it out of the query parameters dictionary and it simply works as an anonymous request.

    params = { }
    params[ 'sensor' ] = "false"
    params[ 'address' ] = query

Upvotes: 2

Related Questions