Search code examples
datetimesliderkmlgoogle-earth

Google Earth - Set Time Slider to Maximum Values


I have created a Google Earth map with a Master KML file that links to 500+ individual KMLs. I have included a time slider so that the user can filter on start and end dates.

Currently when GE first opens the time slider is set to individual day (not today's date). How can I code within the KML file so that the time slider starts on the earliest data and finishes on the latest?

Example:

Event 1 - Start: 01/06/2015 End 01/07/2015

Event 2 - Start: 12/04/2015 End 14/06/2015

Event 3 - Start: 20/06/2015 End 01/09/2015

These events would be within the individual KML files linked together by a master and upon opening the master file I would like the time slider to display everything between 12/04/2015 and 10/09/2015.

If this is not possible another solution would be to show everything that is 'live' on the day the user accesses the map.


Solution

  • In your master KML file, you need to add <gx:TimeSpan> to a View or Camera element in the top-level container. The gx:TimeSpan controls the visibility of time-stamped Features in a user-defined view.

    To display everything between 10/09/2015 and 12/04/2015 by default, the structure of KML should look like this.

    <kml xmlns="http://www.opengis.net/kml/2.2"
     xmlns:gx="http://www.google.com/kml/ext/2.2">
      <Document>
        <LookAt>
          <gx:TimeSpan>
            <begin>2015-10-09</begin>
            <end>2015-12-04</end>
          </gx:TimeSpan>
          <longitude>xx</longitude>
          <latitude>xx</latitude>
          <range>xx</range>
        </LookAt>
    ...
    </Document>
    </kml>
    

    Note if you add a <View> then you must also define the location view (including range) otherwise it defaults to a view over latitude 0 and longitude 0. Find the best view then click snapshot view and copy of the view elements to your master KML file.

    For more details see gx:TimeSpan and View reference documentation.