How do i attach an onclick event to Placemarks specified in the KML file. Can event listeners be added to both google maps and google earth plugin? How would I go about this?
In the Google Earth plugin...
google.earth.fetchKml(ge, href, function(kmlObject) {});
google.earth.addEventListener(kmlObject, 'click', function(event) {
event.preventDefault();
var kmlPlacemark = event.getTarget();
alert(kmlPlacemark.getName());
});
In Google Maps API
var ctaLayer = new google.maps.KmlLayer('http://www.****.com/index.kml');
ctaLayer.setMap(map);
google.maps.event.addListener(ctaLayer, 'click', function(kmlEvent) {
var text = kmlEvent.featureData.description;
alert(text);
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With