Google地图KML层地标点击事件返回ZERO_RESULTS [英] Google Map KML layer placemark click event return ZERO_RESULTS

查看:140
本文介绍了Google地图KML层地标点击事件返回ZERO_RESULTS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将监听器附加到KML层:

Attaching listener to KML layer:

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中的每个地标都具有以下id属性:

KML file is valid (checked by validation api), you may find it here. Each placemark in XML has id attribute like:

<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>

当点击Google地图对象中的地标时,会返回正确的ID,但有时大约有50%的时间 obj.featuredData.id null ( ZERO_RESULTS 状态为在 status 字段中)。我尝试了不同的数据集(从100点到1000),但它没有帮助。我也尝试了lat,lng的不同精度。

When clicking on a placemark in google map object returns right id, but sometimes about 50% of the time obj.featuredData.id is null (ZERO_RESULTS status is in status field). I have tried different sets of data (form 100 points to 1000), but it doesn't help. Also I've tried different precisions for lat, lng.

推荐答案

您可能已经在该页面列出了一个限制: https://developers.google.com/kml/documentation/mapsSupport?hl=zh_CN

You've probably hit one the limits listed on that page: https://developers.google.com/kml/documentation/mapsSupport?hl=en

每个文件最多可包含1000个功能,这可能会让您烦恼。

Maximum 1000 features per file could be the one that is bothering you.

这篇关于Google地图KML层地标点击事件返回ZERO_RESULTS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