2

I am brand new to KML. I would like to ask if it is possible to have both ExtendedData and Description for the same placemark and have both appear in Google Earth Interface? I am asking because when I add a description to my placemark all the ExtendedData disappears in Google Earth and gets replaced by the newly entered description, although when I paste the placemark to Notepad the ExtendedData is still there.

Is there any way these two can both exist and appear at the same time?

2

Google Earth displays the extended data in a formatted HTML table if no description exists. If a feature has a description then Google Earth shows that description in the popup balloon regardless of whether it has extended data or not.

If you want extended data and description to appear at the same time then you can use a BalloonStyle as a template that substitutes the description and extended data elements by name. You can also include the extended data elements by name directly in the description but a single BalloonStyle used by multiple placemarks is easier to change and the KML file size is smaller.

Example:

<kml xmlns="http://www.opengis.net/kml/2.2">
  <Document>
    <name>Entity-Replacement</name>
    <Style id="style">
      <BalloonStyle>
        <text>
          <![CDATA[
          <B>Name: $[name]</B><br>
          $[description]<P>
          city district: $[city_district]<br/>
          population $[population]         
            ]]>
        </text>
      </BalloonStyle>
    </Style>
    <!-- Shared style sample
      Many Placemarks can use the same balloon template
    -->
    <Placemark>
      <name>Club house</name>
      <description>this is an example</description>
      <styleUrl>#style</styleUrl>
      <ExtendedData>
        <Data name="city_district">
          <value>123</value>
        </Data>
        <Data name="population">
          <value>40000</value>
        </Data>
      </ExtendedData>
      <Point>
        <coordinates>-111.956,33.5043</coordinates>
      </Point>
    </Placemark>
  </Document>
</kml>

You can suppress the description balloon from appearing when the user clicks on it if the balloon style has displayMode with "hide" value. In Google Earth, clicking the List View icon for a Placemark whose balloon's <displayMode> value is hide causes Google Earth to fly to the Placemark.

Here is tutorial using the BalloonStyle Element as a Template
https://developers.google.com/kml/documentation/extendeddata#balloonStyle

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.