Google Maps API on click listener

| No Comments
Today I wanted to share a quick example. You want a specific function to happen when someone clicks on your map. We're not talking about click on a marker to open a info window. Today I'm assuming you want to redirect someone to another page when they click on the map. 
To do this we create a listener, it's really easy and will take 40 seconds to explain.
Here is the code that makes it all happen
map = new GMap2(document.getElementById("map_canvas"));
GEvent.addListener(map, "click", function() {
     top.location = 'http://www.queenannessheriff.org/';
);

You can see the map object is created. Then we use GEvent to call 'addListener'. We say when someone 'clicks' on the 'map' to execute the following. Then we tell the page to load http://www.queenannessheriff.org. Easy enough. 

In this case this was a mini map used to show an example of the map. I wanted the user to click on the map to load the full version.