具有内部边界的全世界KML在谷歌地图中显示出奇怪的效果

时间:2013-05-14 04:04:38

标签: google-maps kml

所有!

我有一个看起来像下一个的kml文件:

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
  <Document>
    <name>KML file with polygon for bird species range</name>
    <description>Source various books and websites</description>
    <Style id="rangecolour">
      <LineStyle><color>660000FF</color><width>1</width></LineStyle>
      <PolyStyle><color>660000FF</color></PolyStyle>
    </Style>
    <Style id="linecolour">
      <LineStyle><color>660000FF</color><width>3</width></LineStyle>
    </Style>
    <Placemark><name>distribution/range</name>
      <description></description>
      <styleUrl>#rangecolour</styleUrl>
      <Polygon>
        <tessellate>1</tessellate>
        <altitudeMode>clampToGround</altitudeMode>
        <outerBoundaryIs>
          <LinearRing>
            <coordinates>
              -180.0,180.0,0.0 
              -180.0,-180.0,0.0 
              180.0,-180.0,0.0 
              180.0,180.0,0.0 
              -180.0,180.0,0.0 
            </coordinates>
          </LinearRing>
        </outerBoundaryIs>
        <innerBoundaryIs>
          <LinearRing>
            <coordinates>
              153.056374,-27.500658,0.0 
              153.056374,-27.524105,0.0 
              153.093109,-27.524105,0.0 
              153.093109,-27.500658,0.0 
              153.056374,-27.500658,0.0 
            </coordinates>
          </LinearRing>
        </innerBoundaryIs>
      </Polygon>
    </Placemark>
  </Document>
</kml>

我的目的是在整个世界内做一个“漏洞”,以便在界外的所有世界中留下阴影(这只是一个例子),但是,由于某种原因,我不知道,在Google地球中工作得很好,但在谷歌地图(API v3,至少...是我使用的“google.maps.KmlLayer(url.kml)”...)没有。

有谁知道为什么?

提前谢谢!

1 个答案:

答案 0 :(得分:0)

外边界是:

        <coordinates>
          -180.0,180.0,0.0 
          -180.0,-180.0,0.0 
          180.0,-180.0,0.0 
          180.0,180.0,0.0 
          -180.0,180.0,0.0
        </coordinates>

这是一个非常窄的正方形(介于-180和+180之间)

下面显示的KML将此用于多边形(整个世界有一个小洞):

<Placemark><name>distribution/range</name>
  <description></description>
  <styleUrl>#rangecolour</styleUrl>
  <Polygon>
    <tessellate>1</tessellate>
    <altitudeMode>clampToGround</altitudeMode>
    <outerBoundaryIs>
      <LinearRing>
        <coordinates>
          180,85 
          90,85 
          0,85 
          -90,85 
          -180,85 
          -180,0 
          -180,-85 
          -90,-85 
          0,-85 
          90,-85 
          180,-85 
          180,0 
          180,85 
        </coordinates>
      </LinearRing>
    </outerBoundaryIs>
    <innerBoundaryIs>
      <LinearRing>
        <coordinates>
          153.056374,-27.500658,0.0 
          153.093109,-27.500658,0.0 
          153.093109,-27.524105,0.0 
          153.056374,-27.524105,0.0 
          153.056374,-27.500658,0.0 
        </coordinates>
      </LinearRing>
    </innerBoundaryIs>
  </Polygon>
</Placemark>

This适用于我geoxml3,不适用于KmlLayer

Another example

我不知道为什么,Google Maps KML parserKmlLayer几乎总是以这种方式被打破。

Related question: shading area outside of kml boundary