javascript - Get Address when click on Marker - Google Maps -
i need help.
loaded point database , displayed them on google maps markers.
code:
function displaytraficcir(points) { (i=0;i<points.length;i++){ var mylatlng = new google.maps.latlng(points[i].latitude,points[i].longitude) var marker = new google.maps.marker({ position: mylatlng, map: map }); } }
and now, want point's information (latitude/longitude) when click on 1 of these markers in google maps stuff.
help, please. thanks.
use google.maps.event.addlistener
method:
function displaytraficcir(points) { (i=0;i<points.length;i++){ var mylatlng = new google.maps.latlng(points[i].latitude,points[i].longitude) var marker = new google.maps.marker({ position: mylatlng, map: map }); google.maps.event.addlistener(marker, 'click', function () { var lng = points[i].longitue, lat = points[i].latitude; alert( lat + "-" + lng ); }); } }
Comments
Post a Comment