Hacking Google Maps and Google Earth (ExtremeTech)

(Dana P.) #1

Chapter 9 — Using Overlays 177


FIGURE9-7: Restaurants in Ambleside.


Finally, clicking a marker or restaurant name shows the information window, as shown in
Figure 9-8.


Clicking “Back to city list” would show the list of cities again (see Figure 9-9). The entire pro-
cess has taken place without having to load any different pages, and all of the information is
loaded from a database.


Extending the Content


The real power of the preceding solution is that you can easily extend the information and data
provided on the map — even the list of supported cities — just by updating the database back-
end. By entering more restaurant titles, address information, map points, and other data into
the database, you can add cities, restaurants, and contact information to the map without ever
making any changes to either the HTML or the JavaScript demonstrated in this section.


It is possible, for example, to extend the basic interface so that the user could select entity types
(restaurants, pubs, doctors, shops, and so on) from within the interface in addition to being able
to choose a city to display. It is also not hard to imagine how you might extend this further to
display an array of different information on the same map just by loading different selections of
information. After all, it is the database query that loads the information that is to be dis-
played; a different query could load and display different information.


It is the combination of database-driven content, the CGI script that provides this information in
XML format, the AJAX components that load this data, and the Google Maps API that enable
you to lay all of this information out onscreen that provides you with power and flexibility.

Free download pdf