No frills geocoding - john dimatos

From Designing Around Place
Revision as of 18:35, 14 September 2008 by Jsd (talk | contribs)
Jump to navigation Jump to search

link to geocoding page DAP2

Building on last week's homework, DAP2 uses gathers a name, an address, and a type of place from the user.

Here's the mySQL table:

phpMyAdmin screenshot

The address, expected in the form '721 broadway, NY NY' is inserted into the address field. Observing the table structure, you'll notice there are latitude and longitude fields that are created empty for every new insert.

Based on this [Google tutorial] DAP2 does a SQL query on the database and puts together a Google search query using the address and the individual API key, requesting XML output. This is what the output looks like:

Google Maps Raw XML Output

As each XML output comes back, DAP2 parses out the coordinates element into two variables lat and long, and updates the mySQL database entry that it pulled the address from, using the unique id field.

The next step in the process is creating our own XML output, using the php DOM XML library. based on a different Google tutorial for [using PHP/MySQL with Google Maps] DAP2 outputs XML that we can use via javascript and the Google API. Here's what that output looks like:


Our Raw XML Output

The final step of DAP2 is the javascript section, which invokes the XML output from our database and creates markers on a map, choosing different icons for different types of locations as we see fit.