82 Part I — Basics
Aside from the additional steps required to add the points to the map and the more complex
process of loading the XML through an HTTP request to the web server, the basic structure of
accessing the information contained in the XML file through DOM is the same within
JavaScript as in the earlier Perl example.
This type of processing — loading XML, parsing the contents, and then displaying the
information — is an example of AJAX (Asynchronous JavaScript and XML) in action. The entire
process from loading to display is handled entirely within JavaScript and, therefore, happens
without having to specifically reload the page. AJAX provides a dynamic interface within the
scope of what is normally a static web page. See Chapter 9 for more information and examples
on using AJAX with Google Maps.
More of this kind of XML processing is used throughout the rest of this book.
Working with SQL
Storing and retrieving information from SQL databases relies on creating a connection
between your script or application and the SQL database. The exact method you use depends
on the language and environment you are using with your web environment to extract informa-
tion from the database.
The most likely scenario for using a SQL database is when storing information that you want
to have displayed on the map. The information needs to be extracted from the SQL database
and converted into an XML document that can be used by the Google Maps application. By
using a SQL database, you can pick out the specific elements from the database that you want
very easily. For example, you might want to extract all the restaurants, or maybe even all the
restaurants within a particular town. To support this, you create a script that dynamically gen-
erates the XML from the SQL data and that is called directly through the GXmlHttpfunction
supported by the Google Maps API.
Using SQL in this way adds these additional overheads to your application:
You will need to create a suitable structure for the database.
You will need to create a method for updating the information in the database (through
the web or a desktop application).
You will need to build the script that extracts the information and produces the XML.
If you are using MySQL (one of the more popular open source database solutions), the docu-
mentation available on the web site (http://dev.mysql.com/doc) provides one of the
best all-around guides to both the SQL language and the MySQL extensions.
The structure, format, and scripts used to support these operations are application specific, but
the basics are included here to enable you to get started.