KML - 多边形图层

KML - layer for a polygon

如何为坐标多边形生成 KML 图层,以便禁用多边形的外部,从而无法单击该区域或禁用绘图管理器等。

[33.832681,-84.504041], [33.889129,-84.361905],[33.756788,-84.285001],[ 33.642536,-84.427823],[ 33.744798,-84.556226],[ 33.832681,-84.504041]

下面是您提供的坐标的基本 KML 多边形。我假设它们代表 [latitude,longitude](在亚特兰大地区),而不是 [longitude,latitude](在南极洲)。请注意,在 KML 文件中,坐标集被写为经度、纬度、海拔高度,这与许多人期望的相反。要预览它,您可以将其另存为 KML 文件并使用 Google 地球打开它,或者只需复制下面的 xml 代码并将其粘贴到 Google 地球。

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom">
    <Placemark>
        <name>Polygon Demo</name>
        <Style>
            <LineStyle>
                <color>ff0000ff</color>
                <width>3</width>
            </LineStyle>
            <PolyStyle>
                <color>880000ff</color>    
                <fill>1</fill>
                <outline>1</outline>
            </PolyStyle>
        </Style>
        <Polygon>
            <tessellate>1</tessellate>
            <outerBoundaryIs>
                <LinearRing>
                    <coordinates>
                        -84.504041,33.832681,0 -84.361905,33.889129,0 -84.285001,33.756788,0 -84.427823,33.642536,0 -84.556226,33.744798,0 -84.504041,33.832681,0                       
                    </coordinates>
                </LinearRing>
            </outerBoundaryIs>
        </Polygon>
    </Placemark>
</kml>

多边形的填充颜色在 KML 的 "PolyStyle" 部分中指定,其轮廓的颜色在 "LineStyle" 中指定。请注意,KML 颜色定义为 "aabbggrr"。 "PolyStyle"中还有选项指定是否(1或0)绘制多边形轮廓和填充:

为了防止多边形被点击,请确保它既没有描述(空的或没有标签),并且应用的任何样式都没有 "BalloonStyle"。如果您在 Google 地图 API 中使用它,您可以设置选项 "suppressInfoWindows: true"。