简体   繁体   中英

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.

When I try adding these KML files, I end up reaching some limitation with Google Maps and KML layers.

在此处输入图片说明

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

From the documentation :

Number of KML layers

There is a limit on the number of KML Layers that can be displayed on a single Google Map. 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. 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. 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. 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. If you still hit the limit, use a URL shortner (such as https://goo.gl ) to shorten the KML URLs. Alternatively, create a single KML file consisting of NetworkLinks to the individual KML URLs.

Using GeoXML, I was able to add all the required KMLs to the map successfully! https://github.com/geocodezip/geoxml3

Thanks to Tony Miller for the solution!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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