Google Earth KML - Trying to animate an icon - kml

I am trying to animate three different icons at once. I don't think a tour supports multiple items in one tour, so I'm trying to animate an icon. I tried using TimeSpan on each icon, most are only 1 second in duration, but they don't ever disappear.
Any idea how to make the icon smoothly move from one location to the next?
I tried setting the span from one time tic to the next and changing the Placemark id, but none of the placemarks disappear as time progresses.
<Placemark id="I11">
<TimeSpan>
<begin>2022-09-28T19:55:31Z</begin>
<end>2022-09-28T19:55:41Z</end>
</TimeSpan>
<styleUrl>#greencar-icon1</styleUrl>
<Point><coordinates>-121.890428,37.32745,0</coordinates></Point>
</Placemark>
<Placemark id="I64">
<TimeSpan>
<begin>2022-09-28T19:55:41Z</begin>
<end>2022-09-28T19:56:34Z</end>
</TimeSpan>
<styleUrl>#greencar-icon1</styleUrl>
<Point><coordinates>-121.890450,37.32739,0</coordinates></Point>
</Placemark>
<Placemark id="I66">
<TimeSpan>
<begin>2022-09-28T19:56:34Z</begin>
<end>2022-09-28T19:56:36Z</end>
</TimeSpan>
<styleUrl>#greencar-icon1</styleUrl>
<Point><coordinates>-121.890459,37.32729,0</coordinates></Point>
</Placemark>
<Placemark id="I67">
<TimeSpan>
<begin>2022-09-28T19:56:36Z</begin>
<end>2022-09-28T19:56:37Z</end>
</TimeSpan>
<styleUrl>#greencar-icon1</styleUrl>
<Point><coordinates>-121.890447,37.32722,0</coordinates></Point>
</Placemark>
<Placemark id="I68">
<TimeSpan>
<begin>2022-09-28T19:56:37Z</begin>
<end>2022-09-28T19:56:38Z</end>
</TimeSpan>
<styleUrl>#greencar-icon1</styleUrl>
<Point><coordinates>-121.890433,37.32715,0</coordinates></Point>
</Placemark>

Related

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
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>

Can Draw Order of Polygons Be Controlled in KML?

I have adjacent polygons (clampToGround) where a portion of the boundaries overlap. I would like to be able to control which one appears on top. The only method I've found to work thus far is to list the polygon placemarks in stack order (last on list appears on top). However, I'd like to organize the placemarks based on other logic and would like a coding method to specify which polygon is on top.
Note, I've also tried using relativeToGround and small elevation differences, but that leads to potions of the polygons fill to disappear beneath the topography.
You can specify <gx:drawOrder> element (which is a Google Earth KML extension) to order polygons as well as lines and rings in your KML.
Note the documentation (see below) only specifies LineStrings but also works for Lines, LinearRings, and Polygons. Anywhere "LineStrings" is mentioned below just replace it with Lines, Rings, and Polygons. The drawOrder support for Polygons is undocumented but was reported as an issue.
KML Documentation:
<gx:drawOrder>
"An integer value that specifies the order for drawing multiple line
strings. LineStrings drawn first may be partially or fully obscured by LineStrings with a later (or higher) draw order. This element may be required in
conjunction with the <gx:outerColor> and <gx:outerWidth> elements in
<LineStyle> when dual-colored lines cross each other."
Note this will only work in clients that support the Google Earth KML extensions.
In example below, the Red polygon is drawn over the blue polygon. To make the blue polygon draw over the red one change its drawOrder value to a higher number.
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2">
<Document>
<Placemark>
<name>Red Polygon</name>
<description>gx:drawOrder=3</description>
<Style>
<LineStyle>
<color>ff000000</color>
</LineStyle>
<PolyStyle>
<color>ff0000ff</color>
</PolyStyle>
</Style>
<Polygon>
<gx:drawOrder>3</gx:drawOrder>
<tessellate>1</tessellate>
<outerBoundaryIs>
<LinearRing>
<coordinates>
14.456906,37.345497,0 14.949769,37.346531,0
14.960918,37.987563,0 14.45089,37.987521,0
14.456906,37.3455,0
</coordinates>
</LinearRing>
</outerBoundaryIs>
</Polygon>
</Placemark>
<Placemark>
<name>Blue Polygon</name>
<description>gx:drawOrder=2</description>
<Style>
<LineStyle>
<color>ff000000</color>
</LineStyle>
<PolyStyle>
<color>ffff0000</color>
</PolyStyle>
</Style>
<Polygon>
<gx:drawOrder>2</gx:drawOrder>
<tessellate>1</tessellate>
<outerBoundaryIs>
<LinearRing>
<coordinates>
14.83626,38.016863,0 14.835535,37.645589,0
15.47025,37.589266,0 15.470457,38.019158,0
14.83626,38.016862,0
</coordinates>
</LinearRing>
</outerBoundaryIs>
</Polygon>
</Placemark>
</Document>
</kml>

