Search code examples
kmlgoogle-earth

KML icons on every waypoint


I want to export telephone poles and cables out of our database into a KML file for Google Earth.

For every node we have an array of poles, the cables are always connected towards the next pole in the array.

An export making simple paths seems to be easy enough. But these paths just show a path, they don't show every waypoint (telephone pole).

This is an example in Google Maps what I want to achieve in .kml screenshot from Google Maps


Solution

  • If you want paths and points for each of the poles (aka waypoints) then you need your KML to include not only the line segments separate points for each of the positions of the poles.

    Your KML will need to be structured like this where poleSyle will have an IconStyle with the icon you want for the points and lineStyle will be a thick green line

    <kml xmlns="http://www.opengis.net/kml/2.2">
      <Document>
        <Style id="poleStyle">
           ...
        </Style>
        <Style id="lineStyle">
           ...
        </Style>
        <Placemark>
            <styleUrl>#lineStyle</styleUrl>
            <LineString>
                <coordinates>...</coordinates>
            </LineString>
        </Placemark>
        <Placemark>
            <name>pole1</name>
            <description>address pole1</description>
            <styleUrl>#poleStyle</styleUrl>
            <Point>
                <coordinates>...</coordinates>
            </Point>
        </Placemark>
        ...
      </Document>
    </kml>
    

    If you don't want or need a unique name or description for every point then you can combine the points in a single Placemark inside a MultiGeometry like this:

    <Placemark>
      <styleUrl>#poleStyle</styleUrl>
      <MultiGeometry>
          <Point>
                <coordinates>...</coordinates>
          </Point>
          <Point>
                <coordinates>...</coordinates>
          </Point>
      </MultiGeometry>
    </Placemark>