OpenLayers.Renderer - OpenLayers

# OpenLayers. Renderer

This is the base class for all renderers.

This is based on a merger code written by Paul Spencer and Bertil Chapuis. It is largely composed of virtual functions that are to be implemented in technology-specific subclasses, but there is some generic code too.

The functions that are implemented here merely deal with the maintenance of the size and extent variables, as well as the cached ‘resolution’ value.

A note to the user that all subclasses should use getResolution() instead of directly accessing this.resolution in order to correctly use the cacheing system.

Summary

OpenLayers. Renderer | This is the base class for all renderers.
Properties |
container | {DOMElement}
extent | {OpenLayers.Bounds}
locked | {Boolean} If the renderer is currently in a state where many things are changing, the ‘locked’ property is set to true.
size | {OpenLayers.Size}
resolution | {Float} cache of current map resolution
map | {OpenLayers.Map} Reference to the map -- this is set in Vector’s setMap()
Constructor |
OpenLayers. Renderer |
Functions |
destroy |
supported | This should be overridden by specific subclasses
setExtent | Set the visible part of the layer.
setSize | Sets the size of the drawing surface.
getResolution | Uses cached copy of resolution if available to minimize computing
drawFeature | Draw the feature.
drawGeometry | Draw a geometry.
clear | Clear all vectors from the renderer.
getFeatureIdFromEvent | Returns a feature id from an event on the renderer.
eraseFeatures | This is called by the layer to erase features
eraseGeometry | Remove a geometry from the renderer (by id).

### Properties

### container

{DOMElement}

### extent

{OpenLayers.Bounds}

### locked

{Boolean} If the renderer is currently in a state where many things are changing, the ‘locked’ property is set to true. This means that renderers can expect at least one more drawFeature event to be called with the ‘locked’ property set to ‘true’: In some renderers, this might make sense to use as a ‘only update local information’ flag.

### size

{OpenLayers.Size}

### resolution

{Float} cache of current map resolution

### map

{OpenLayers.Map} Reference to the map -- this is set in Vector’s setMap()

### Constructor

### OpenLayers. Renderer

#### Parameters

containerID | {String}
options | {Object} options for this renderer. See sublcasses for supported options.

### Functions

### destroy

> destroy: function()

### supported

> supported: function()

This should be overridden by specific subclasses

#### Returns

{Boolean} Whether or not the browser supports the renderer class

### setExtent

> setExtent: function( | extent,
> | resolutionChanged | )

Set the visible part of the layer.

Resolution has probably changed, so we nullify the resolution cache (this.resolution) -- this way it will be re-computed when next it is needed. We nullify the resolution cache (this.resolution) if resolutionChanged is set to true - this way it will be re-computed on the next getResolution() request.

#### Parameters

extent | {OpenLayers.Bounds}
resolutionChanged | {Boolean}

### setSize

> setSize: function( | size | )

Sets the size of the drawing surface.

Resolution has probably changed, so we nullify the resolution cache (this.resolution) -- this way it will be re-computed when next it is needed.

#### Parameters

size | {OpenLayers.Size}

### getResolution

> getResolution: function()

Uses cached copy of resolution if available to minimize computing

#### Returns

The current map’s resolution

### drawFeature

> drawFeature: function( | feature,
> | style | )

Draw the feature. The optional style argument can be used to override the feature’s own style. This method should only be called from layer.drawFeature().

#### Parameters

feature | {OpenLayers.Feature.Vector}
style | {<Object>}

#### Returns

{Boolean} true if the feature has been drawn completely, false if not, undefined if the feature had no geometry

### drawGeometry

> drawGeometry: function( | geometry,
> | style,
> | featureId | )

Draw a geometry. This should only be called from the renderer itself. Use layer.drawFeature() from outside the renderer. virtual function

#### Parameters

geometry | {OpenLayers.Geometry}
style | {Object}
featureId | {String}

### clear

> clear: function()

Clear all vectors from the renderer. virtual function.

### getFeatureIdFromEvent

> getFeatureIdFromEvent: function( | evt | )

Returns a feature id from an event on the renderer. How this happens is specific to the renderer. This should be called from layer.getFeatureFromEvent(). Virtual function.

#### Parameters

evt | {OpenLayers.Event}

#### Returns

{String} A feature id or null.

### eraseFeatures

> eraseFeatures: function( | features | )

This is called by the layer to erase features

#### Parameters

features | {Array(OpenLayers.Feature.Vector)}

### eraseGeometry

> eraseGeometry: function( | geometry | )

Remove a geometry from the renderer (by id). virtual function.

#### Parameters

geometry | {OpenLayers.Geometry}

Instances of this class represent bounding boxes.
Instances of this class represent a width/height pair
Instances of OpenLayers.Map are interactive maps embedded in a web page.

> destroy: function()

> supported: function()

This should be overridden by specific subclasses

> setExtent: function( | extent,
> | resolutionChanged | )

Set the visible part of the layer.

> setSize: function( | size | )

Sets the size of the drawing surface.

> getResolution: function()

Uses cached copy of resolution if available to minimize computing

> drawFeature: function( | feature,
> | style | )

Draw the feature.

> drawGeometry: function( | geometry,
> | style,
> | featureId | )

Draw a geometry.

> clear: function()

Clear all vectors from the renderer.

> getFeatureIdFromEvent: function( | evt | )

Returns a feature id from an event on the renderer.

> eraseFeatures: function( | features | )

This is called by the layer to erase features

> eraseGeometry: function( | geometry | )

Remove a geometry from the renderer (by id).
Contains convenience functions for string manipulation.
Vector features use the OpenLayers.Geometry classes as geometry description.
A Geometry is a description of a geographic object.
Utility functions for event handling.
Close