Search code examples
kmlgoogle-earth

Multiple icons in one KML Placemark


I have some symbols that I want to add to a KML file (for Google Earth). However, my symbols consist of multiple icons overlayed on top of each other. For other maps that I use I simply draw the icons on top of each other and control the selection/right click actions so that the user only sees it as one object, but in Google Earth if I add each overlayed icon as a separate placemark the user sees multiple objects when they click on it. Is there a way to add a single placemark in kml with multiple icons?

I wanted to do something like this:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:ns2="http://www.w3.org/2005/Atom" xmlns:ns3="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0">
    <Document>
        <name>kmlTest</name>
        <open>true</open>
        <description>description</description>
        <StyleMap id="Symbol0Map">
            <Pair id="Symbol0MapPairNormal">
                <key>normal</key>
                <Style id="Symbol0normal">
                    <IconStyle id="Symbol0iconStyle">
                        <scale>1.0</scale>
                        <heading>0.0</heading>
                        <Icon>
                            <href>files/images/GenericGround_0.png</href>
                        </Icon>
                        <Icon>
                            <href>files/images/eqp_2.png</href>
                        </Icon>
                    </IconStyle>
                    <LabelStyle id="Symbol0labelStyle">
                        <color>FF00FFFF</color>
                        <colorMode>normal</colorMode>
                        <scale>0.0</scale>
                    </LabelStyle>
                </Style>
            </Pair>
            <Pair id="Symbol0MapPairHighlight">
                <key>highlight</key>
                <!-- similar to above -->
            </Pair>
        </StyleMap>
        <Folder>
            <name>My Layers</name>
            <visibility>true</visibility>
            <open>true</open>
            <Folder>
                <name>My Layer</name>
                <visibility>true</visibility>
                <open>false</open>
                <Folder>
                    <name>Symbols</name>
                    <visibility>true</visibility>
                    <open>false</open>
                    <Placemark id="Placemark0">
                        <visibility>true</visibility>
                        <open>false</open>
                        <description>Platform</description>
                        <styleUrl>#Symbol0Map</styleUrl>
                        <Point>
                            <coordinates>-123.1569,38.5962,0.0</coordinates>
                        </Point>
                    </Placemark>
                </Folder>
            </Folder>
        </Folder>
    </Document>
</kml>

where I just have multiple <Icon> tags (or multiple <IconStyle> tags). However, looking at the schema this is not valid and I tried it anyways and it only picks the last one.

Is this even possible or will I need to dynamically create rolled up icons in code and include those in my .kmz file?


Solution

  • A KML placemark can only have one icon image. You will need to combine (roll up) your icons into a single image and then apply that to the placemark.