Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get marker id in google maps

Tags:

google-maps

I want to pass related marker id by clicking marker on google map. I am using marker.getId() function to retrieve marker id. But the marker id is not passing along with url. How can i do this? Any Help?

function AddressMap(lat,lang,markerid)
{   
var latLng = new google.maps.LatLng(lat,lang);
var marker = new google.maps.Marker({
    'map': map,
    position: latLng,
    'latitude' :lat,
    'longitude' :lang,
    icon: image,
    shadow: shadow,
    id: markerid

});

markers.push(marker);   
google.maps.event.addListener(marker, 'click', function() {               
          window.location = "www.cickstart.com/" + marker.getId();

        }); 
}
like image 983
srinu Avatar asked Nov 30 '22 15:11

srinu


1 Answers

you can try directly to access the id:

google.maps.event.addListener(marker, 'click', function() {               
  window.location = "www.cickstart.com/" + marker.id;
});
like image 162
msonsona Avatar answered Dec 05 '22 20:12

msonsona