分享地标描述

Share a placemark description

我创建了一个地质单位地图。每个地质单元由多个地标多边形组成。我目前在组成地质单元的每个地标中重复相同的地质单元描述,以获得我想要的功能(单击多边形并获取描述)。

有没有办法在 KML 文件中包含一次地质单元描述并在多个多边形上使用它?

这是我目前拥有的示例:

<?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">
<Document>
    <name>Geologic Units</name>
    <open>1</open>
    <Style id="style22">
        <LineStyle>
            <color>40000000</color>
        </LineStyle>
        <PolyStyle>
            <color>996ca66c</color>
        </PolyStyle>
    </Style>
    <Folder>
        <name>Cokeville Formation (Lower Cretaceous)</name>
        <Placemark>
            <name>Cokeville Formation</name>
            <description><![CDATA[<p>UNITSYMBOL: Kc</p><p>UNITNAME: Cokeville Formation</p><p>AGE: Lower Cretaceous</p><p>Description: Interbedded dark-gray, carbonaceous, shaly mudstone and siltstone, tan-weathering sandstone, and gray to tan limestone and coquina containing gastropod (Pyrgulifera) and pelecypod fauna. hickness about 650 m. Mapped only along southeastern edge of map area</p>]]></description>
            <styleUrl>#style22</styleUrl>
            <Polygon>
                <outerBoundaryIs>
                    <LinearRing>
                        <tessellate>1</tessellate>
                        <coordinates>
                            -111.001621832,41.6548237803,0 -111.000744207,41.6560784513,0 -111.00074419,41.6548059965,0 -111.001123716,41.6547959594,0 -111.001621832,41.6548237803,0 
                        </coordinates>
                    </LinearRing>
                </outerBoundaryIs>
            </Polygon>
        </Placemark>
        <Placemark>
            <name>Cokeville Formation</name>
            <description><![CDATA[<p>UNITSYMBOL: Kc</p><p>UNITNAME: Cokeville Formation</p><p>AGE: Lower Cretaceous</p><p>Description: Interbedded dark-gray, carbonaceous, shaly mudstone and siltstone, tan-weathering sandstone, and gray to tan limestone and coquina containing gastropod (Pyrgulifera) and pelecypod fauna. hickness about 650 m. Mapped only along southeastern edge of map area</p>]]></description>
            <styleUrl>#style22</styleUrl>
            <Polygon>
                <outerBoundaryIs>
                    <LinearRing>
                        <tessellate>1</tessellate>
                        <coordinates>
                            -111.010074925,41.6544088836,0 -111.009817106,41.6540759648,0 -111.009537791,41.6538429717,0 -111.009365835,41.6535267043,0 -111.009150955,41.6532271007,0 -111.008914576,41.653010725,0 -111.008549317,41.6527943596,0 -111.00861367,41.6521452029,0 -111.008506241,41.6516790986,0 -111.008466501,41.6515573391,0 -111.009350608,41.6513600036,0 -111.01081154,41.6510769006,0 -111.011498939,41.6510102244,0 -111.011406521,41.6517787096,0 -111.011019912,41.6519285808,0 -111.010590221,41.6523613799,0 -111.01028951,41.6528275229,0 -111.010246703,41.6535765651,0 -111.010160817,41.6540093659,0 -111.010074925,41.6544088836,0 
                        </coordinates>
                    </LinearRing>
                </outerBoundaryIs>
            </Polygon>
        </Placemark>
    </Folder>
</Document>
</kml>

我想出了如何使用 BalloonStyle Text 来做到这一点。这是唯一的方法还是有 another/better 方法?

<?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">
<Document>
    <name>Geologic Units</name>
    <open>1</open>
    <Style id="style22">
        <BalloonStyle>
            <text><![CDATA[<p>UNITSYMBOL: Kc</p><p>UNITNAME: Cokeville Formation</p><p>AGE: Lower Cretaceous</p><p>Description: Interbedded dark-gray, carbonaceous, shaly mudstone and siltstone, tan-weathering sandstone, and gray to tan limestone and coquina containing gastropod (Pyrgulifera) and pelecypod fauna. hickness about 650 m. Mapped only along southeastern edge of map area</p>]]></text>
        </BalloonStyle>
        <LineStyle>
            <color>40000000</color>
        </LineStyle>
        <PolyStyle>
            <color>996ca66c</color>
        </PolyStyle>
    </Style>
    <Folder>
        <name>Cokeville Formation (Lower Cretaceous)</name>
        <Placemark>
            <name>Cokeville Formation</name>
            <styleUrl>#style22</styleUrl>
            <Polygon>
                <outerBoundaryIs>
                    <LinearRing>
                        <tessellate>1</tessellate>
                        <coordinates>
                            -111.001621832,41.6548237803,0 -111.000744207,41.6560784513,0 -111.00074419,41.6548059965,0 -111.001123716,41.6547959594,0 -111.001621832,41.6548237803,0 
                        </coordinates>
                    </LinearRing>
                </outerBoundaryIs>
            </Polygon>
        </Placemark>
        <Placemark>
            <name>Cokeville Formation</name>
            <styleUrl>#style22</styleUrl>
            <Polygon>
                <outerBoundaryIs>
                    <LinearRing>
                        <tessellate>1</tessellate>
                        <coordinates>
                            -111.010074925,41.6544088836,0 -111.009817106,41.6540759648,0 -111.009537791,41.6538429717,0 -111.009365835,41.6535267043,0 -111.009150955,41.6532271007,0 -111.008914576,41.653010725,0 -111.008549317,41.6527943596,0 -111.00861367,41.6521452029,0 -111.008506241,41.6516790986,0 -111.008466501,41.6515573391,0 -111.009350608,41.6513600036,0 -111.01081154,41.6510769006,0 -111.011498939,41.6510102244,0 -111.011406521,41.6517787096,0 -111.011019912,41.6519285808,0 -111.010590221,41.6523613799,0 -111.01028951,41.6528275229,0 -111.010246703,41.6535765651,0 -111.010160817,41.6540093659,0 -111.010074925,41.6544088836,0 
                        </coordinates>
                    </LinearRing>
                </outerBoundaryIs>
            </Polygon>
        </Placemark>
    </Folder>
</Document>
</kml>

对于您的 use-case,与包含气球模板的 BalloonStyle 共享样式可能是最好的方法。您可以更进一步,在 BalloonStyle 模板中包含占位符变量,这些变量会被每个 Placemark 中的 ExtendedData 部分的内容替换。也就是说,另一种方法是使用 MultiGeometry 将相关的多边形组合成一个地标,但前提是您希望组合的多边形在地图上充当一个多边形。