Timestamp/ TimeSpan

81 views
Skip to first unread message

Timmkish

unread,
Dec 4, 2007, 12:59:03 AM12/4/07
to KML Developer Support - Getting Started with KML
I've got a single placemark (in this case a polygon) that I'd like to
change color given a certain time. I don't want to recreate the
object each time I want it to change color. For example: For a 3-D
polygon, on Monday I want it to be blue, Tuesday to be red, Wednesday
orange. How would I go about coding this up? I tried embedding the
Style within the Timespan, but that didn't work. I had previously
defined the 'transRedPoly' and 'transYellowPoly'

<TimeSpan>
<begin>2005-08-21T09:01:00Z</begin>
<styleUrl>#transRedPoly</styleUrl>
<end>2005-09-21T09:01:00Z</end>
</TimeSpan>

<TimeSpan>
<begin>2005-10-21T09:01:00Z</begin>
<styleUrl>#transYellowPoly</styleUrl>
<end>2005-11-21T09:01:00Z</end>
</TimeSpan>

Thanks!

barryhunter [KML Guru]

unread,
Dec 4, 2007, 4:35:54 AM12/4/07
to KML Developer Support - Getting Started with KML
I dont think you have any option but to recreate it each time -
embeding the KML file inside a KMZ will mean it will compress away
pretty well anyway.

As a Tip; put all the placemarks in a single folder - and use a Icon
and hide children style, that way to the outside world (your users) it
can appear as a single placemark in the tree.

You *might* be able to use network links - even pointing to static
generated kml files - that use the Update mechanim to change the
colour of a placemark. So you have a folder of time stamped
networklinks, that when they activate they change the colour of a all
relevent placemarks. However this sounds complicated and even fickle,
so not sure it worth the effort - keep it simple.

Firsk

unread,
Dec 13, 2007, 2:50:25 PM12/13/07
to KML Developer Support - Getting Started with KML
Hi
English is not my native tongue but I will try to explain the
solution.

