Examples of Javascript in KML <description> tag for GE 5.0?

1,655 views
Skip to first unread message

tatlar

unread,
Feb 4, 2009, 4:56:15 PM2/4/09
to KML Developer Support - Advanced Support for KML
Hi All,

Has anyone seen/written a GE 5.0 KML file that actually uses the new*
javascript functionality embedded in the <description> tag? I have
been searching online for an example, but haven't seen anything.
Specifically I am looking to use jQuery within my KML for AJAX
requests.

All information appreciated. Thanks in advance.

* - This is supposed to be available now as of the version 5.0 that
was just released:
http://code.google.com/apis/kml/documentation/kmlreference.html#description

JamesS

unread,
Feb 5, 2009, 1:10:16 PM2/5/09
to KML Developer Support - Advanced Support for KML
Hi,

I've played around with it a little, and got some basic Javascript
working. For example a clock:

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Placemark>
<name>Clock</name>
<description><![CDATA[
<div style="width:350px;" id="clock"></div>
<script type="text/javascript">
setInterval("tick()",50);
function tick(){
document.getElementById("clock").innerHTML=new Date();
}
</script>]]>
</description>
<Point>
<coordinates>0,0,0</coordinates>
</Point>
</Placemark>
</kml>


We could do with an official example or two from Google. Not really
sure whether just sticking in a html fragment like this is the right
way to go about it.

-James
> was just released:http://code.google.com/apis/kml/documentation/kmlreference.html#descr...

tatlar

unread,
Feb 5, 2009, 4:22:40 PM2/5/09
to KML Developer Support - Advanced Support for KML
Hey James,

Thanks for that example. What I am really wondering is if there is a
way to reference a script globally, kind of like in HTML where you
embed a <script> reference as a child element in the <head> element of
the page. That way, the whole page can have all the functionality
provided by the script with just one call. It would be extremely
verbose (and make a very large file) to have to add a <script> element
to EVERY <description> element if you wanted consist dynamic behavior
across all placemarks.

I wonder if you can insert it in the <Document> tag? You are right
though - an official example would really help us out here.
Reply all
Reply to author
Forward
0 new messages