How to integrate Google Maps, Google App Engine, and JSON?
January 21, 2011 12:56 PM   Subscribe

I'd like an explanation of how to make Google App Engine (in python), Google Maps (in javascript), and JSON play nice with each other. My programming experience is intermediate. Details inside.

Here's what I would like to end up with:
An AppEngine-powered site which primarily consists of a google map, plotting points of interest.

The first use, view mode, pulls a number of instances from the datastore and plots them on the map. There's about 8 different categories of points (no polygons) and each has lat,long coords, an address, category, and brief description.

In the second use, post mode, users can take a draggable marker on the Google Map, drag it to a point on the map, and select a category and write a brief desciption/comment. Ideally the coordinates/address could be autopopulated on the Maps end (I've been looking at this example.

My basic understanding of how this would work is as follows:

The data is stored in a JSON file, accessible to the Google Map in Javascript. This file is generated by a Python function that writes all instances of the Point model in a JSON syntax. My question is how can I feed the new data from the Google Map back into Python and thus the Datastore backend? I tried using (self.request.get) on the div fields where the earlier example puts the coordinates and address but I can't get that to work, so my guess is there's a barrier to doing that that I don't know about.

I am just getting back into programming after some years off, so while I have been learning a lot about Python recently, I am not so good with JavaScript. I am open to learning more, however. Any explanation of how this application should be written/alternative ways of accomplishing what I'd like to do/better resources that I could learn from are welcome. Thanks!
posted by ofthestrait to Computers & Internet (3 answers total) 1 user marked this as a favorite
 
There's a lot of ways to glue this together. The road you're going down, I think the missing piece you have is communicating the data from Javascript in the web browser back to Python in your Google App Engine server. The key here is some sort of AJAX call to send data back; personally I'd use jQuery to do it.

BTW, since you're doing JSON any way, you probably should use GeoJSON.

If you're just getting started and are not wedded to Google App Engine, GeoDjango does a whole lot of work for you. But it requires many technologies that won't work in Google's environments.
posted by Nelson at 4:24 PM on January 21, 2011


App Engine with Python is essentially modified Django, and there are lots of Django apps for which modified versions exist for GAE. Piston is one; it's a Django app for building RESTful APIs (basically, URLs you can GET to extract data from your datastore, and POST to if you want to write). That library or similar will allow you to basically just define your models and automagically have your whole server interface generated for you (it can spit out JSON, no problem). After that, it all becomes a matter of client-side programming, for which there are tons of resources not specific to GAE.

I will add, though, that while that will work fine if all you're doing is pumping values into and out of a dumb datastore, if you ever want to do anything fancier with your GIS data, Nelson is right that GeoDjango will save your ass, and there are also way more resources out there about Django, generally, than GAE, so if you're not dead-set on using App Engine, I might look at using something else. Hosting's cheap, these days, and there are lots of options. There are even some services in the works, like ep.io, that follow a GAE-esque pay-per-compute-unit instead of pay-per-box billing model.
posted by andrewpendleton at 5:25 PM on January 21, 2011


If you can sacrifice the draggable marker, you won't have to write a single line of code. Google Fusion Tables will allow you to plot up to 100Mb of tabular data on a Google map (including descriptions, markers colored based on the value of some field, links to images that are pulled in dynamically, etc.) and open up the data source for editing and commenting by other users.
posted by Monsieur Caution at 8:52 PM on January 21, 2011


« Older How do I monitor net usage in terms of GB/month?   |   What to do when you are born in a trough? Newer »
This thread is closed to new comments.