# OpenLayers.Control.CacheRead

A control for using image tiles cached with OpenLayers.Control.CacheWrite from the browser’s local storage.

#### Inherits from

- OpenLayers.Control

Summary

OpenLayers.Control.CacheRead | A control for using image tiles cached with OpenLayers.Control.CacheWrite from the browser’s local storage.
Properties |
fetchEvent | {String} The layer event to listen to for replacing remote resource tile URLs with cached data URIs.
layers | {Array(OpenLayers.Layer.Grid)}.
autoActivate | {Boolean} Activate the control when it is added to a map.
Constructor |
OpenLayers.Control.CacheRead |
Functions |
setMap | Set the map property for the control.
addLayer | Adds a layer to the control.
removeLayer | Removes a layer from the control.
fetch | Listener to the fetchEvent event.
destroy | The destroy method is used to perform any clean up before the control is dereferenced.

### Properties

### fetchEvent

{String} The layer event to listen to for replacing remote resource tile URLs with cached data URIs. Supported values are “tileerror” (try remote first, fall back to cached) and “tileloadstart” (try cache first, fall back to remote). Default is “tileloadstart”.

Note that “tileerror” will not work for CORS enabled images OpenLayers.Tile.Image.crossOriginKeyword in OpenLayers.Layer.Grid.tileOptions.

### layers

{Array(OpenLayers.Layer.Grid)}. Optional. If provided, only these layers will receive tiles from the cache.

### autoActivate

{Boolean} Activate the control when it is added to a map. Default is true.

### Constructor

### OpenLayers.Control.CacheRead

#### Parameters

options | {Object} Object with API properties for this control

### Functions

### setMap

> setMap: function( | map | )

Set the map property for the control.

#### Parameters

map | {OpenLayers.Map}

### addLayer

> addLayer: function( | evt | )

Adds a layer to the control. Once added, tiles requested for this layer will be cached.

#### Parameters

evt | {Object} Object with a layer property referencing an OpenLayers.Layer instance

### removeLayer

> removeLayer: function( | evt | )

Removes a layer from the control. Once removed, tiles requested for this layer will no longer be cached.

#### Parameters

evt | {Object} Object with a layer property referencing an OpenLayers.Layer instance

### fetch

> fetch: function( | evt | )

Listener to the fetchEvent event. Replaces a tile’s url with a data URI from the cache.

#### Parameters

evt | {Object} Event object with a tile property.

### destroy

> destroy: function()

The destroy method is used to perform any clean up before the control is dereferenced. Typically this is where event listeners are removed to prevent memory leaks.

A control for caching image tiles in the browser’s local storage.
Base class for layers that use a lattice of tiles.

> setMap: function( | map | )

Set the map property for the control.

> addLayer: function( | evt | )

Adds a layer to the control.

> removeLayer: function( | evt | )

Removes a layer from the control.

> fetch: function( | evt | )

Listener to the fetchEvent event.
{String} The layer event to listen to for replacing remote resource tile URLs with cached data URIs.

> destroy: function()

The destroy method is used to perform any clean up before the control is dereferenced.
Controls affect the display or behavior of the map.
The value of the crossorigin keyword to use when loading images.
{Object} optional configuration options for OpenLayers.Tile instances created by this Layer, if supported by the tile class.
Instances of OpenLayers.Map are interactive maps embedded in a web page.
Close