Map cache usage by clients

This topic contains three parts. The first section outlines how ArcGIS applications access and use the tiles in a map cache. The second part explains how these applications store the tiles for later use. The final section provides some instructions for overlaying map caches in ArcGIS applications.

How applications access and use the cache

Once you define a tiling scheme for your map service, the service immediately begins trying to use the cache. Any ArcGIS application that can display a map service uses the cache, although how the tiles are retrieved and used varies between applications.

Web applications

When developing with the ArcGIS APIs for JavaScript, Flex, and Silverlight, you use a specific class to specify that you're connecting to a tiled (cached) map service. For example, with the JavaScript API, you use ArcGISTiledMapServiceLayer to connect to a cached service. When you use the cached service, tiles are retrieved from the cache directory by REST calls to the map service. The tile request takes the form http://<map service URL>/tile/<level>/<row>/<column>.

If you are viewing a single cached service in any web application and pan to an area where tiles do not exist, the application does not display a dynamic image; instead, you don't see anything. One way to ensure that you see a map when you pan to an uncached area is to enable on-demand caching.

TipTip:

If the map appears more slowly than expected, examine the URLs of the map images to verify that the application is retrieving tiles. One way to do this is to open the application in Mozilla Firefox 4 (or higher) and click Firefox > Web Developer > Web Console. When the console appears, click the Net button, then zoom or pan your map.

  • If you see URLs like this, your application is successfully getting tiles from REST requests:

    http://gisserver.domain.com:6080/arcgis/rest/services/myService/MapServer/tile/10/1723/3495.jpg

  • If you see some other URL format for your map images, your application is retrieving the tile in a less efficient way or the cache is not being used.

ArcMap

You add cached map services to ArcMap using the Add Data button, the same way you add any other map service. There are two ways you can view a cache in ArcMap:

  • Access the cache through a map service. To view a cache this way, browse to the GIS server and the map service used to create the cache. In this scenario, ArcMap makes an initial connection to the GIS server to determine if the service has a cache. Then ArcMap retrieves tiles from the cache directory on the server's file system.
  • Access the cache as a raster dataset. To view a cache this way, browse to the directory containing the cache tiles and choose to add the dataset to ArcMap. The cache is represented with the same icon used to add all other rasters using the Add Data button. A cache accessed as a raster is for viewing only and cannot be queried. The advantage with this type of cache is that it is not tied to a map service and can be viewed when disconnected from the server, as long as you can still access the cache directory.

When a request is made for a tile at a scale that exactly matches a scale level in the cache, the map service returns the tile directly. Most often, requests do not exactly match the scale levels in the cache. In this situation, ArcMap generally requests the tile from the next closest scale level and resamples it to match the requested scale. This resampling is still much quicker than generating a tile dynamically; however, it does result in an image that looks different than the original tile. Map labels that have been cached may be difficult to read at certain scales in ArcMap due to this resampling. For best results, view the map at or near the scales from which the cache was created.

ArcGlobe and ArcGIS Explorer

ArcGlobe and ArcGIS Explorer can read 2D caches and drape them over the surface of the globe. You'll get the best performance if you build the cache with the ArcGIS Online/Google Maps/Bing Maps tiling scheme. If you cannot use one of these tiling schemes, your best performance will come from using globe services.

One scenario where you may want to add a map service to ArcGlobe is when you've created a 2D map cache and want to create an identical 3D globe cache from the 2D cache. In this scenario, you would only be concerned with generating the cache and would not be navigating the globe.

Local caching of layers on the client

ArcMap, ArcGIS Explorer, and ArcGlobe all maintain local caches of the tiles you have visited. When you zoom and pan back to these areas, the application uses the local cache and does not have to retrieve the tiles from the server again.

You can choose whether you want to save the local cache on disk for use in future sessions or use the local cache for the current session only.

You can also choose not to cache tiles locally. Although this causes you to lose the performance benefit of local caching, you can always be sure that you are getting the latest tile from the server.

It's possible that the server administrator has disabled local caching of the layer, which also means that you always get the most up-to-date tile. If this is the case, the other options for saving the cache locally are unavailable.

If the server administrator updates an area of the server cache that you have already viewed, you must clear your local cache to see the changes. ArcMap, ArcGIS Explorer, and ArcGlobe cannot detect if a cache has been updated. If you are a server administrator, you need to alert your users when updated data is available so that they know to clear their caches.

Overlaying caches

When designing map caches that will be overlaid with other map caches, there are some important cache design factors to consider depending on which application will be used to view the caches.

Overlaying map caches in web applications

Web applications such as the ones built with the ArcGIS APIs for JavaScript, Flex, and Silverlight require that you match coordinate system and tile size when overlaying caches. It's also a good practice to match as many scales as possible.

The easiest way to do this is to match tiling schemes for both caches, then only create tiles at the scales that make sense for each cache. This way, you can be sure that you've matched coordinate system and tile size and that the software recognizes that the two caches have scales in common.

Overlaying map caches in ArcMap

You can overlay any number of map caches in ArcMap. The caches do not need to have the same tiling schemes or projections; however, because of the resampling and reprojecting that ArcMap performs, using equivalent tiling schemes and projections may improve the performance and aesthetic quality of your map.

Forcing a dynamic draw

There are some occasions when you might want to force the service to ignore the cache and draw dynamically, even when tiles are available at some levels. For example, imagine you are developing a web application with the ArcGIS web APIs. You have a map that is cached from zoom levels 0 – 15, but should be drawn dynamically from levels 16 – 19. This might be the case if you want to show real time data at large scales, or if the map covers too broad of an area to be cached at large scales.

The solution for this scenario is to enable dynamic layers on the server and specify in your map requests at scales 16 – 19 that you want to use the dynamic layers. Otherwise, the service will return a map constructed from available tiles, which will be blank in areas where tiles don't exist.

12/18/2014