Friday, 7 June 2013

Google Map marker with url variation

Google Map marker with url variation

I'm stuck trying to figure out a little bit of JS :( I have a google map
var myCenter=new google.maps.LatLng(53, -1.33);

function initialize()
    {
    var mapProp = {
        center:myCenter,
        zoom: 14,
        draggable: false,
        scrollwheel: false,
        mapTypeId:google.maps.MapTypeId.ROADMAP
    };

    var map=new google.maps.Map(document.getElementById("map-canvas"),mapProp);

    var marker=new google.maps.Marker({
        position:myCenter,
        icon:'images/pin.png',
        url: 'http://www.google.com/',
        animation:google.maps.Animation.DROP
    });
    marker.setMap(map);
    }

    google.maps.event.addDomListener(window, 'load', initialize);
But i cant seem to hook up the onlick event for the marker url?
I know it has something to do with adding
    google.maps.event.addListener(marker, 'click', function() {window.location.href = marker.url;});
But where ever I put it causes the map to not display or the marker to not display.

No comments:

Post a Comment