I need to get marker icon url on click, I saw on google maps documentation that there is function getIcon() but don’t know where to call it.
google.maps.event.addListener(layer, 'click', function (kmlEvent) {
alert(kmlEvent.getIcon());//Object #<Object> has no method 'getIcon'
showInContentWindow(map, kmlEvent);
});
Update:
var myOptions = {
zoom: 8,
center: null,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("kmlMapCanvas"), myOptions);
var layer = new google.maps.KmlLayer(
'https://maps.google.co.uk/maps/ms?msid=207817312541605896974.0004cdbf70e9c541de0ac&msa=0&ll=51.499019,-0.58382&spn=0.070103,0.209255&output=kml',
{
suppressInfoWindows: true,
map: map
});
google.maps.event.addListener(layer, 'click', function (kmlEvent) {
alert(kmlEvent.getIcon());//Object #<Object> has no method
showInContentWindow(map, kmlEvent);
});
where I am losing connection with native marker….
You can’t access the icon if you render your KML using KmlLayer. If you use a third party parser, like geoxml3 or geoxml-v3, which renders the KML using native Google Maps API v3 markers, you can access the icon, using the getIcon() method on the marker.
Your KML displayed with geoxml3
The urls of the icons are:
This works on that page (in the address bar, at least in IE):