OpenLayers.Renderer.Canvas - OpenLayers

# OpenLayers. Renderer. Canvas

A renderer based on the 2D ‘canvas’ drawing element.element

#### Inherits

- OpenLayers.Renderer

Summary

OpenLayers. Renderer. Canvas | A renderer based on the 2D ‘canvas’ drawing element.element
Properties |
root | {DOMElement} root element of canvas.
canvas | {Canvas} The canvas context object.
features | {Object} Internal object of feature/style pairs for use in redrawing the layer.
geometryMap | {Object} Geometry -> Feature lookup table.
Constructor |
OpenLayers. Renderer. Canvas |
Functions |
eraseGeometry | Erase a geometry from the renderer.
supported | {Boolean} Whether or not the browser supports the renderer class
setExtent | Set the visible part of the layer.
setSize | Sets the size of the drawing surface.
drawFeature | Draw the feature.
drawGeometry | Used when looping (in redraw) over the features; draws the canvas.
drawExternalGraphic | Called to draw External graphics.
setCanvasStyle | Prepare the canvas for drawing by setting various global settings.
drawPoint | This method is only called by the renderer itself.
drawLineString | This method is only called by the renderer itself.
drawLinearRing | This method is only called by the renderer itself.
drawPolygon | This method is only called by the renderer itself.
getLocalXY | transform geographic xy into pixel xy
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; removes the feature from the list, then redraws the layer.
redraw | The real ‘meat’ of the function: any time things have changed, redraw() can be called to loop over all the data and (you guessed it) redraw it.

### Properties

### root

{DOMElement} root element of canvas.

### canvas

{Canvas} The canvas context object.

### features

{Object} Internal object of feature/style pairs for use in redrawing the layer.

### geometryMap

{Object} Geometry -> Feature lookup table. Used by eraseGeometry to lookup features to remove from our internal table (this.features) when erasing geoms.

### Constructor

### OpenLayers. Renderer. Canvas

#### Parameters

containerID | {String}

### Functions

### eraseGeometry

> eraseGeometry: function( | geometry | )

Erase a geometry from the renderer. Because the Canvas renderer has ‘memory’ of the features that it has drawn, we have to remove the feature so it doesn’t redraw.

#### Parameters

geometry | {OpenLayers.Geometry}

### supported

> supported: function()

#### Returns

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

### setExtent

> setExtent: function( | extent | )

Set the visible part of the layer.

Resolution has probably changed, so we nullify the resolution cache (this.resolution), then redraw.

#### Parameters

extent | {OpenLayers.Bounds}

### setSize

> setSize: function( | size | )

Sets the size of the drawing surface.

Once the size is updated, redraw the canvas.

#### Parameters

size | {OpenLayers.Size}

### drawFeature

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

Draw the feature. Stores the feature in the features list, then redraws the layer.

#### Parameters

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

### drawGeometry

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

Used when looping (in redraw) over the features; draws the canvas.

#### Parameters

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

### drawExternalGraphic

> drawExternalGraphic: function( | pt,
> | style | )

Called to draw External graphics.

#### Parameters

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

### setCanvasStyle

> setCanvasStyle: function( | type,
> | style | )

Prepare the canvas for drawing by setting various global settings.

#### Parameters

type | {String} one of ‘stroke’, ‘fill’, or ‘reset’
style | {Object} Symbolizer hash

### drawPoint

> drawPoint: function( | geometry,
> | style | )

This method is only called by the renderer itself.

#### Parameters

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

### drawLineString

> drawLineString: function( | geometry,
> | style | )

This method is only called by the renderer itself.

#### Parameters

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

### drawLinearRing

> drawLinearRing: function( | geometry,
> | style | )

This method is only called by the renderer itself.

#### Parameters

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

### drawPolygon

> drawPolygon: function( | geometry,
> | style | )

This method is only called by the renderer itself.

#### Parameters

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

### getLocalXY

> getLocalXY: function( | point | )

transform geographic xy into pixel xy

#### Parameters

point | {OpenLayers.Geometry.Point}

### 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.

#### Parameters

evt | {OpenLayers.Event}

#### Returns

{String} A feature id or null.

### eraseFeatures

> eraseFeatures: function( | features | )

This is called by the layer to erase features; removes the feature from the list, then redraws the layer.

#### Parameters

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

### redraw

> redraw: function()

The real ‘meat’ of the function: any time things have changed, redraw() can be called to loop over all the data and (you guessed it) redraw it. Unlike Elements-based Renderers, we can’t interact with things once they’re drawn, to remove them, for example, so instead we have to just clear everything and draw from scratch.

> eraseGeometry: function( | geometry | )

Erase a geometry from the renderer.

> supported: function()

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

> setExtent: function( | extent | )

Set the visible part of the layer.

> setSize: function( | size | )

Sets the size of the drawing surface.

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

Draw the feature.

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

Used when looping (in redraw) over the features; draws the canvas.

> drawExternalGraphic: function( | pt,
> | style | )

Called to draw External graphics.

> setCanvasStyle: function( | type,
> | style | )

Prepare the canvas for drawing by setting various global settings.

> drawPoint: function( | geometry,
> | style | )

This method is only called by the renderer itself.

> drawLineString: function( | geometry,
> | style | )

This method is only called by the renderer itself.

> drawLinearRing: function( | geometry,
> | style | )

This method is only called by the renderer itself.

> drawPolygon: function( | geometry,
> | style | )

This method is only called by the renderer itself.

> getLocalXY: function( | point | )

transform geographic xy into pixel xy

> 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; removes the feature from the list, then redraws the layer.

> redraw: function()

The real ‘meat’ of the function: any time things have changed, redraw() can be called to loop over all the data and (you guessed it) redraw it.
This is the base class for all renderers.
Contains convenience functions for string manipulation.
A Geometry is a description of a geographic object.
Instances of this class represent bounding boxes.
Instances of this class represent a width/height pair
Vector features use the OpenLayers.Geometry classes as geometry description.
Point geometry class.
Utility functions for event handling.
Close