问题
Recently I'm developping a Map containing KML Layer compressed as KMZ file (about 45mb). As there is a file weight limitation, I first split the files into 3mb files. Then I noticed that some splitted files was not showing everytime, causing some "blanks" on the map. So I made researches on many forums, and found that the real limitation of files in order to get everything working properly is 2mb. After update, the KML Layer was indeed showing entierely.
However, after doing many tests, I seen that some parts was disappearing again. Currently there about half of parts that are not showing, like they were rejected by Google Maps API (the rejected parts are always the same, and they are not increasing so I think they are not valid). I did again many research on Google Maps KML Layer API and limitations/validation but couldnt find any information that match with my problem.
Google Maps API does not send error, just got null response like:
/**/_xdc_._swjxb2 && _xdc_._swjxb2( [0,null,null,null,null,null,4,[["client","2"]]] )
Does anyone knows the rules about files limitation/validation ? Is there a limit of access for one KMZ URL ? Or it is because the file is invalid ? If so, how to check if my file is valid ?
Here is the KML extracted from one of the KML files that are rejected:
DOWNLOAD URL: https://mega.nz/#!zohkmSAQ
KEY: !4HfbSLDpazhXHsTpFLOgfgXirRbt2usNFVy-ZYoDNcw
For some reasons, I only removed code that was inside . But here is its format:
<![CDATA[<html xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:msxsl="urn:schemas-microsoft-com:xslt">
<head>
<META http-equiv="Content-Type" content="text/html">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body>
<table>
<td>NAME</td>
</tr>
<tr>
<td>
<table>
<tr>
<td>LABEL</td>
<td>VALUE</td>
</tr>
<tr>
<td>LABEL</td>
<td>VALUE</td>
</tr>
<tr>
<td>LABEL</td>
<td>VALUE</td>
</tr>
<tr>
<td>LABEL</td>
<td>VALUE</td>
</tr>
<tr>
<td>LABEL</td>
<td>VALUE</td>
</tr>
<tr>
<td>LABEL</td>
<td></td>
</tr>
<tr>
<td>LABEL</td>
<td>VALUE</td>
</tr>
<tr>
<td>LABEL</td>
<td>VALUE</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>]]>
I tried to rename extension as xml and open it with Chrome to check if it is well formated, but it was properly parsed by Chrome.
EDIT: Problem was solved by upgrading server for KMZ file upload.
回答1:
KML Restrictions from the documentation
Size and complexity restrictions for KML rendering
The Maps JavaScript API has limitations to the size and complexity of loaded KML files. Below is a summary of the current limits.Note: These limits are subject to change at any time.
Maximum fetched file size (raw KML, raw GeoRSS, or compressed KMZ) 3MB
Maximum uncompressed KML file size 10MB
Maximum number of network Links 10
Maximum number of total document-wide features 1,000
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 shortener to shorten the KML URLs. Alternatively, create a single KML file consisting of NetworkLinks to the individual KML URLs.
The KML you posted is 5MB (which exceeds the maximum fetched file size).
Gives FETCH_ERROR
But can be loaded with the third party library geoxml3 (but as that translates it into "normal" google maps objects in the browser, performance may suffer)
Zipped (KMZ) still gives me a FETCH_ERROR
still loads with geoxml3
来源:https://stackoverflow.com/questions/57671067/google-maps-some-kmz-layers-disappear-after-many-access