I'm pretty new at using the Google Maps API although I've learned a lot about it over the last week but one thing that is still bugging me is that i don't know how to add a marker event so that when i click on a mark it will send me to a website. I want the marker to say for example take me to Google( http://www.google.ie/ ) when i click on it.
GEvent.addListener(marker, "click", function() {
});
I just don't know what to put inside this function to do this, i have two events on each marker one with I mouseover the marker, that works alright its just the click that I want to get working.
GEvent.addListener is an event listener (exactly what it says). It look for you to do something, in this case a click. When you call addListener, you're also creating a function.
Within the function, you can call in anything you want. Typically, most people opens up the infoWindow which describes the marker, but in your case, you can put in:
window.location = "http://www.google.com";
so your entire code could look like:
GEvent.addListener(marker, "click", function() {
window.location = "http://www.google.com";
});
A quick FYI, I did not test out the code.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.