Javascript 谷歌地图KML图层placemark点击事件返回零结果

Javascript 谷歌地图KML图层placemark点击事件返回零结果,javascript,google-maps-api-3,kml,Javascript,Google Maps Api 3,Kml,将侦听器附加到KML层: var layer = new google.maps.KmlLayer('http://sites.google.com/site/kmlprototypes/kmls/temp.kml?dc_=' + Math.random(), {suppressInfoWindows:true,preserveViewport:true}); layer.setMap(map); google.maps.event.addListener(layer, 'click', f

将侦听器附加到KML层:

var layer = new google.maps.KmlLayer('http://sites.google.com/site/kmlprototypes/kmls/temp.kml?dc_=' + Math.random(),
{suppressInfoWindows:true,preserveViewport:true});

layer.setMap(map);

google.maps.event.addListener(layer, 'click', function (obj) {
    alert(obj.featureData.id);
});
KML文件是有效的(通过验证api检查),您可以找到它。XML中的每个placemark都有id属性,如:

<Placemark id="46">
  <Style>
    <IconStyle>
      <Icon>
        <href>
          <![CDATA[http://chart.apis.google.com/chart?chf=bg,s,EAF7FE02&chxt=y&chbh=a,4,4&chs=48x48&cht=bvg&chco=FF0000,0000FF&chds=20,9048.00,0,9048.00&chd=t:8149.00|9048.00]]>
        </href>
      </Icon>
    </IconStyle>
  </Style>
  <Point>
    <coordinates>30.49566650390625,50.721378326416016</coordinates>
  </Point>
</Placemark>

30.49566650390625,50.721378326416016

在google map中单击一个位置标记时,对象返回右id,但有时大约50%的时间
obj.featuredData.id
null
ZERO\u结果
状态在
状态
字段中)。我尝试了不同的数据集(从100点到1000点),但没有帮助。此外,我还尝试了lat、lng的不同精度。

您可能已经达到了该页面列出的一个极限:


每个文件最多1000个功能可能是困扰您的问题。

是否仅显示问题?看起来您的KML包含太多自定义标记。它是使用geoxml3渲染的(渲染需要一段时间)。如果隐藏这些标记(单击“隐藏”按钮),然后显示Kmlayer,则会看到默认蓝色标记和自定义标记的组合。