如何使KML不导入多几何的顺序

时间:2012-09-28 06:31:54

标签: kml google-earth

您好我正在编写一些KML以及何时和我按顺序创建多项目

PlaceMark A. PlaceMark B

我无法选择PlMark A因为B更大,但是当我有

PlaceMark B. PlaceMark A

是的,因为我认为A较小而且它是最后一个被图示的,我的问题是我不能有地标顺序,Kml中有任何选项可以选择所有元素。

感谢。

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.0">
<Document>
<StyleMap id="StyF1"><Pair><key>normal</key><Style><IconStyle><Icon></Icon></IconStyle><PolyStyle><color>7d0000ff</color></PolyStyle></Style></Pair><Pair><key>highlight</key><Style><IconStyle><Icon></Icon></IconStyle><PolyStyle><color>7aFFFF8C</color></PolyStyle></Style></Pair></StyleMap>
<StyleMap id="StyU1"><Pair><key>normal</key><Style><IconStyle><Icon></Icon></IconStyle><PolyStyle><color>7d0000ff</color></PolyStyle></Style></Pair><Pair><key>highlight</key><Style><IconStyle><Icon></Icon></IconStyle><PolyStyle><color>7aFFFF8C</color></PolyStyle></Style></Pair></StyleMap>

<Placemark>
    <name>A</name>
    <description>
    </description>
    <visibility>1</visibility>
    <tessellate>1</tessellate>
    <styleUrl>#StyU1</styleUrl>
    <MultiGeometry>
        <Point>
            <coordinates>-0.18806,39.78366</coordinates>
        </Point>
        <Polygon>
        <outerBoundaryIs>
            <LinearRing>
                <coordinates>-0.18806,39.78261
                -0.18701,39.7844286533479
                -0.18911,39.7844286533479
                -0.18806,39.78261</coordinates>
            </LinearRing>
        </outerBoundaryIs>
        </Polygon>
    </MultiGeometry>
</Placemark>

<Placemark>
    <name>B</name>
    <description>
    </description>
    <visibility>1</visibility>
    <tessellate>1</tessellate>
    <styleUrl>#StyF1</styleUrl>
    <MultiGeometry>
        <Point>
            <coordinates>-0.18806,39.78501</coordinates>
        </Point>
        <Polygon>
        <outerBoundaryIs>
        <LinearRing>
            <coordinates>-0.18806,39.78261
            -0.18566,39.7867669219382
            -0.19046,39.7867669219382
            -0.18806,39.78261</coordinates>
            </LinearRing>
        </outerBoundaryIs>
        </Polygon>
    </MultiGeometry>
</Placemark>

</Document></kml>

1 个答案:

答案 0 :(得分:3)

如果您想订购一条线或多边形,可以使用&lt; gx:drawOrder&gt;元件。

具有更高&lt; gx:drawOrder&gt;的功能值绘制在具有较低值的值之上,例如,如果对A使用drawOrder为2,对B使用1则绘制A,则在B顶部绘制A.换句话说,首先绘制具有较低drawOrder值的要素。 / p>

不要忘记将 xmlns:gx =“http://www.google.com/kml/ext/2.2”声明添加到kml标记,并注意文档说明了仅适用于LineStrings,但它也适用于多边形和线性环。


    <?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">
     ...
      <Placemark>
        <name>A</name>
        <MultiGeometry>   
            <Point>
                <coordinates>-0.18806,39.78366</coordinates>
            </Point>
            <Polygon>
                <gx:drawOrder>2</gx:drawOrder>
                ...
            </Polygon>
         </MultiGeometry>
      </Placemark>

      <Placemark>
        <name>B</name>
        <MultiGeometry>
            <Point>
                <coordinates>-0.18806,39.78501</coordinates>
            </Point>
            <Polygon>
                <gx:drawOrder>1</gx:drawOrder>
                ...
            </Polygon>
         </MultiGeometry>
      </Placemark>

参考:https://developers.google.com/kml/documentation/kmlreference#gxdraworder