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

标签 javascript google-maps google-maps-api-3 kml kmz

我正在尝试将 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/

相关文章:

Android:Google map 不适用于 Phonegap

android - 如何使用谷歌地图 API 跟踪实时位置?

javascript - 如何在没有外部库的情况下在 React 中实现 Google Maps JS API?

android - Google place api,想要获得最近的位置

Javascript:在 div 上执行的 scrollBy 函数

javascript - 在路由更改时重新加载不受 ngRoute 管理的 Controller

javascript - react native 导航给出错误 "undefined is not an object (evaluating ' _this.props.navigation.navigate')"

android - 如何在 android 的 webview 中显示本地谷歌地图?

Android 标记点击功能

javascript - 使用 Javascript 删除值的逗号