3

I have a Multigeometry in KML but when I assign a name to the placemark, both points in my placemark have the same name. Is there any possibility to have different names for points in any placemark?

Here is an example of my code:

<Placemark>
    <name>TEST</name>
<description></description>
    <visibility>1</visibility>
    <tessellate>1</tessellate>
    <styleUrl>#StyTEST</styleUrl>
<MultiGeometry>
    <Point>
        <coordinates>-3.6655,40.4364</coordinates>
    </Point>
    <Point>
        <coordinates>-3.6726,40.4308</coordinates>
    </Point>
    <LineString>
        <tessellate>1</tessellate>
            <coordinates>
                -3.6655,40.4364
                -3.6726,40.4308
            </coordinates>
    </LineString>
</MultiGeometry>
</Placemark>

3 Answers3

5

KML does not allow multiple names/labels for geometries within a single Feature even using a Multi-geometry. If you have multiple points in a MultiGeometry then the same name of the feature will appear over all points. One Placemark point == one label so if you want different labels on map using KML then must have two Placemarks one at each end of the line.

Simple solution is to structure your KML with multiple Placemarks which you can hide in a Document/Folder using the checkHideChildren listItemType. Then it appears in the Places panel in Google Earth as a single "feature" but multiple name labels display on the map as you want. The trick here is that the Folder name appears in the Places Panel and the Placemark names appear as labels on the map.

The following example illustrates such a KML file.

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
    <Document>            
        <name>Example</name>
        <open>1</open>

        <Style id="hide">
            <ListStyle>
                <listItemType>checkHideChildren</listItemType>
            </ListStyle>
        </Style>

        <Folder>
          <name>TEST1</name>
          <styleUrl>#hide</styleUrl>

          <Placemark>
            <name>TEST1</name>
            <MultiGeometry>
                <Point>
                    <coordinates>-3.6726,40.4308</coordinates>
                </Point>
                <LineString>
                    <tessellate>1</tessellate>
                    <coordinates>
                     -3.6655,40.4364
                     -3.6726,40.4308
                    </coordinates>
                </LineString>
            </MultiGeometry>
          </Placemark>

          <Placemark>
            <name>TEST2</name>
            <Point>
                <coordinates>-3.6655,40.4364</coordinates>
            </Point>
          </Placemark>

        </Folder>
    </Document>
</kml>
CodeMonkey
  • 22,825
  • 4
  • 35
  • 75
3

A Placemark has only one name. If you need to have each Point have its own name, they need to be separate Placemarks.

From the referenced documentation:

<Placemark>
Syntax

<Placemark id="ID">
<!-- inherited from Feature element -->
<name>...</name> <!-- string -->
<visibility>1</visibility> <!-- boolean -->
<open>0</open> <!-- boolean -->
<atom:author>...<atom:author> <!-- xmlns:atom -->
<atom:link href=" "/> <!-- xmlns:atom -->
<address>...</address> <!-- string -->
<xal:AddressDetails>...</xal:AddressDetails> <!-- xmlns:xal -->
<phoneNumber>...</phoneNumber> <!-- string -->
<Snippet maxLines="2">...</Snippet> <!-- string -->
<description>...</description> <!-- string -->
<AbstractView>...</AbstractView> <!-- Camera or LookAt -->
<TimePrimitive>...</TimePrimitive>
<styleUrl>...</styleUrl> <!-- anyURI -->
<StyleSelector>...</StyleSelector>
<Region>...</Region>
<Metadata>...</Metadata> <!-- deprecated in KML 2.2 -->
<ExtendedData>...</ExtendedData> <!-- new in KML 2.2 -->

<!-- specific to Placemark element -->
<Geometry>...</Geometry>
</Placemark>

geocodezip
  • 158,664
  • 13
  • 220
  • 245
-1

A user can't see 40,000 placemarks at once. Take a look at some of the provided Earth Gallery pages like FlightWise (http://mw1.google.com/mw-weather/flightwise/pointer.kml) to see how they use NetworkLink, Region, and Lod tags to split up their data set and present the correct data to the correct view at the correct time.

user1089933
  • 87
  • 1
  • 2