Google Earth How to animate KML placemarks smoothly

I have some radar data to display with the Google Earth plugin. Generally, it is some ground objects with coordinates and a timestamp. I followed the instructions in https://developers.google.com/kml/documentation/time, tried both timestamp and timespan and it works fine. But the displaying effects are not satisfying.
For the timestamp solution, the placemarks just flash briefly at exactly the time indicated by "" tags. And when I pressed play button, nothing shows up on the map.
Code sample:
<Folder>
<name>Vehicles</name>
<description>Timeline information of vehicles</description>
<Placemark>
<name>2</name>
<description>(-84.114231,39.785436,-0.000216),V(13.411216,37.555181) at 0.00s</description>
<TimeStamp>
<when>2012-09-19T08:00:00Z</when>
</TimeStamp>
<styleUrl>#vehicleStyle</styleUrl>
<Point>
<coordinates>-84.114231,39.785436,-0.000216</coordinates>
</Point>
</Placemark>
<Placemark>
<name>910</name>
<description>(-84.110335,39.788438,-0.000024),V(0.000000,0.000000) at 0.80s</description>
<TimeStamp>
<when>2012-09-19T08:00:30Z</when>
</TimeStamp>
<styleUrl>#vehicleStyle</styleUrl>
<Point>
<coordinates>-84.110335,39.788438,-0.000024</coordinates>
</Point>
</Placemark>
<Placemark>
<name>2</name>
<description>(-84.114133,39.785494,-0.000285),V(13.411216,37.555118) at 0.80s</description>
<TimeStamp>
<when>2012-09-19T08:00:30Z</when>
</TimeStamp>
<styleUrl>#vehicleStyle</styleUrl>
<Point>
<coordinates>-84.114133,39.785494,-0.000285</coordinates>
</Point>
</Placemark>
<Placemark>
<name>910</name>
<description>(-84.110307,39.788410,-0.000046),V(3.499966,307.390012) at 1.60s</description>
<TimeStamp>
<when>2012-09-19T08:01:00Z</when>
</TimeStamp>
<styleUrl>#vehicleStyle</styleUrl>
<Point>
<coordinates>-84.110307,39.788410,-0.000046</coordinates>
</Point>
</Placemark>
</Folder>
...
For the timespan case, the animation is OK but there is always a tail followed by each object: the placemarks in previous frames do not disappear immediately at the beginning of the new time span.
Code sample:
...
<Folder>
<name>Vehicles</name>
<description>Timeline information of vehicles</description>
<Placemark>
<name>2</name>
<description>(-84.114231,39.785436,-0.000216),V(13.411216,37.555181) at 0.00s</description>
<TimeSpan>
<begin>2012-09-19T08:00:00Z</begin>
<end>2012-09-19T08:00:10Z</end>
</TimeSpan>
<styleUrl>#vehicleStyle</styleUrl>
<Point>
<coordinates>-84.114231,39.785436,-0.000216</coordinates>
</Point>
</Placemark>
<Placemark>
<name>910</name>
<description>(-84.110335,39.788438,-0.000024),V(0.000000,0.000000) at 0.80s</description>
<TimeSpan>
<begin>2012-09-19T08:00:10Z</begin>
<end>2012-09-19T08:00:20Z</end>
</TimeSpan>
<styleUrl>#vehicleStyle</styleUrl>
<Point>
<coordinates>-84.110335,39.788438,-0.000024</coordinates>
</Point>
</Placemark>
<Placemark>
<name>2</name>
<description>(-84.114133,39.785494,-0.000285),V(13.411216,37.555118) at 0.80s</description>
<TimeSpan>
<begin>2012-09-19T08:00:10Z</begin>
<end>2012-09-19T08:00:20Z</end>
</TimeSpan>
<styleUrl>#vehicleStyle</styleUrl>
<Point>
<coordinates>-84.114133,39.785494,-0.000285</coordinates>
</Point>
</Placemark>
<Placemark>
<name>910</name>
<description>(-84.110307,39.788410,-0.000046),V(3.499966,307.390012) at 1.60s</description>
<TimeSpan>
<begin>2012-09-19T08:00:20Z</begin>
<end>2012-09-19T08:00:30Z</end>
</TimeSpan>
<styleUrl>#vehicleStyle</styleUrl>
<Point>
<coordinates>-84.110307,39.788410,-0.000046</coordinates>
</Point>
</Placemark>
</Folder>
...
So is there any solution to make the placemarks animate continuously? Thanks.
P.S. Track is not considered, because tracking information between data points are not available for now.
If I understand what you are asking then you could do this by simply toggling the style of the placemarks using the JavaScript api.
To do this you could simply create a style in your Kml document such as.
<Style id="vehicleStyleHighighted">
<IconStyle>
<color>ff00ff00</color>
<colorMode>random</colorMode>
<scale>1.5</scale>
<Icon>
<href>http://maps.google.com/mapfiles/kml/pal3/icon21.png</href>
</Icon>
</IconStyle>
</Style>
You can then use the method setStyleUrl() along with a timer to set each placemark's style. I.E. You would toggle each placemarks style between #vehicleStyleHighighted and '#vehicleStyleHighighted.
If you wanted more than a simple 'on/off' animation then you can define more than two animation states using this method and then simply apply them as required.

