简体   繁体   English

Google Maps API KML层数限制

[英]Google Maps API KML layer limit

I need to display a large number of KML files on a Google Maps API map, based on certain conditions. 根据某些条件,我需要在Google Maps API地图上显示大量KML文件。

When I try adding these KML files, I end up reaching some limitation with Google Maps and KML layers. 当我尝试添加这些KML文件时,最终在Google Maps和KML图层上遇到了一些限制。

在此处输入图片说明

I've tried using shortened URLs, PHP scripts, shortened URLs AND PHP scripts but nothing seems to have fixed the issue, and I still hit the limit within seconds... 我尝试使用缩短的URL,PHP脚本,缩短的URL和PHP脚本,但似乎没有任何问题可以解决,并且我仍然在几秒钟内达到了极限。

From the documentation : 文档中

Number of KML layers KML层数

There is a limit on the number of KML Layers that can be displayed on a single Google Map. 可以在单个Google地图上显示的KML图层数量是有限制的。 If you exceed this limit, none of your layers will appear on the map, and an error will be reported in your web browser's JavaScript console. 如果超出此限制,则所有图层都不会出现在地图上,并且将在Web浏览器的JavaScript控制台中报告错误。 The limit is based on a combination of the number of KMLLayer classes created and the total length of all the URLs used to create those layers. 该限制基于所创建的KMLLayer类的数量以及用于创建这些层的所有URL的总长度的组合。 Each new KMLLayer you create will take up a portion of the limit for the layer and a further portion of the limit depending on the length of the URL where the KML file was loaded from. 您创建的每个新KMLLayer都会占该层的一部分限制,而另一部分则取决于从中加载KML文件的URL的长度。 Consequently, the number of layers you can add will vary by application; 因此,您可以添加的层数将因应用程序而异。 on average, you should be able to load between 10 and 20 layers without hitting the limit. 平均而言,您应该能够加载10到20层之间而不会达到限制。 If you still hit the limit, use a URL shortner (such as https://goo.gl ) to shorten the KML URLs. 如果您仍然达到限制,请使用URL缩写(例如https://goo.gl )来缩短KML URL。 Alternatively, create a single KML file consisting of NetworkLinks to the individual KML URLs. 或者,创建一个由网络链接组成的单个KML文件,这些链接指向各个KML URL。

Using GeoXML, I was able to add all the required KMLs to the map successfully! 使用GeoXML,我能够将所有必需的KML成功添加到地图中! https://github.com/geocodezip/geoxml3 https://github.com/geocodezip/geoxml3

Thanks to Tony Miller for the solution! 感谢Tony Miller的解决方案!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM