Custom GEvent types
You don’t have to be limited to using the GEvent event types that Google supply.
If you want to pass information from one part of your own code to another you can use your own GEvents. You don’t have to do anything special to get this to happen, you just perform GEvent.addListener and GEvent.trigger using your custom event type, just as if it were one of the inbuilt event types.
Here’s an example that uses the new events “to” and “from” to handle the “get directions” options in an info window. By using events in this way, it’s not necessary to use the to_htmls[ ] and from_htmls[ ] arrays that were used in map 4, since we can now hold the information by function closure.
You can pass these custom events on any object, these can be API objects, HTML elements, data structures, or any type of Object().
GEvent.addListener(map, "myevent", ... GEvent.addListener(document.getElementById("message"), "thisevent", ... var fred = new Object(); GEvent.addListener(fred, "thatevent", ...