Hacking Google Maps and Google Earth (ExtremeTech)

(Dana P.) #1

176 Part III — Google Map Hacks


There are two elements here, both in separate functions. The citylist()function uses
a SQL statement to select a list of distinct cities from the database. The other function,
getmarkers(), returns the list of restaurants. This function is based on the earlier example,
only the SQL statement that selects the list of cities now requests only restaurants that are
located within a specific city.

Using the New Map


You can see the new map, in its initial state, in Figure 9-6. You can see here that the initial
mode is for the window to show a list of available cities. The database has been updated to also
include the restaurants for a town in the Lake District in the U.K., Ambleside, so the default
city list now includes both options.

The final application is available online at http://maps.mcslp.com/examples/ch09-
14.html.

FIGURE9-6: A dynamic application in its initial state.

If you click a city, the JavaScript loads the XML for the specific city by asking the CGI script
to supply it with new XML. The XML is loaded, the markers are added to the map, and the
map is recentered in the middle of all the markers. You can see a representation of restaurants
in Ambleside in Figure 9-7.
Free download pdf