I've got the same error with TimeSpan tag.
I used the KML 2.1 schema (http://code.google.com/apis/kml/schema/
kml21.xsd).
With xsl shema for KML 2.1, you will see that association of TimeSpann
tag and LookAt tag for the same Placemark is impossible.
The solution : I deleted LookAt tag...and all will be correct.
-----------------------------------------------------------
Below, an example :

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.1">>
<Document id="KML_sample">
<name>sample.kml</name>
<!-- First object & color -->
<Style id="normBleu1">
<IconStyle>
<color>ffffbf00</color>
<scale>0.5</scale>
<Icon>
<href>http://maps.google.com/mapfiles/kml/pal2/icon26.png</href>
</Icon>
<hotSpot x="20" y="2" xunits="pixels" yunits="pixels"/>
</IconStyle>
</Style>
<Style id="highBleu1">
<IconStyle>
<color>ffffbf00</color>
<scale>0.7</scale>
<Icon>
<href>http://maps.google.com/mapfiles/kml/pal2/icon26.png</href>
</Icon>
<hotSpot x="20" y="2" xunits="pixels" yunits="pixels"/>
</IconStyle>
</Style>
<StyleMap id="First">
<Pair>
<key>normal</key>
<styleUrl>#normBleu1</styleUrl>
</Pair>
<Pair>
<key>highlight</key>
<styleUrl>#highBleu1</styleUrl>
</Pair>
</StyleMap>
<!-- Second object & color -->
<Style id="normBleu2">
<IconStyle>
<color>ffe16941</color>
<scale>0.8</scale>
<Icon>
<href>http://maps.google.com/mapfiles/kml/pal2/icon26.png</href>
</Icon>
<hotSpot x="20" y="2" xunits="pixels" yunits="pixels"/>
</IconStyle>
</Style>
<Style id="highBleu2">
<IconStyle>
<color>ffe16941</color>
<scale>1.0</scale>
<Icon>
<href>http://maps.google.com/mapfiles/kml/pal2/icon26.png</href>
</Icon>
<hotSpot x="20" y="2" xunits="pixels" yunits="pixels"/>
</IconStyle>
</Style>
<StyleMap id="Second">
<Pair>
<key>normal</key>
<styleUrl>#normBleu2</styleUrl>
</Pair>
<Pair>
<key>highlight</key>
<styleUrl>#highBleu2</styleUrl>
</Pair>
</StyleMap>
<!-- Third object & color -->
<Style id="normBleu3">
<IconStyle>
<color>fffe0000</color>
<scale>1.1</scale>
<Icon>
<href>http://maps.google.com/mapfiles/kml/pal2/icon26.png</href>
</Icon>
<hotSpot x="20" y="2" xunits="pixels" yunits="pixels"/>
</IconStyle>
</Style>
<Style id="highBleu3">
<IconStyle>
<color>fffe0000</color>
<scale>1.3</scale>
<Icon>
<href>http://maps.google.com/mapfiles/kml/pal2/icon26.png</href>
</Icon>
<hotSpot x="20" y="2" xunits="pixels" yunits="pixels"/>
</IconStyle>
</Style>
<StyleMap id="Third">
<Pair>
<key>normal</key>
<styleUrl>#normBleu3</styleUrl>
</Pair>
<Pair>
<key>highlight</key>
<styleUrl>#highBleu3</styleUrl>
</Pair>
</StyleMap>
<!-- Fourth object & color -->
<Style id="normBleu4">
<IconStyle>
<color>ff800000</color>
<scale>1.0</scale>
<Icon>
<href>http://maps.google.com/mapfiles/kml/pal2/icon26.png</
href>
</Icon>
<hotSpot x="20" y="2" xunits="pixels" yunits="pixels"/>
</IconStyle>
</Style>
<Style id="highBleu4">
<IconStyle>
<color>ff800000</color>
<scale>1.2</scale>
<Icon>
<href>http://maps.google.com/mapfiles/kml/pal2/icon26.png</href>
</Icon>
<hotSpot x="20" y="2" xunits="pixels" yunits="pixels"/>
</IconStyle>
</Style>
<StyleMap id="Fourth">
<Pair>
<key>normal</key>
<styleUrl>#normBleu4</styleUrl>
</Pair>
<Pair>
<key>highlight</key>
<styleUrl>#highBleu4</styleUrl>
</Pair>
</StyleMap>
<!-- First Entry -->
<Style id="normRose1">
<IconStyle>
<color>ffc1b6ff</color>
<scale>0.01</scale>
<Icon>
<href>http://maps.google.com/mapfiles/kml/pal2/icon26.png</href>
</Icon>
<hotSpot x="20" y="2" xunits="pixels" yunits="pixels"/>
</IconStyle>
</Style>
<Style id="highRose1">
<IconStyle>
<color>ffc1b6ff</color>
<scale>0.02</scale>
<Icon>
<href>http://maps.google.com/mapfiles/kml/pal2/icon26.png</href>
</Icon>
<hotSpot x="20" y="2" xunits="pixels" yunits="pixels"/>
</IconStyle>
</Style>
<StyleMap id="Entry">
<Pair>
<key>normal</key>
<styleUrl>#normRose1</styleUrl>
</Pair>
<Pair>
<key>highlight</key>
<styleUrl>#highRose1</styleUrl>
</Pair>
</StyleMap>
<!-- Places -->
<!-- Make this place the first to point at
WITHOUT Time Primitive,
styleUrl should be as tiny as possible (Scale size = 0.01),
no name,
and WITH a LookAt -->
<Placemark>
<name></name>
<visibility>1</visibility>
<open>1</open>
<Snippet maxLines="2"><![CDATA[ <P>
Take a look at this place !
</P>]]>
</Snippet>
<description><![CDATA[ <H3 align=center>
Title
</H3>
<P align=center>
Some description
</P>]]>
</description>
<styleUrl>#Entry</styleUrl>
<LookAt>
<longitude>4.387445883253662</longitude>
<latitude>45.43968126136668</latitude>
<range>100000</range>
<tilt>0</tilt>
<heading>0</heading>
</LookAt>
<Point>
<coordinates>4.387445883253662,45.43968126136668,0</coordinates>
</Point>
</Placemark>
<!-- Then, Look at the overs without LookAt tag-->
<Placemark>
<name>Sixties</name>
<visibility>1</visibility>
<open>1</open>
<Snippet maxLines="2"><![CDATA[ <P>
Take a look at this place !
</P>]]>
</Snippet>
<description><![CDATA[ <H3 align=center>
Title
</H3>
<P align=center>
Some description
</P>]]>
</description>
<TimeSpan>
<begin>1960-01-01</begin>
<end>1965-01-01</end>
</TimeSpan>
<styleUrl>#First</styleUrl>
<!-- DELETED !!!
<LookAt>
<longitude>4.387445883253662</longitude>
<latitude>45.43968126136668</latitude>
<range>100000</range>
<tilt>0</tilt>
<heading>0</heading>
</LookAt>-->
<Point>
<coordinates>4.387445883253662,45.43968126136668,0</coordinates>
</Point>
</Placemark>
<Placemark>
<name>Sixties</name>
<visibility>1</visibility>
<open>1</open>
<Snippet maxLines="2"><![CDATA[ <P>
Take a look at this place !
</P>]]>
</Snippet>
<description><![CDATA[ <H3 align=center>
Title
</H3>
<P align=center>
Some description
</P>]]>
</description>
<TimeSpan>
<begin>1965-01-01</begin>
<end>1970-01-01</end>
</TimeSpan>
<styleUrl>#Second</styleUrl>
<!-- DELETED !!!
<LookAt>
<longitude>6.134151766529271</longitude>
<latitude>43.71586422117165</latitude>
<range>100000</range>
<tilt>0</tilt>
<heading>0</heading>
</LookAt>-->
<Point>
<coordinates>6.134151766529271,43.71586422117165,0</coordinates>
</Point>
</Placemark>
<Placemark>
<name>Seventies</name>
<visibility>1</visibility>
<open>1</open>
<Snippet maxLines="2"><![CDATA[ <P>
Take a look at this place !
</P>]]>
</Snippet>
<description><![CDATA[ <H3 align=center>
Title
</H3>
<P align=center>
Some description
</P>]]>
</description>
<TimeSpan>
<begin>1970-01-01</begin>
<end>1975-01-01</end>
</TimeSpan>
<styleUrl>#Third</styleUrl>
<!-- DELETED !!!
<LookAt>
<longitude>4.387445883253662</longitude>
<latitude>45.43968126136668</latitude>
<range>100000</range>
<tilt>0</tilt>
<heading>0</heading>
</LookAt>-->
<Point>
<coordinates>4.387445883253662,45.43968126136668,0</coordinates>
</Point>
</Placemark>
<Placemark>
<name>Seventies</name>
<visibility>1</visibility>
<open>1</open>
<Snippet maxLines="2"><![CDATA[ <P>
Take a look at this place !
</P>]]>
</Snippet>
<description><![CDATA[ <H3 align=center>
Title
</H3>
<P align=center>
Some description
</P>]]>
</description>
<TimeSpan>
<begin>1975-01-01</begin>
<end>1980-01-01</end>
</TimeSpan>
<styleUrl>#Fourth</styleUrl>
<!-- DELETED !!!
<LookAt>
<longitude>4.697091755220669</longitude>
<latitude>45.98844237842893</latitude>
<range>100000</range>
<tilt>0</tilt>
<heading>0</heading>
</LookAt>-->
<Point>
<coordinates>4.697091755220669,45.98844237842893,0</coordinates>
</Point>
</Placemark>
<Placemark>
<name>Eighties</name>
<visibility>1</visibility>
<open>1</open>
<Snippet maxLines="2"><![CDATA[ <P>
Take a look at this place !
</P>]]>
</Snippet>
<description><![CDATA[ <H3 align=center>
Title
</H3>
<P align=center>
Some description
</P>]]>
</description>
<TimeSpan>
<begin>1980-01-01</begin>
<end>1985-01-01</end>
</TimeSpan>
<styleUrl>#Third</styleUrl>
<!-- DELETED !!!
<LookAt>
<longitude>4.697091755220669</longitude>
<latitude>45.98844237842893</latitude>
<range>100000</range>
<tilt>0</tilt>
<heading>0</heading>
</LookAt> -->
<Point>
<coordinates>4.697091755220669,45.98844237842893,0</coordinates>
</Point>
</Placemark>
<Placemark>
<name>Eighties</name>
<visibility>1</visibility>
<open>1</open>
<Snippet maxLines="2"><![CDATA[ <P>
Take a look at this place !
</P>]]>
</Snippet>
<description><![CDATA[ <H3 align=center>
Title
</H3>
<P align=center>
Some description
</P>]]>
</description>
<TimeSpan>
<begin>1985-01-01</begin>
<end>1990-01-01</end>
</TimeSpan>
<styleUrl>#Second</styleUrl>
<!-- <LookAt>
<longitude>5.744862162619981</longitude>
<latitude>45.20698359648858</latitude>
<range>100000</range>
<tilt>0</tilt>
<heading>0</heading>
</LookAt>-->
<Point>
<coordinates>5.744862162619981,45.20698359648858,0</coordinates>
</Point>
</Placemark>
</Document>
</kml>
--------------------------------



On 4 déc, 06:59, Timmkish wrote:
> I've got a single placemark (in this case a polygon) that I'd like to
> change color given a certain time. I don't want to recreate the
> object each time I want it to change color. For example: For a 3-D
> polygon, on Monday I want it to be blue, Tuesday to be red, Wednesday
> orange. How would I go about coding this up? I tried embedding the
> Style within theTimespan, but that didn't work. I had previously

ManoM

unread,
Dec 13, 2007, 4:32:33 PM12/13/07
to KML Developer Support - Getting Started with KML
Hi Firsk,

There's no issue with having a LookAt and a TimeSpan in the same
Placemark, but if you're going by the Schema, order matters. It should
be LookAt, then TimeSpan, Then styleUrl.

ManoM
> ...
>
> read more >>
Reply all
Reply to author
Forward
0 new messages