View Full Version : Google Places API & Sencha

26 Jul 2011, 12:29 PM

I am back trying Sencha Touch. I am trying to (what I think is simple) a request to Google for a list of Places that are within GeoCoords. I had a prototype working in iOS and in jQuery and I am trying to port it over into Sencha. I would like the JSON result to be displayed in a Navigation List / Table format.

The problem I am running into is an error on the JSON that is returned from Google.

"Uncaught SyntaxError: Unexpected token :"

I am using Ext.util.JSONP.request to make the request but it appears to be failing on the response. I found an article stating JSONP is not supported by the Google Places API.

If that is the case, what is the workaround? Is there one?

21 Aug 2011, 8:07 PM
Same Problem for me... If any one have a solution please say.....

20 Nov 2011, 2:57 PM
Anyone figured this out yet?!? :-/

16 Dec 2011, 1:56 AM
Any luck so far? Am facing the same issue..

25 Jan 2012, 11:46 PM
Exactly the same issue for me..

2 Feb 2012, 11:31 PM
Anyone of you got solution for this issue, please suggest :(

3 Feb 2012, 3:54 AM
I have a solution:

You can make a jsonp request to your server.
-The server will print "Ext.util.JSONP(".
-The server will then get the json file from google and print it.
-The server will print ")"

Here is a code sample:

url: 'http://localhost:8080/db/',
callbackKey: 'callback',
params: {
currentLat: getLat(),
currentLon: getLon(),
transaction: 'getGpPlaces'
callback: function(result) {

To make this work you have to modify your app.yaml and add the following code:

- url: /db/.*
script: db/transaction.py

Then create a db folder under your project's root directory and inside it create the transaction.py
The python code inside transaction.py looks like this:

def geocode(sensor,location,radius,key, **geo_args):
'sensor': <sensor>, #true or false
'location': <location>, #lat,lon
'radius': <radius>, #distance in meters
'key': <your app's API key>
url = GEOCODE_BASE_URL + '?' + urllib.urlencode(geo_args)
result = simplejson.load(urllib.urlopen(url))
print ''
print 'Ext.util.JSONP.callback('
print simplejson.dumps(result, indent=2)
print ')

Have a look also here (http://gmaps-samples.googlecode.com/svn/trunk/geocoder/python/SimpleParser.py).