Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Possible to show all placemarks with Timestamps in Google Earth by default?

I'm looking at creating KML placemarks with Timestamp elements. This itself is fairly easy to do, but I don't like the behavior of Google Earth only showing a small band of time when the KML is initially loaded. I'd like it to show the full span of time (and thus all the placemarks) by default.

Is there any way to do this? I'm not seeing any settings in Google Earth, or anything in the KML documentation for this.

An alternative I'm considering is to basically duplicate each placemark, and have 1 set with Timestamps, and 1 without, in separate folders. The folders would use the radio-button selection feature. I'd like to avoid this if possible, as a KML could potentially have thousands of placemarks, and seems to be a waste to duplicate the nodes.

Here's an example from this source that has KML with placemarks if you'd like to see the behavior I'm speaking of.

Update: The behavior I'm seeing with the time slider not defaulting to the full span of the contained KML placemarks seems to be because the file is loaded via a Network Link to a local file. I'm not sure how to control the behavior of the time slider in this case. I can have the link do a "fly to view on refresh", which sets the time slider correctly, but I don't want to move the camera to a lat/long, as I am refreshing every 4 seconds.

like image 668
Stealth Rabbi Avatar asked Sep 17 '12 12:09

Stealth Rabbi


1 Answers

By default Google Earth shows the full time of the KML. However, a common situation is when multiple KML files are opened/visible with times where Google Earth by default shows the full time range of earliest and latest times in all KML features. Also, loading KML via NetworkLinks does not show the full time range as does opening it directly in Google Earth.

To illustrate first uncheck your saved places to disable other KML with times then load this KML file. You'll notice the timeline showing 1787 through 1959 for its full range. https://developers.google.com/kml/documentation/us_states.kml

If you wanted to pre-define a time range you can explicitly add a Camera or LookAt that constraints the time view. For example to constrain the view to the first 100 years you could add a <gx:TimeSpan> element with a year range to the root-level element in your KML. Remember to include the lat/lon/range elements otherwise the view will default to lat=0, lon=0, range=0.

<?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>
    ....
    <LookAt>
            <gx:TimeSpan>
                    <begin>1787</begin>
                    <end>1887</end>
            </gx:TimeSpan>
            <longitude>-95.71</longitude>
            <latitude>37.09</latitude>
            <range>4119625</range>
            ...
    </LookAt>
    ...
</Document>
</kml>

If you right-mouse click on a Placemark or Folder then select 'Snapshot View' in Google Earth and the timer slider is visible then the time range will be captured in the saved view.

So you can do what you want without duplicating the placemarks with times but by creating a few placemarks only defined with a view constrained by time range. Clicking each of these special placemarks would change the time slider to whatever time range you want to show.

KML features with times retrieved via Networklinks have a different behavior and only a portion of the time range is pre-selected in the time slider. You must add flyToView to the NetworkLink for it to behave same as loading the KML directly.

<NetworkLink>
  <flyToView>1</flyToView>
  <Link>
    <href>...</href>
  </Link>
</NetworkLink>

As a best practice if you include more than one NetworkLink with time-based features in a parent KML file then add a <TimeSpan> element to the NetworkLinks including the full range of time for that collection of features otherwise Google Earth will automatically load the entire file at startup.

<NetworkLink>
  <TimeSpan>
    <begin>1787</begin>
    <end>1887</end>
  </TimeSpan>
  <flyToView>1</flyToView>
  <Link>
    <href>...</href>
  </Link>
</NetworkLink>

References:
https://developers.google.com/kml/documentation/kmlreference#timespan
https://developers.google.com/kml/documentation/kmlreference#gxtimespan

like image 180
CodeMonkey Avatar answered Sep 28 '22 03:09

CodeMonkey