Select to view content in your preferred language

Loading a KML layer in real time (no cache).

5305
9
Jump to solution
10-15-2012 12:50 AM
IgorNadal
Emerging Contributor
Hello:

I'm new in ArcGIS Online. I want to add a layer from the Web, from a URL that points to a KML file. I've been able to do this successfully. However, I'm interested in loading such KML in pure real time, because eventually I'll replace the file (which is just a sample) by a Java servlet which will obtain certain filtered references from a generic database.

What do I mean by "real time"? In my tests I've cleared my sample KML file but the map in ArcGIS Online still showed the content there. It seems that ArcGIS Online keeps some kind of cache. Is it possible to disable it and force a live load?

Thank you for your help.
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
MikeMinami
Esri Notable Contributor
We cache for performance reasons, so this will not be changing anytime soon. Yes, I suppose you could write your own Javascript app that makes a call to the KML utility service (http://utility.arcgis.com/sharing/kml). The KML utility that reads the KML file has a "refresh=true" parameter that will ignore the cache and read the file again.

Thanks,

Mike

View solution in original post

0 Kudos
9 Replies
MikeMinami
Esri Notable Contributor
The KML gets read each time the web map opens. The web map doesn't respond to real-time changes in the KML while the map is open. You could probably write your own application to do this...Check out the JavaScript API.

Thanks,

Mike
IgorNadal
Emerging Contributor
Hello Mike:

First of all, thank you for your support. I think that I should have been more precise about the "real-time" term. Because I really meant every time that the map is loaded, indeed (true, that's not "real-time"). For example, when I follow these steps, the map still shows the old version of the KML file:


  1. I create a Web map with a KML layer on it.

  2. I check if the resulting mark is right (the KML file contains one only). I can see it there, so it's OK.

  3. I logout.

  4. I clear the KML file in my server so that it does not contain any mark.

  5. I login again.

  6. I check the map, but the mark from the old version of the KML file is still there.


Whenever I (re)load the map, Shouldn't it load the KML file again from my server? I believe that I even cleared the cache of my Web browser to make sure that it wasn't because of the local cache, but it still loaded the old version of the KML file.

Only after waiting for some time (I don't know how long exactly) it reloads the KML again.


PS: Thanks for the link to the JavaScipt API too, since I will need it soon 😉 .
0 Kudos
MikeMinami
Esri Notable Contributor
OK, it turns out we have a 30 minute cache of the KML... Do you ever see the point move?

Thanks,

Mike
IgorNadal
Emerging Contributor
Yes, after certain time, the map tries to load the KML file from the original location. For example, if I rename the file from "a_place.kml" to "a_place.kml~" in my server, and later I load the ArcGIS Online map again, the point is still there.

But if I wait for several minutes (I guess it's 30 minutes, as you mentioned), the map detects that the file is missing and does not show any point, only an alert. This means that the cache has expired properly, I guess.

So, in order to avoid this cache, I guess that I'm forced to get into the JavaScript API now and set the points with a custom script, Right?
0 Kudos
MikeMinami
Esri Notable Contributor
We cache for performance reasons, so this will not be changing anytime soon. Yes, I suppose you could write your own Javascript app that makes a call to the KML utility service (http://utility.arcgis.com/sharing/kml). The KML utility that reads the KML file has a "refresh=true" parameter that will ignore the cache and read the file again.

Thanks,

Mike
0 Kudos
IgorNadal
Emerging Contributor
Thank you for the information Mike. I'm going to start studying the JavaScript API from today 😉 .
0 Kudos
ElbertHatchell1
Deactivated User

This post was a while back, but has anyone found a solution? We have KML files we serve up through AGOL, but we need to display updates as they take place. Unfortunately, the existing AGOL 30-minute cache will not work for us. We're working with the JavaScript API as well, but we're not sure how to set the "refresh=true" parameter within the KML utility service.

Thanks for any ideas you can send our way.

Bert

0 Kudos
PeterTimmers
Frequent Contributor

According to the KML documentation the web map refresh rates on KML layers are honoured.

KML—ArcGIS Online Help | ArcGIS 

I'm not entirely sure that's the case.  I've got a KML that's refreshing on our web server every minute and the layer in the web map is set to refresh every minute.  So at worst you'd expect something like a 2 minute refresh.  As far as I can see that's not the case.  I suppose it could be my browser caching or firewall caching, but Google Earth sees the changes so it's all a little unclear.

I've tried incognito in chrome with no change.

Can anyone clear up what the story is with KML refresh rates in AGOL?

0 Kudos
PeterTimmers
Frequent Contributor

Reply to my own reply....

While refresh rates on layers within Web Maps don't seem to be honoured, you can create a kml with a network link with a refresh rate and that may work.

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.1">
<Document>
<NetworkLink>
<Link>
<href>https://server/data.kmz</href>
<refreshMode>onInterval</refreshMode>
<refreshInterval>60</refreshInterval>
</Link>
</NetworkLink>
</Document>
</kml>