Associating different LookAt with different placemarks in the kml file

117 views
Skip to first unread message

Yash Vasavada

unread,
May 20, 2013, 12:30:12 AM5/20/13
to kml-support-g...@googlegroups.com
I have defined multiple placemarks in the kml file, where I have associated a specific TimeSpan value with each placemark.

I now want to also change the LookAt settings for each placemark. Thus, as the time changes over min and max values of the specified TimeSpans for different placemarks, I want also to be able to vary LookAt settings.

However, as soon as I assign two different LookAt settings to two placemarks, the Google Earth seems to ignore both these LookAt settings. 

There is a related discussion in a prior post:


The same problem is discussed in this post. However, the solution suggested here is not applicable for me. I don't want to have one global LookAt setting that I would declare at the Document level. My need is to be able to define different LookAt settings for different Placemarks.

Is there any way I can do this? Thanks.

barryhunter (KML Guru)

unread,
May 20, 2013, 8:57:24 AM5/20/13
to kml-support-g...@googlegroups.com

However, as soon as I assign two different LookAt settings to two placemarks, the Google Earth seems to ignore both these LookAt settings. 

Then I humbly suggest you have a syntax error in your KML code. 

Its definitly possible to have LookAt's local to each feature seperately. 

 

Yash Vasavada

unread,
May 20, 2013, 10:30:37 AM5/20/13
to kml-support-g...@googlegroups.com
If I uncomment the second placemark, neither of the two LookAt's have any effect.

   <Placemark>
 <LookAt>
 <longitude>-112.00</longitude>
 <latitude>37.00</latitude><altitude>0</altitude>
 <range>10000000.00</range>
 <tilt>0</tilt>
 <heading>0</heading>
 </LookAt>
<TimeSpan>
<begin>2013-05-20T10:15:47Z</begin>
<end>2013-05-20T10:15:57Z</end>
</TimeSpan>
 
      <styleUrl>#randomColorIcon</styleUrl>
      <Point>
<altitudeMode>relativeToGround</altitudeMode>
         <coordinates>-112.36868,37.831145,0</coordinates>  
      </Point>
   </Placemark>
   
<!--    <Placemark>
 <LookAt>
 <longitude>-102.00</longitude>
 <latitude>37.00</latitude><altitude>0</altitude>
 <range>10000000.00</range>
 <tilt>0</tilt>
 <heading>0</heading>
 </LookAt>
<TimeSpan>
<begin>2013-05-20T10:15:57Z</begin>
<end>2013-05-20T10:16:07Z</end>
</TimeSpan>
 
      <styleUrl>#randomColorIcon</styleUrl>
      <Point>
<altitudeMode>relativeToGround</altitudeMode>
         <coordinates>-102.36868,37.831145,0</coordinates>  
      </Point>
   </Placemark>    -->

barryhunter (KML Guru)

unread,
May 20, 2013, 10:45:05 AM5/20/13
to kml-support-g...@googlegroups.com
Well I just tried copying your code into a fresh KML file. And loaded it in Google Earth. Seems to work just fine. See two placemarks over the US. 

Can double click on either placemark, and the view changes. The LookAts work. 

I also tried playing with the timeslider, the markers appears/disappear correctly in relation to the current time. 



Maybe you thinking the LookAts do something differntly to what they actully do? 

What exactly are you trying to do here? 

Yash Vasavada

unread,
May 20, 2013, 11:21:27 AM5/20/13
to kml-support-g...@googlegroups.com
Thanks. You're right, if I double click on either placemarks on the sidebar of Google Earth, the view changes as you say. For example, the eye alt displayed in the bottom right corner of Google Earth matches with the specified LookAt's <range>10000000.00</range>.

However, I want this same effect to occur automatically, i.e, in the timeslider animation (without me requiring to manually double click the placemarks from the sidebar). For the first ten seconds, I want the camera to be positioned according to the LookAt programmed for the first placemark (whose timespan is the first ten seconds). For the next ten seconds, I want the camera to be positioned according to the second placemark's LookAt. 

