Google Map KML Layer - Click ZERO_RESULTS Return Event

I am working with the KML level click event in Google Maps.

I am using this code:

function initialize() { var mapOptions = { center: new google.maps.LatLng(41.875696, -87.624207), zoom: 11, mapTypeId: google.maps.MapTypeId.ROADMAP }; var map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions); var ctaLayer = new google.maps.KmlLayer('https://sites.google.com/site/anoopkml123/kml/ab9Plan0520.kmz'); ctaLayer.setMap(map); google.maps.event.addListener(ctaLayer, 'click', function(kmlEvent) { alert(kmlEvent.featureData.name); }); } 

Sometimes alert(kmlEvent.featureData.name) shows a number, but sometimes it is undefined. Sometimes obj.featuredData.id is null (the status ZERO_RESULTS is in the status field).

+6
source share
1 answer

Created your code in a script: http://jsfiddle.net/mdares/TAfys/

I cannot reproduce the problem you are facing. Can you give an example above where it fails? Is this possible in the browser? Finally - is there any additional code that you have not published that could be the reason? My code is immutable from yours as you posted, but I am curious if you also do other things:

 function initialize() { var mapOptions = { center: new google.maps.LatLng(41.875696, -87.624207), zoom: 11, mapTypeId: google.maps.MapTypeId.ROADMAP } var map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions); var ctaLayer = new google.maps.KmlLayer('https://sites.google.com/site/anoopkml123/kml/ab9Plan0520.kmz'); ctaLayer.setMap(map); google.maps.event.addListener(ctaLayer, 'click', function (kmlEvent) { alert(kmlEvent.featureData.name); }); } 
+1
source

All Articles