Search code examples
kmlgoogle-earth

Add Lines To Google Earth Using KML


So, basically, I'm trying to figure out a way that I can draw lines (say, representing the flight path of an RC plane or something) onto Google Earth using KML. Here's the kicker though: I want to give it an initial location, and then check somewhere to see where to continue drawing the line to, draw the line, and leave it be. Once it's done, I could then move it around.

Ex:

  1. Starts at a point A in google Earth
  2. Checks File XYZ.kml on //someserver
  3. XYZ.kml has updated coordinates to draw to
  4. Google Earth pulls in those coordinates and extends the line
  5. Repeat 2->4 until complete
  6. View completed flight path from 3rd person.

Does anyone have any ideas on how to do this? It seems like it can change the location of a model or something in this fashion, but you would have to watch it first person. I haven't been able to figure out how to get this particular functionality to come out right.


Solution

  • You have a few ways of doing this, here is just 2.

    1. Create a LineString via a networkLink and then use the Update feature to update your LineString (ie replace with new version)
    2. Create a LineString and then use .getCoordinates().pushLatLngAlt() to build upon it.

    Edit: Sorry, as pointed out in comments, Option 2 is for GE Plug-in, not standalone version

    See this SO question for some help on using option #1

    See this SO question for more info on option #2