Instead of the above, when I open the kml file with Google Earth, eye alt becomes 477 miles (much much smaller than the programmed range value of 10000 km) and the camera view does not change at all during timeslider animation. Although, yes, "the markers appears/disappear correctly in relation to the current time.", the camera stays put and that too not at the programmed LookAt for the either placemark but at some other arbitrary setting.

barryhunter (KML Guru)

unread,
May 20, 2013, 11:38:54 AM5/20/13
to kml-support-g...@googlegroups.com
Ah well LookAts, are never used during 'Timeslider animations'. They are only used when the content is first loaded. But they will also be used during 'Tours'. Opening the folder, and clicking the Tour button. 

If there is no LookAt on the top most element, one will automatically be generated for you, a view is choosen to encompass all points. But I beleive it tries to use data from the enclosed LookAts, so it will deduce its own range, rather than using that from the seperate features. 

So you could generate one for the Top Most element yourself, perhaps looking at a lat/long in the middle between the points, and at the required Range. 


So to get the view to move, have to use the dedicated tour feature, rather than simple timeslider animation. Dont think its possible with the inbuilt builder, but by creating one manually using KML could encode changing the timeslider as part of the Tour. 

And the initial view could be solved by adding a new LookAt. 

Yash Vasavada

unread,
May 20, 2013, 11:43:20 AM5/20/13
to kml-support-g...@googlegroups.com
Even more specifically, with the second placemark commented out, if I double click the kml file, Google Earth opens and the eye alt settles down to the programmed LookAt for the one and only placemark 112 deg W, 37 N, 10000 km.

After uncommenting the second placemark, a double click of kml results in Google Earth settling down at eye alt of 477 miles. Thus, neither of the two LookAt's have any effect.

Only if I double click on the individual placemarks, the programmed LookAts take effect. 

Yash Vasavada

unread,
May 20, 2013, 11:47:16 AM5/20/13
to kml-support-g...@googlegroups.com
>> So you could generate one for the Top Most element yourself

Okay, I will do so.

>> So to get the view to move, have to use the dedicated tour feature

I don't know how to program kml to use the dedicated tour feature. However, looks like I will need to learn this, since my objective is to get the view to move.

barryhunter (KML Guru)

unread,
May 20, 2013, 12:06:01 PM5/20/13
to kml-support-g...@googlegroups.com

Jason M

unread,
May 20, 2013, 2:37:04 PM5/20/13
to kml-support-g...@googlegroups.com
Assume you have a Document element containing both the placemarks for a valid KML file.

<?xml version="1.0" encoding="UTF-8"?>
<Document>

   <Placemark>
  <LookAt>
  <longitude>-112.00</longitude>
  <latitude>37.00</latitude><altitude>0</altitude>
  <range>10000000.00</range>
  <tilt>0</tilt>
  <heading>0</heading>
  </LookAt>
          ...
    </Placemark>

   <Placemark>
          ...
   </Placemark>

</Document>
</kml>

Yash Vasavada

unread,
May 20, 2013, 4:04:48 PM5/20/13
to kml-support-g...@googlegroups.com
Yes, I do. The full program is listed below. Note that only the document level LookAt has the effect here. The LookAt's declared within each Placemarks have no effect as the timeslider animation runs.

The solution is to use the tour feature.




<?xml version="1.0" encoding="UTF-8"?>
<Document>
   <Style id="randomColorIcon">
      <IconStyle>
         <color>ff00ff00</color>
         <colorMode>random</colorMode>
         <scale>4</scale>
         <Icon>
         </Icon>
      </IconStyle>
   </Style>
   
 <LookAt>
 <longitude>-122.00</longitude>
 <latitude>37.00</latitude><altitude>0</altitude>
 <range>10000000.00</range>
 <tilt>0</tilt>
 <heading>0</heading>
 </LookAt>   

   <Placemark>
 <LookAt>
 <longitude>-122.00</longitude>
 <latitude>37.00</latitude><altitude>0</altitude>
 <range>10000000.00</range>
 <tilt>0</tilt>
 <heading>0</heading>
 </LookAt>
 
      <styleUrl>#randomColorIcon</styleUrl>
      <Point>
         <coordinates>-122.36868,37.831145,0</coordinates>
      </Point>
   </Placemark>
   
   <Placemark>
 <LookAt>
 <longitude>-112.00</longitude>
 <latitude>37.00</latitude><altitude>0</altitude>
 <range>10000000.00</range>
 <tilt>0</tilt>
 <heading>0</heading>
 </LookAt>
