The Basics

Google Maps API Tutorial

Get Directions

One way to offer directions is to throw a request at maps.google.com, and have the results be displayed on a real Google map. You can arrange for the resulting Google map to be displayed in a new window.

It is now also possible to display directions on your own map, see this advanced tutorial

Here’s an example that uses XML.

Here’s another example that doesn’t use XML.

There are initially two links: “To here” and “From here”. Clicking these links opens a corresponding form. Submitting the form throws a request to maps.google.com in a new browser window.

When the data is read from the XML file, the HTML for each of the three different info window displays for each marker are generated and stored in two new arrays to_htmls[ ] and from_htmls[ ]. The initial version of the info window, one with the “To here” form and one with the “From here” form. When the “To here” or “From here” link is clicked, the corresponding html string is loaded into the info window.

It’s also possible to add text, in brackets, to the end of the &saddr or &daddr parameters and have that text be displayed in bold on the Google Local page, instead of having the latitude and longitude appear in bold.


If you want something simpler, you can just provide a link to Google Maps with an empty &saddr. When Google Maps loads, it will display the &daddr destination, and allow the user to enter the start address.

example


Google maps now supports multi-point routing. You can request multi-point routes by adding “+to:+” followed by subsequent destinations to the end of the &daddr string.