问题
I am attempting to get a KMZ file to load ontop of a Google Map API and the KMZ file is not appearing. Below is my code and everything executes properly when I load the HTML--the KMZ file is just missing. I tried to minimize the size of the file by converting only one feature layer vs the entire map document to KMZ but I had the same problem.
Ideas?
<!DOCTYPE html>
<html>
<head>
<title>Map Title, USA</title>
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyAx70- gnDWt1nCCf_pLezTNqZfH2G_im04"></script>
<script>
function initialize()
{
var mapProp = {
center:new google.maps.LatLng(38.89,-77),
zoom:12,
mapTypeId:google.maps.MapTypeId.SATELLITE
};
var map = new google.maps.Map(document.getElementById("googleMap"),mapProp);
var kmlPath = https://sites.google.com/site/geos455assignment/data_files/assignment-4/Turi_Kristen_GEOS455_Assign4.kmz';
var urlSuffix = (new Date).getTime().toString();
var layer = new google.maps.KmlLayer(kmlPath + '?' + urlSuffix );
layer.setMap(map);
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>`
</head>
<body>
<div id="googleMap" style="width:1384px;height:936px;"></div>
</body>
</html>
回答1:
The document is too large:
returns a KmlStatus of "DOCUMENT_TOO_LARGE":
Kml Status:DOCUMENT_TOO_LARGE
- original link (no longer valid)
- Limits:
Size and Complexity Restrictions for KML Rendering in Google Maps
Google Maps currently has specific limitations to the size and complexity of loaded KML files. Below is a summary of the current limits:
Note: these limits are temporary and 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
Your KML is 18.3 MB, it needs to be less than 10MB.
Your options are:
- break your KMZ file into 2 separate files containing KML of < 10 MB
- use a third party KMZ parser (like geoxml3), but that may have performance issues. Example using geoxml3 (kmz branch) and your KMZ hosted on my server)
来源:https://stackoverflow.com/questions/29697046/google-api-kmz-file-not-appearing-in-web-map