Search code examples
kmlgoogle-earth

Share a placemark description


I've created a geologic units map. Each geologic unit is composed of multiple placemark polygons. I currently have the same geologic unit description repeated in each placemark composing the geologic unit in order to get the functionality I want (click on the polygon and get a description).

Is there a way to include the geologic unit description once in the KML file and use it on multiple polygons?

Here's an example of what I currently have:

<?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>

Solution

  • I figured out how to do it with BalloonStyle Text. Is this the only way or is there another/better way?

    <?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>