javascript - Google Maps - Multiple behaviours with markers -
i have google map display 2 types of marker on. 1 of these display popup window information, other link url.
is possible set sort of distinction between markers can add together separate listener functions each?
thanks in advance.
something maybe (http://jsfiddle.net/uzv95/)? :
var pos = [ { position: new google.maps.latlng(-25.1, 131.044922), action: function (e) { document.location.href = "http://google.com" } }, { position: new google.maps.latlng(-25.363882, 131.044922), action: function (e) { infowindow.open(map, this); } } ], markers = [], infowindow = new google.maps.infowindow({ content: "hi" }), mapoptions = { center: pos[0].position, zoom: 8, maptypeid: google.maps.maptypeid.roadmap }, map = new google.maps.map(document.getelementbyid("map"), mapoptions); pos.foreach(function (position) { var marker = new google.maps.marker({ position: position.position }); marker.setmap(map); google.maps.event.addlistener(marker, 'click', position.action); markers.push(marker); });
hope helps!
javascript google-maps google-maps-api-3
No comments:
Post a Comment