gpt4 book ai didi

javascript - Google API--KMZ 文件未出现在网络 map 中

转载 作者:行者123 更新时间:2023-12-03 10:19:45 29 4
gpt4 key购买 nike

我正在尝试将 KMZ 文件加载到 Google Map API 上,但 KMZ 文件没有出现。下面是我的代码,当我加载 HTML 时,一切都能正常执行——只是缺少 KMZ 文件。我尝试通过仅将一个要素图层与整个 map 文档转换为 KMZ 来最小化文件大小,但我遇到了同样的问题。

想法?

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

最佳答案

The document is too large :

返回“DOCUMENT_TOO_LARGE”的 KmlStatus:

Kml Status:DOCUMENT_TOO_LARGE

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.

  • 提取的最大文件大小(原始 KML、原始 GeoRSS 或压缩 KMZ)3MB
  • 未压缩的 KML 文件最大大小为 10MB
  • 最大网络链接数 10
  • 文档范围内的特征总数最多为 1,000

您的 KML 为 18.3 MB,它需要小于 10MB。

您的选择是:

  1. 将您的 KMZ 文件分成 2 个单独的文件,其中包含 < 10 MB 的 KML
  2. 使用第三方 KMZ 解析器(例如 geoxml3 ),但这可能会存在性能问题。 Example using geoxml3 (kmz branch) and your KMZ hosted on my server)

关于javascript - Google API--KMZ 文件未出现在网络 map 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29697046/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com