148 Part III — Google Map Hacks
FIGURE9-1: A basic multi-point HTML-only example.
Remember that coordinates are generally referenced using latitude and longitude in that order,
although many of the built-in functions within the Google Maps API use the terms X and Y (or hor-
izontal and vertical). Latitude is the vertical (Y) measure; longitude is the horizontal (X) measure.
Making the Generation Dynamic with a Script
The previous example used a static HTML file to generate the map. The static method has
some limitations, including the most obvious one, that changing or editing the content means
making modifications directly to the HTML.
Technically there is no problem with this approach, but you do not always want users to be able
to edit the HTML on a live web server. It is better to use a method that dynamically generates
the HTML and JavaScript required for the map based on a source of data separate from the
map points and information on the screen.
The simplest way to dynamically create a Google Map is to change from using the static
HTML method to a script-based method that generates the necessary HTML and JavaScript
to build the map. The system is dynamic in that the script can be updated and the source for
the information can be any reliable data source, such as static files or a database.
Listing 9-2 demonstrates the generation of a set of HTML identical to that generated in
Listing 9-1. The difference is that this listing is a Perl script designed to run as a CGI. The