Force reload of KML file

1,395 views
Skip to first unread message

todduser

unread,
Jul 27, 2009, 10:50:35 AM7/27/09
to KML Developer Support - Advanced Support for KML
Hi all,
This is a repost from the "Getting Started with KML" area - I didn't
get any responses there.

I'm trying to implement a work-around to network link refresh closing
a balloon. I have a script that runs and generates 2 kml files every
second. One of the kml files is configured in Google Earth as a
network link that periodically refreshes every n seconds (normally
set
at 1 or 5). This network link kml file has Placemark <description>
tags that look like this: <![CDATA[<a
href="Second_KML_File.kml#0000001;balloon">details</a>]]>
This link opens the 2nd kml file and displays the balloon for
placemark id "0000001" This balloon stays open during network link
refreshes because it's not part of the network link. The problem is
that that clicking on the same placemark again does not re-read the
2nd kml file to refresh with the latest data. Is there a way to
force
GE to reload the 2nd kml or have it "expire?"

Thanks!

Barry Hunter

unread,
Aug 3, 2009, 11:22:09 AM8/3/09
to KML Developer Support - Advanced Support for KML
To be honest I dont understand the question.

Can you perhaps link to a demonstrator KML file - seeing the problem
like you do makes it much easier to figure out what is going on.

todduser

unread,
Aug 3, 2009, 2:52:24 PM8/3/09
to KML Developer Support - Advanced Support for KML
I cannot provide a link, but I can explain in more detail and provide
kml snippets. Everything occurs on a local machine and I'm using
Google Earth. I have a script that runs every second and generates 2
kml files (KML_1 and KML_2) - data changes every time as the source
data is constantly changing. Google Earth has a network link pointing
to KML_1. Here's a snippet of KML_1:

<Placemark>
<name>Placemark_1</name>
<description><![CDATA[<a
href="KML_2.kml#00000001;balloon">Details...</a>]]></description>
<Style> style stuff here </Style>
<MultiGeometry>
<LineString> linestring stuff here </LineString>
<Point> point stuff here </Point>
</MultiGeometry>
</Placemark>

That gives me a linestring and a point... and the <coordinates>
values of the <Point> and <LineString> have the point at the end of
the linestring.
Each placemark in KML_1, has a cooresponding placemark in KML_2 (note
the href 00000001 in KML_1 and the placemark id of "00000001").
Here's a snippet of KML_2:

<Placemark id="00000001">
<name>Placemark 1</name>
<ExtendedData> extended data stuff here </ExtendedData>
<styleUrl> styleUrl stuff here that has Balloon style and text
definitions </styleUrl>
<Point> coordinates match those in KML1 </Point>
</Placemark>

When I click on "Details..." for Placemark_1 in KML1 (KML1 is the
network link file), the balloon for id=00000001 in KML2 is displayed
correctly.... and the balloon does not go away on Network Link
refreshes. If I click on "Details..." for Placemark_1 again, the
balloon displays again, but the data is not up to date. If I click
"Details..." on another placemark that has not been displayed before,
KML2 is refreshed with current data at that point - but becomes stale
until a "never been clicked on" placemark is clicked.

Thanks!
> > Thanks!- Hide quoted text -
>
> - Show quoted text -

Barry Hunter

unread,
Aug 3, 2009, 4:09:11 PM8/3/09
to KML Developer Support - Advanced Support for KML
Are you using HTTP Expires header on KML_2 ?

Have you tried a dummy query string?

<a href="KML_2.kml?d=1234545#00000001;balloon">Details...</a>

where d changes every time you publish KML_1

todduser

unread,
Aug 4, 2009, 9:52:41 AM8/4/09
to KML Developer Support - Advanced Support for KML
The HTTP Expires header on KML_2 sounds like what I need, how can I
add that to KML_2.kml? (I googled and came up empty) Also, there is
no web server running.

I've tried the dummy query string, unfortunately, it didn't work
(actually, the balloon stops working alltogether).

Thanks.
> > > - Show quoted text -- Hide quoted text -

Barry Hunter

unread,
Aug 4, 2009, 12:10:40 PM8/4/09
to KML Developer Support - Advanced Support for KML
If you not using a webserver, and just linking to local files - then
neither of these techniques will work.

Expires headers are part of the webbased protocol and not applicable
to local files.

Also doubt query strings are going to work, again they are part of URL
specs, and often ignored by webservers - so ideal for defeating the
cache. Doubtful they will be ignored by the operating system.

Can use something like
http://www.appwebserver.org/
to get a local server running.

todduser

unread,
Aug 4, 2009, 12:50:51 PM8/4/09
to KML Developer Support - Advanced Support for KML
Thanks Barry,
I might have to give a web server a try... I was hoping not to have
to require one.
If I were running one, I'm still not sure how to add the expire
headers to KML_2.
Think changing the web server settings would do the trick?

Thanks again for your help!

On Aug 4, 12:10 pm, Barry Hunter wrote:
> If you not using a webserver, and just linking to local files - then
> neither of these techniques will work.
>
> Expires headers are part of the webbased protocol and not applicable
> to local files.
>
> Also doubt query strings are going to work, again they are part of URL
> specs, and often ignored by webservers - so ideal for defeating the
> cache. Doubtful they will be ignored by the operating system.
>
> Can use something likehttp://www.appwebserver.org/

Barry Hunter

unread,
Aug 4, 2009, 1:47:48 PM8/4/09
to KML Developer Support - Advanced Support for KML
Yes would be in the server config.

I assumed appWeb would be able to do expires header, but a quick
browse though their settings, cant see it.

Maybe the old faithful Apache theb - eg via WAMP. That can definitly
do it.


If you have access to a apache server online might be worth testing
there first, before going though the trouble of getting it running
locally.

todduser

unread,
Aug 5, 2009, 2:52:31 PM8/5/09
to KML Developer Support - Advanced Support for KML
Tried it on a machine with Apache (and modified the server config).
Same results - it still uses cached kml (displaying stale data in the
balloon).

Barry Hunter

unread,
Aug 10, 2009, 4:17:10 PM8/10/09
to KML Developer Support - Advanced Support for KML
Did you try the dummy params? - dont think that can fail :) [provided
the webserver can just silently ignore them]


Re using http headers, it seems it would only work with network links
- as it needs 'onExpire' explicity set
http://code.google.com/apis/kml/documentation/kml_21tutorial.html#expiration

todduser

unread,
Aug 13, 2009, 12:31:56 PM8/13/09
to KML Developer Support - Advanced Support for KML
Yes, I tried the dummy params... the balloon never pops up trying
that method.
Too bad I can't get the 2nd kml to "expire" - as I thought this was
going to work. I really like the balloon staying open during a
network refresh.

On Aug 10, 4:17 pm, Barry Hunter wrote:
> Did you try the dummy params? - dont think that can fail :) [provided
> the webserver can just silently ignore them]
>
> Re using http headers, it seems it would only work with network links
> - as it needs 'onExpire' explicity sethttp://code.google.com/apis/kml/documentation/kml_21tutorial.html#exp...
Reply all
Reply to author
Forward
0 new messages