Google 地图 api kml 填充不正确

Google maps api kml filling incorrect

我有一个简单的 HTML 和简单的 KML 文件,我想在 Google 地图中显示。问题是单个多边形的填充工作不正常。如果您查看下面的示例,您会看到右侧填充了多边形(这对我的框架来说是正确的)。放大一个级别,填充翻转到另一侧。再次放大,然后翻转回来。缩小一次它会翻转,缩小两次它又回到正确的填充状态。当您不断缩小时,它仍然是正确的。

我在其他地方读到过有关使用 geoxml3 解析 KML 而不是让 Google 执行的信息。虽然主干下载不支持多边形,但我(认为)我下载了它的分支版本。基于此,它似乎正在解析 KML 并创建 google.maps.Polyline 对象。我的问题是我需要显示数百个(不是数千个)多边形,加载时间转换 KML 我预计会限制性能。更不用说,我想要 Google 的 KML 文件缩放级别简化。

有什么想法吗?这已经工作了几年,几周前才坏掉。在 Chromium 37 (linux)、Firefox 38 (linux)、Chrome 43 (Win7)、Firefox 37 (Win7) 和 IE11 (Win7) 上测试。我唯一的其他选择是尝试将 google.maps.ImageMapType() 与 google.maps.overlayMapTypes() 一起使用,这需要大量的重新设计吗?

谢谢!

HTML 页面:

<html>
<head>
<style>
   #mapCanvas {height: 600px;width: 600px;}
</style>
</head>
<body>
<div id="mapCanvas"></div>
<script src="http://maps.google.com/maps/api/js?v=3.&libraries=geometry,drawing,places&sensor=false"/></script>
<script>
    var googleMap = new google.maps.Map(document.getElementById('mapCanvas'), 
          maxZoom: 20,
          minZoom: 4,
          zoom: 17,
          panControl: true,
          zoomControl: true,
          scaleControl: true,
          streetViewControl: true,
          tilt: 0,
          center: new google.maps.LatLng(39.77420517, -94.83232857)
    });
    var kml = new google.maps.KmlLayer('http://itic.occinc.com/new5.kml', 
        preserveViewport: true,
        suppressInfoWindows:true,
        clickable: false,
        map: googleMap
    });
</script>
</body>
<html>

以及 KML(以防它从我的服务器中消失):

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Folder>
<name>District Polygon Folder&lt;/name>
  <open>1&lt;/open>
  <description>&lt;/description>
  <Placemark>
    <name>Folder object 2 (Polygon)&lt;/name>
    <Polygon>
      <altitudeMode>clampToGround&lt;/altitudeMode>
      <outerBoundaryIs>
        <LinearRing>
          <coordinates>
            -94.84433855, 39.53505883
            -94.83010566, 39.82194139
            -94.59858395, 39.8204777
            -94.59383965, 39.53213146
            -94.84433855, 39.53505883
          </coordinates>
        </LinearRing>
      </outerBoundaryIs>
    </Polygon>
  </Placemark>
</Folder>
</kml>

您的 KML 坐标格式可能不正确。以下是 Google Documentation(scroll up):

的摘录

Four or more tuples, each consisting of floating point values for longitude, latitude, and altitude. The altitude component is optional. Do not include spaces within a tuple. The last coordinate must be the same as the first coordinate. Coordinates are expressed in decimal degrees only.

所以逗号后面的空格可能会给您带来麻烦。

另外,附带说明一下,我确实相信 google 地图将显示的 KML 存在文件大小限制。因此,您可能 运行 无法显示数千个形状。

Google KML 呈现器中存在错误。

Issue 8015