Select to view content in your preferred language

WPF local map cache - version 2.1

1345
7
10-13-2010 10:59 AM
GreggLanzing
Deactivated User
Can someone point me to some documentation or perhaps a "how to" on the new local map cache options with the new API version 2.1? 

Thanks for your help!
0 Kudos
7 Replies
JenniferNery
Esri Regular Contributor
You can go to this link to see what's new with 2.1
http://help.arcgis.com/en/webapi/silverlight/2.1/help/index.html?Whats_New.htm
0 Kudos
dotMorten_esri
Esri Notable Contributor
There's no "how to" on local map cache. It just works. The local cache you are referring to is not an offline story if that's what you are thinking. It's just improved use of cache, similar to what Silverlight gets through the browser cache in order to reduce requests going to the server (in fact the tiles are stored in the browser cache).
0 Kudos
PieterCoetzer
Deactivated User
Hi glanzing,

We were also waiting for an off-line storage mechanism that is manageable through code. It appears that this is just a use of the Temp folder to cache data locally, but not permanently (correct me if I�??m wrong SharpGIS).

I can see the use for an off-line cache system (similar to the ArcExplorer application):

+ For clients who are not connected to the network to still be able to pan and browse the map
+ To ship a product with some basic high level tiles, so that the user has an immediate map view available and download the tiles as the user uses the map (in an online environment)

The only other way is to intercept the call to the server, download the tile �??manually�?� to the file system, then to load it into the viewer using the ArcGISDynamicMapServiceLayer from the file system, but this involves constant refreshing and the pain is that you have to manage your own history log to know when to �??refresh�?� the downloaded tiles as well as managing the space requirements and permissions.

It would have been nice if the WPF team could have borrowed the already existing code from the ArcExplorer team 😉

Any other suggestions would be welcome!
0 Kudos
dotMorten_esri
Esri Notable Contributor
Actually v2.1 has events you can use to "intercept" the tile before (TileLoading) and after it loads (TileLoaded). In the case of "before it loads" you check if the tile is already stored locally and if so, you set the tilesource on the event argument, and the map will use that. If you don't have it, do nothing here.
In the TileLoaded handler you can then get to the byte stream that the tile was made off, and you can save it to disk for use at a later time when TileLoading for this tile fires again. I've seen prototypes of this working for WPF and Silverlight in Full Trust mode (it will not work with SL if you are not in full-trust mode).
You can even modify the tile in the TileLoaded event and for instance watermark it, or replace any tile load failure (see the event args for that) with a tile that for instance says "Map Data not available for this area".
0 Kudos
GreggLanzing
Deactivated User
Hi Morten
Its been a couple of months and we are wrapping up our app.  The technique you described above (intercepting the loading of tiles) works great - but with one problem.  If the application is started while disconnected from the internet the map control never initializes.  As a result the tile loading events are never called and so using my local cache doesn't work.  If connectivity is dropped after the control and the app are started using the local cache works great.  Is there a way for the map control to initialize while disconnected so that the loading of tiles (and redirecting to my cache ) can work?

Thanks very much, Gregg
0 Kudos
dotMorten_esri
Esri Notable Contributor
At this point no there isn't. As mentioned earlier, the enhancements are not a true offline story.
You might be able to do something with a custom tile layer though, but that's probably a lot more work.
0 Kudos
MethosPerez
New Contributor
Hi Gregg

I am new to the whole WPF API and I would like to implement a local cache solution.

Would you be so kind to share some of your code to show how this is done?

Methos Perez
0 Kudos