Neil_Bradley
asked on
Event Listener within a Google Maps info window
Here is a link to a page containing a Google Map http://www.soundsairpark.com/sandpit/mapTest.html
As it stands I have a zoom event occurring when the marker is clicked. I would like to change this so the zoom event only occurs only when the "zoom" link within the info window is clicked.
Assistance appreciated.
Regards,
N
As it stands I have a zoom event occurring when the marker is clicked. I would like to change this so the zoom event only occurs only when the "zoom" link within the info window is clicked.
Assistance appreciated.
Regards,
N
ASKER
Removing the Zoom from the marker click is straight forward I know and yes your answer would do this. However my question relates to how to add an event listener to the word "zoom" inside the info window so that when it is clicked the zoom occurs.
N
N
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
That is the crux of my question and what I having difficulty achieving. The attached code is the info window set up or the full script can be found via the link.
http://www.soundsairpark.com/sandpit/mapTest.html
N
http://www.soundsairpark.com/sandpit/mapTest.html
N
// Set up marker with info windows
var point = new GLatLng(-41.34204, 173.957801);
var marker = createMarker(point,'<div style="width:240px; font-family:Arial; font-size:14px"><img src="http://www.soundsairpark.com/sandpit/images/structure/logo-icon.png" width="66" height="48" style="float:left; margin-right:10px">Marlborough Sounds <br>Air Park<br>SH1, Picton. NZ<br> <a id=zoom" href="#">Zoom<\/a><\/div>')
map.addOverlay(marker);
ASKER
Ok, it looks like I have it! Many thanks for pointing me in the right direction. If you are interested I am about to post a related question asking how to create a toggle effect on my button.
Cheers
N
My solution:<input type="button" id="zoom" value="Zoom" onclick="map.setZoom(15)"/ >
Cheers
N
My solution:<input type="button" id="zoom" value="Zoom" onclick="map.setZoom(15)"/
function createMarker(point,html) {
var marker = new GMarker(point);
GEvent.addListener(marker,
marker.openInfoWindowHtml(
map.setZoom(15);
});
Do you see the issue? You call "map.setZoom(15)" when the marker is clicked. Change it to:
function createMarker(point,html) {
var marker = new GMarker(point);
GEvent.addListener(marker,
marker.openInfoWindowHtml(
});