<TimeSpan>
<begin>2013-05-20T10:15:47Z</begin>
<end>2013-05-20T10:15:57Z</end>
</TimeSpan>
 
      <styleUrl>#randomColorIcon</styleUrl>
      <Point>
<altitudeMode>relativeToGround</altitudeMode>
         <coordinates>-112.36868,37.831145,0</coordinates>  
      </Point>
   </Placemark>
   
   
   <Placemark>
 <LookAt>
 <longitude>-102.00</longitude>
 <latitude>37.00</latitude><altitude>0</altitude>
 <range>10000000.00</range>
 <tilt>0</tilt>
 <heading>0</heading>
 </LookAt>
<TimeSpan>
<begin>2013-05-20T10:15:57Z</begin>
<end>2013-05-20T10:16:07Z</end>
</TimeSpan>
 
      <styleUrl>#randomColorIcon</styleUrl>
      <Point>
<altitudeMode>relativeToGround</altitudeMode>
         <coordinates>-102.36868,37.831145,0</coordinates>  
      </Point>
   </Placemark>
 
   
</Document>
</kml>

Yash Vasavada

unread,
May 20, 2013, 4:09:21 PM5/20/13
to kml-support-g...@googlegroups.com
Following works in that I can now get the view to move. However, the nice thing about the previous approach using the time-spans was that that allowed displaying different placemark icons as the timeslider progressed. Not sure if it is possible to add a time-dependent placemark display in the tour based approach.

<?xml version="1.0" encoding="UTF-8"?>
 
<!-- <Document> -->
<gx:Tour>
    <name>Play me!</name>
    <gx:Playlist>

      <gx:FlyTo>
        <gx:duration>5.0</gx:duration>
<gx:flyToMode>smooth</gx:flyToMode>
<LookAt>
 <longitude>-122.00</longitude>
 <latitude>37.00</latitude><altitude>0</altitude>
 <range>10000000.00</range>
 <tilt>0</tilt>
 <heading>0</heading>
 <altitudeMode>relativeToGround</altitudeMode>
 </LookAt>
 
      </gx:FlyTo>

<!--       <gx:Wait>
        <gx:duration>1.0</gx:duration>
      </gx:Wait> -->

      <gx:FlyTo>
        <gx:duration>6.0</gx:duration>
<gx:flyToMode>smooth</gx:flyToMode>
        <LookAt>
 <longitude>-112.00</longitude>
 <latitude>37.00</latitude><altitude>0</altitude>
 <range>10000000.00</range>
 <tilt>0</tilt>
 <heading>0</heading>
 <altitudeMode>relativeToGround</altitudeMode>
 </LookAt>
 </gx:FlyTo>
<!--       <gx:Wait>
        <gx:duration>1.0</gx:duration>
      </gx:Wait> -->

      <gx:FlyTo>
        <gx:duration>6.0</gx:duration>
<gx:flyToMode>smooth</gx:flyToMode>
        <LookAt>
 <longitude>-102.00</longitude>
 <latitude>37.00</latitude><altitude>0</altitude>
 <range>10000000.00</range>
 <tilt>0</tilt>
 <heading>0</heading>
 <altitudeMode>relativeToGround</altitudeMode>
 </LookAt>
 </gx:FlyTo>
 
 </gx:Playlist>
  </gx:Tour>
 
   
<!-- </Document> -->
</kml>

barryhunter (KML Guru)

unread,
May 22, 2013, 10:15:49 AM5/22/13
to kml-support-g...@googlegroups.com


On Monday, May 20, 2013 9:09:21 PM UTC+1, Yash Vasavada wrote:
Following works in that I can now get the view to move. However, the nice thing about the previous approach using the time-spans was that that allowed displaying different placemark icons as the timeslider progressed. 


 Use the <gx:AnimatedUpdate> to change the <visibility> and/or  <gx:balloonVisibility> of a placemark
Reply all
Reply to author
Forward
0 new messages