Chapter 7 — Extending the Google API Examples 121
The key to the example is the use of GEvent. This function makes the Google Maps applica-
tion respond to a specific event. The next section of this chapter covers events in a bit more
detail, but the principle is similar to adding a response to a mouse click or key press within any
other type of application.
In Listing 7-9, you are configuring a new type of event on the marker that is triggered when
you click the marker. The result of the click is the inline function that you have designed. It
calls the openInfoWindowHtmlmethod on the marker to display the HTML supplied as an
argument, with the title embedded into a set of bold tags.
Once the marker has been configured, it can be added as an overlay object to the map. Figure
7-10 shows the map in its initial state: just showing the configured markers. Figure 7-11 shows
the result when the marker for One on Wharf is clicked: a small information window with the
name of the restaurant.
FIGURE7-10: A map with markers configured for info windows.
You cannot have more than one info window open at a time. If you click a different marker, the
existing info window is closed before the new one is opened.