4

I have to lat/lon Points. I want to draw a line segment between the 2 (in kml), but I don't see functionality in Google Earth to do this. LineString is not it. Surely I am missing something.

<?xml version='1.0' encoding='UTF-8'?>
<kml xmlns:ns="http://earth.google.com/kml/2.0">
  <Folder>
    <open>1</open>
    <Placemark>
      <Point>
        <coordinates>-107.980362141, 31.872060174</coordinates>
      </Point>
    </Placemark>
    <Placemark>
      <Point>
        <coordinates>-107.963280345, 31.80230482</coordinates>
      </Point>
    </Placemark>
    <Placemark>
      <LineString>
        <extrude>1</extrude>
        <tessellate>1</tessellate>
        <coordinates>-107.980362141, 31.872060174, 0  -107.963280345, 31.80230482, 0</coordinates>
      </LineString>
    </Placemark>
    <GroundOverlay>
      <Icon>
        <href>redBorder.png</href>
      </Icon>
      <LatLonBox>
        <north>31.82103476</north>
        <south>31.78357488</south>
        <east>-107.91400752</east>
        <west>-108.01255317</west>
      </LatLonBox>
    </GroundOverlay>
  </Folder>
</kml>
  • Why doesn't a LineString using the two points work for you? – Russell at ISC Feb 4 '15 at 16:29
  • Because it doesn't draw a line between the 2 points. What I get is a line segment at each point. – Al Lelopath Feb 4 '15 at 16:30
  • Sounds like you aren't constructing it correctly. Please add a code snippet to your post showing what is not working. – Russell at ISC Feb 4 '15 at 16:32
  • I added some code – Al Lelopath Feb 4 '15 at 16:40
6

From KML LineString help:

coordinates (required) Two or more coordinate tuples, each consisting of floating point values for longitude, latitude, and altitude. The altitude component is optional. Insert a space between tuples. Do not include spaces within a tuple.

Remove the spaces within your coordinates. This works:

    <Placemark>
      <LineString>
        <extrude>1</extrude>
        <tessellate>1</tessellate>
        <coordinates>-107.980362141,31.872060174,0  -107.963280345,31.80230482,0</coordinates>
      </LineString>
    </Placemark>
| improve this answer | |

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.