Animating a line in Google Earth using kml

I am pretty accomplished at using the animated update function of google earth and am using it to move models around. What I would really like to do is to be able to animate a line (eg up and down) in Google Earth but am finding this tricky.
I have the longitude and latitude of the line at the start. For example line coordinates are:
-88,17,100 -88.20270841086835,17.21899813162266,100
I then want to raise one end of this line up to an altitude of 500 over a period of 5 seconds.
I've drawn the line using LineString:
<Placemark id="path1">
<name>Untitled Path man</name>
<LineString>
<tessellate>1</tessellate>
<coordinates>
-88.,17,100 -88.20270841086835,17.21899813162266,100
</coordinates>
</LineString>
</Placemark>
But Im now lost as to how to use <gx:AnimatedUpdate> to move one end up from 100 to 500.
Im sure its easy - can someone point me in the right direction??
The trick is to update the LineString element (with an id on that) rather than the Placemark.
Here's a working KML example tour that animates a line changing from a relative altitude of 100 to 500m.
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2">
<Document>
<name>gx:AnimatedUpdate example</name>
<open>1</open>
<LookAt>
<longitude>-88.1351880996469</longitude>
<latitude>17.09943637744042</latitude>
<altitude>0</altitude>
<heading>49.91874373078863</heading>
<tilt>84.43764019949967</tilt>
<range>1929.311316966288</range>
<gx:altitudeMode>relativeToSeaFloor</gx:altitudeMode>
</LookAt>
<Placemark>
<name>Untitled Path man</name>
<LineString id="path1">
<tessellate>1</tessellate>
<altitudeMode>relativeToGround</altitudeMode>
<coordinates>
-88,17,100 -88.20270841086835,17.21899813162266,100
</coordinates>
</LineString>
</Placemark>
<gx:Tour>
<name>Play me!</name>
<gx:Playlist>
<gx:AnimatedUpdate>
<gx:duration>5</gx:duration>
<Update>
<targetHref/> <!-- Left empty to refer to the current file -->
<Change>
<LineString targetId="path1">
<coordinates>
-88,17,100 -88.20270841086835,17.21899813162266,500
</coordinates>
</LineString>
</Change>
</Update>
</gx:AnimatedUpdate>
<!-- Wait for the animation to complete (see the touring
tutorial for an explanation of how AnimatedUpdate's
duration isn't enough to guarantee this). -->
<gx:Wait>
<gx:duration>5.0</gx:duration>
</gx:Wait>
</gx:Playlist>
</gx:Tour>
</Document>
</kml>
For details see https://developers.google.com/kml/documentation/touring#tourtimelines

Getting lines to work on Google Earth

So I've been sifting through GE's documentation, and found how to do LineStyle and LineString to style and display a line, but in practice I cannot actually make it work. Here's my KML:
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2"><Document><Style id="thisStyle">
<LineStyle>
<color>500078F0</color>
<colorMode>Normal</colorMode>
<width>5</width>
</LineStyle>
</Style>
<Placemark>
<name>502-2012-11-19 05:27:03</name>
<description>Speed:0</description>
<Point>
<coordinates>-76.0513,42.0894,247</coordinates>
</Point>
</Placemark>
<Placemark>
<name>502-2012-11-19 05:26:46</name>
<description>Speed:0</description>
<Point>
<coordinates>-76.0517,42.0886,287</coordinates>
</Point>
</Placemark>
....
<Placemark>
<name>525-2012-11-19 04:38:25</name>
<description>Speed:0</description>
<Point>
<coordinates>-76.0512,42.0894,178</coordinates>
</Point>
</Placemark>
<styleUrl>#thisStyle</styleUrl>
<LineString>
<tessellate>1</tessellate>
<altitudeMode>clampToGround</altitudeMode>
<coordinates>
-76.0513,42.0894,247
-76.0517,42.0886,287
....
-76.0512,42.0894,178
</coordinates></LineString></Document></kml>
Note: The above places where "..." appears there are about 50 more coordinate sets, I removed them for the sake of brevity, but since all coordinates are produced by a script if one works I know they all will. Can anyone nudge me in the right direction as to why my placemarks all show up, but no lines?
A LineString element is only valid inside a Placemark (or a MultiGeometry inside a Placemark):
<Placemark>
<LineString>
<tessellate>1</tessellate>
<altitudeMode>clampToGround</altitudeMode>
<coordinates>
-76.0513,42.0894,247
-76.0517,42.0886,287
-76.0512,42.0894,178
</coordinates>
</LineString>
</Placemark>
Example on Google Maps with your KML
Example on Google Maps with a Placemark containing the Linestring
You must either inline Style in the Placemark or reference the style in the Placemark using styleUrl element.
The last Placemark in your example needs to be rewritten like this:
<Placemark>
<name>525-2012-11-19 04:38:25</name>
<description>Speed:0</description>
<styleUrl>#thisStyle</styleUrl>
<LineString>
<tessellate>1</tessellate>
<altitudeMode>clampToGround</altitudeMode>
<coordinates>
-76.0513,42.0894,247
-76.0517,42.0886,287
...
-76.0512,42.0894,178
</coordinates>
</LineString>
</Placemark>
If your KML doesn't view correctly then it usually helps to validate the KML. You can use the KML Validator.

Resources