How to integrate Google Maps, Google App Engine, and JSON?
-
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 http://gmaps-samples-v3.googlecode.com/svn/trunk/draggable-markers/draggable-markers.html. 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!
-
Answer:
Over at http://www.mefightclub.com/ we run a minecraft server which has a http://mc1.dtmfa.org/map/ with markers pulled from a database. I'd be glad to introduce you to our spaghetti code if it would help. It's mostly JQuery and PHP. I added the marker functionality.
ofthestrait at Ask.Metafilter.Com Visit the source
Other answers
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 http://pypi.python.org/pypi/geojson/1.0. 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.
Nelson
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 http://www.ep.io/, that follow a GAE-esque pay-per-compute-unit instead of pay-per-box billing model.
andrewpendleton
If you can sacrifice the draggable marker, you won't have to write a single line of code. http://www.google.com/fusiontables/public/tour/index.html 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.
Monsieur Caution
Related Q & A:
- How to integrate paypal into your IOS app using swift?Best solution by Stack Overflow
- Is Go faster than Python on Google App Engine?Best solution by Stack Overflow
- How to connect Android app to App engine?Best solution by groups.google.com
- How often does google maps update?Best solution by Web Applications
- How to open google latitude on iphone from google maps?Best solution by seroundtable.com
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.