I notice certain behaviour using ExtendedData in KML which I feel renders the use of ExtendedData questionable, especially if the trackway crosses itself.
I would like to know if there is a fix or workaround?
GoogleEarth (v7.3.2.5491 (32-bit)) appears to do calculation on the fly to calculate the nearest waypoint to the clicked position. This is a problem if the nearest waypoint by crow-flies distance is further away along the trackway taking time into account. I have an MRE here...
<kml xmlns="http://earth.google.com/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2">
<Document xmlns="http://earth.google.com/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2">
<name>2018-08-27_Mon</name>
<Schema id="schema">
<gx:SimpleArrayField name="gps_coords" type="string">
<displayName>GPS Coords</displayName>
</gx:SimpleArrayField>
<gx:SimpleArrayField name="ping_time" type="string">
<displayName>Ping Time</displayName>
</gx:SimpleArrayField>
</Schema>
<Folder xmlns="http://earth.google.com/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2">
<name>Tracks</name>
<Placemark xmlns="http://earth.google.com/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2">
<name>Trackway</name>
<styleUrl>#my_track</styleUrl>
<gx:Track xmlns="http://earth.google.com/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2">
<altitudeMode>clampToGround</altitudeMode>
<when>1970-01-01T05:02:28Z</when>
<when>1970-01-01T09:04:00Z</when>
<when>1970-01-01T11:06:00Z</when>
<when>1970-01-01T14:59:30Z</when>
<when>1970-01-01T15:02:00Z</when>
<when>1970-01-01T17:03:11Z</when>
<gx:coord>-8.460239 54.253286 0</gx:coord>
<gx:coord>-8.460439 54.256286 0</gx:coord>
<gx:coord>-8.460639 54.259286 0</gx:coord>
<gx:coord>-8.467867 54.262505 0</gx:coord>
<gx:coord>-8.462653 54.256286 0</gx:coord>
<gx:coord>-8.460599 54.250317 0</gx:coord>
<ExtendedData>
<SchemaData schemaUrl="#schema">
<gx:SimpleArrayData name="gps_coords">
<gx:value>No 1. 54.253286 -8.460239</gx:value>
<gx:value>No 2. 54.256286 -8.460439</gx:value>
<gx:value>No 3. 54.259286 -8.460539</gx:value>
<gx:value>No 4. 54.262505 -8.467867</gx:value>
<gx:value>No 5. 54.256286 -8.462653</gx:value>
<gx:value>No 6. 54.250317 -8.460599</gx:value>
</gx:SimpleArrayData>
<gx:SimpleArrayData name="ping_time">
<gx:value>2018-08-27T05:02:28Z</gx:value>
<gx:value>2018-08-27T09:04:00Z</gx:value>
<gx:value>2018-08-27T11:06:00Z</gx:value>
<gx:value>2018-08-27T14:59:30Z</gx:value>
<gx:value>2018-08-27T15:02:00Z</gx:value>
<gx:value>2018-08-27T17:03:11Z</gx:value>
</gx:SimpleArrayData>
</SchemaData>
</ExtendedData>
</gx:Track>
</Placemark>
</Folder>
<Folder>
<Placemark>
<TimeStamp>
<when>1970-01-01T05:02:28Z</when>
</TimeStamp>
<description>Desc No 1. 54.253286 -8.460239</description>
<styleUrl>#waypoint</styleUrl>
<Point>
<coordinates>-8.460239 54.253286 0</coordinates>
</Point>
</Placemark>
<Placemark>
<TimeStamp>
<when>1970-01-01T09:04:00Z</when>
</TimeStamp>
<description>Desc No 2. 54.256286 -8.460439</description>
<styleUrl>#waypoint</styleUrl>
<Point>
<coordinates>-8.460439 54.256286 0</coordinates>
</Point>
</Placemark>
<Placemark>
<TimeStamp>
<when>1970-01-01T11:06:00Z</when>
</TimeStamp>
<description>Desc No 3. 54.259286 -8.460539</description>
<styleUrl>#waypoint</styleUrl>
<Point>
<coordinates>-8.460639 54.259286 0</coordinates>
</Point>
</Placemark>
<Placemark>
<TimeStamp>
<when>1970-01-01T14:59:30Z</when>
</TimeStamp>
<description>Desc No 4. 54.262505 -8.467867</description>
<styleUrl>#waypoint</styleUrl>
<Point>
<coordinates>-8.467867 54.262505 0</coordinates>
</Point>
</Placemark>
<Placemark>
<TimeStamp>
<when>1970-01-01T15:02:00Z</when>
</TimeStamp>
<description>Desc No 5. 54.256286 -8.462653</description>
<styleUrl>#waypoint</styleUrl>
<Point>
<coordinates>-8.462653 54.256286 0</coordinates>
</Point>
</Placemark>
<Placemark>
<TimeStamp>
<when>1970-01-01T17:03:11Z</when>
</TimeStamp>
<description>Desc No 6. 54.250317 -8.460599</description>
<styleUrl>#waypoint</styleUrl>
<Point>
<coordinates>-8.460599 54.250317 0</coordinates>
</Point>
</Placemark>
</Folder>
</Document>
</kml>
Clicking on the trackway midway between #4 and #5 pops up the ExtendedData for #3. Same with #5 and #6 resulting in #1 opening. It kind of makes senses because the trackway is just painted as the straight line between two points and does not have its own geometry. So, I could live with that even though a naive user might expect a precise popup for the intermediate positions. However, if I move the time slider to exclude/disappear points #1, #2, and #3, I would now expect #1, #2, and #3 to be excluded from the calculations. But this is not the case. The same results as above obtain. That is not what I would expect.
In this MRE it is not a problem as such but on a large trackway with several hundred points and the trackway going over and back across itself throughout the day, then such ExtendedData popups are, IMO, ususable.
To work around it, I have created a CDATA description for the each waypoint in the track which is acceptable
Is there a KML workaround for this behaviour or is it just the way GE implements it? Any other suggestions perhaps?
Liam
Google Earth Pro behaves in such a way that when clicking the segment of track past the mid-point gives the metadata for the next waypoint. This is what you are seeing when clicking on a track and seeing metadata for another point.
Also note the KML above does not conform to the KML 2.2 standard. Couple of validation issues.
There should not be any whitespace in the point coordinates. The whitespace should be replaced with a comma (,):
old:
<Point>
<coordinates>-8.460239 54.253286 0</coordinates>
</Point>
new:
<Point>
<coordinates>-8.460239,54.253286,0</coordinates>
</Point>
The namespace should be xmlns="http://www.opengis.net/kml/2.2" rather than the old form of http://earth.google.com/kml/2.2.
Some of the element are out of sequence. KML 2.2 has a strict order of elements (see reference) but Google Earth generally ignores the order of elements. The correct order of elements is as follows:
<Placemark>
<description>...</description>
<TimeStamp>...</TimeStamp>
<styleUrl>...</styleUrl>
<Point>...</Point>
</Placemark>
Related
I'm doing a proof-of-concept map. Goal is half sized labels, with red font, and no icon. I've tried everything, even copy pasting from the google KML reference manuals and many examples posted here. What am I missing? I'm trying to display the map in both Google's "My maps" and also as a called data file at the browser utility gmap4. The test map should show four labels with Google streetmap of Pennsylvania for a baselayer...... Thanks for any help.
<?xml version="1.0" standalone="yes"?>
<kml xmlns="http://earth.google.com/kml/2.2">
<Document>
<Style id="NoIconRedTextHalfSize">
<IconStyle>
<scale>.1</scale>
<Icon>
<href>https://maps.google.com/mapfiles/kml/paddle/grn-stars.png</href>
</Icon>
</IconStyle>
<LabelStyle>
<Color>FF1400FF</Color>
<Scale>.5</Scale>
</LabelStyle>
</Style>
<Folder>
<Placemark>
<name>Hs-4-C.Sonney</name>
<styleUrl>#NoIconRedTextHalfSize</styleUrl>
<Point>
<coordinates>1,1,0</coordinates>
</Point>
</Placemark>
<Placemark>
<name>Hs-5-B.Jozwiak</name>
<styleUrl>#NoIconRedTextHalfSize</styleUrl>
<Point>
<coordinates>1,1,0</coordinates>
</Point>
</Placemark>
<Placemark>
<name>Hs-6-B.Roae</name>
<styleUrl>#NoIconRedTextHalfSize</styleUrl>
<Point>
<coordinates>1,1,0</coordinates>
</Point>
</Placemark>
<Placemark>
<name>Hs-7-M.Longietti</name>
<styleUrl>#NoIconRedTextHalfSize</styleUrl>
<Point>
<coordinates>1,1,0</coordinates>
</Point>
</Placemark>
</Folder>
</Document>
</kml>
The KML syntax includes a number of tags that are not supported by plain Google maps (my map) or by sotfware based on the Google map API. One of the non-supported tags is .
See: https://developers.google.com/maps/documentation/javascript/kmllayer#supported-elements
To make a label with no icon try making a transparent icon.
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.
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
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.
Hello Im writing some KML and when and I create the multigeomtry in the order
PlaceMark A
PlaceMark B
I cant select PlMark A beceause B is bigger, but when I have
PlaceMark B
PlaceMark A
Yes, because I think A is smaller and it was the last in be grapicated, my question is I cant have the Placemarks In order,there are any option in Kml to made selectable all the elements.
Thanks.
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.0">
<Document>
<StyleMap id="StyF1"><Pair><key>normal</key><Style><IconStyle><Icon></Icon></IconStyle><PolyStyle><color>7d0000ff</color></PolyStyle></Style></Pair><Pair><key>highlight</key><Style><IconStyle><Icon></Icon></IconStyle><PolyStyle><color>7aFFFF8C</color></PolyStyle></Style></Pair></StyleMap>
<StyleMap id="StyU1"><Pair><key>normal</key><Style><IconStyle><Icon></Icon></IconStyle><PolyStyle><color>7d0000ff</color></PolyStyle></Style></Pair><Pair><key>highlight</key><Style><IconStyle><Icon></Icon></IconStyle><PolyStyle><color>7aFFFF8C</color></PolyStyle></Style></Pair></StyleMap>
<Placemark>
<name>A</name>
<description>
</description>
<visibility>1</visibility>
<tessellate>1</tessellate>
<styleUrl>#StyU1</styleUrl>
<MultiGeometry>
<Point>
<coordinates>-0.18806,39.78366</coordinates>
</Point>
<Polygon>
<outerBoundaryIs>
<LinearRing>
<coordinates>-0.18806,39.78261
-0.18701,39.7844286533479
-0.18911,39.7844286533479
-0.18806,39.78261</coordinates>
</LinearRing>
</outerBoundaryIs>
</Polygon>
</MultiGeometry>
</Placemark>
<Placemark>
<name>B</name>
<description>
</description>
<visibility>1</visibility>
<tessellate>1</tessellate>
<styleUrl>#StyF1</styleUrl>
<MultiGeometry>
<Point>
<coordinates>-0.18806,39.78501</coordinates>
</Point>
<Polygon>
<outerBoundaryIs>
<LinearRing>
<coordinates>-0.18806,39.78261
-0.18566,39.7867669219382
-0.19046,39.7867669219382
-0.18806,39.78261</coordinates>
</LinearRing>
</outerBoundaryIs>
</Polygon>
</MultiGeometry>
</Placemark>
</Document></kml>
If you want to order one line or polygon over another you can use the <gx:drawOrder> element.
Features with higher <gx:drawOrder> values are drawn on top of those with lower values so for example if you use a drawOrder of 2 for A and 1 for B then A is drawn on top of B. In other words, the features with lower drawOrder values are drawn first.
Don't forget to add the xmlns:gx="http://www.google.com/kml/ext/2.2" declaration to the kml tag and note that the documentation says it only applies to LineStrings but it also applies to Polygons and LinearRings.
<?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">
...
<Placemark>
<name>A</name>
<MultiGeometry>
<Point>
<coordinates>-0.18806,39.78366</coordinates>
</Point>
<Polygon>
<gx:drawOrder>2</gx:drawOrder>
...
</Polygon>
</MultiGeometry>
</Placemark>
<Placemark>
<name>B</name>
<MultiGeometry>
<Point>
<coordinates>-0.18806,39.78501</coordinates>
</Point>
<Polygon>
<gx:drawOrder>1</gx:drawOrder>
...
</Polygon>
</MultiGeometry>
</Placemark>
Reference: https://developers.google.com/kml/documentation/kmlreference#gxdraworder