OpenLayers. Renderer. Canvas

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

Inherits

Summary
OpenLayers. Renderer. CanvasA renderer based on the 2D ‘canvas’ drawing element.element
Properties
canvas{Canvas} The canvas context object.
features{Object} Internal object of feature/style pairs for use in redrawing the layer.
Constructor
OpenLayers. Renderer. Canvas
Functions
eraseGeometryErase a geometry from the renderer.
supported{Boolean} Whether or not the browser supports the renderer class
setExtentSet the visible part of the layer.
setSizeSets the size of the drawing surface.
drawFeatureDraw the feature.
drawGeometryUsed when looping (in redraw) over the features; draws the canvas.
drawExternalGraphicCalled to draw External graphics.
setCanvasStylePrepare the canvas for drawing by setting various global settings.
drawPointThis method is only called by the renderer itself.
drawLineStringThis method is only called by the renderer itself.
drawLinearRingThis method is only called by the renderer itself.
drawPolygonThis method is only called by the renderer itself.
drawTextThis method is only called by the renderer itself.
getLocalXYtransform geographic xy into pixel xy
clearClear all vectors from the renderer.
getFeatureIdFromEventReturns a feature id from an event on the renderer.
eraseFeaturesThis is called by the layer to erase features; removes the feature from the list, then redraws the layer.
redrawThe 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.
Constants
OpenLayers. Renderer. Canvas. LABEL_ALIGN{Object}

Properties

canvas

{Canvas} The canvas context object.

features

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

Constructor

OpenLayers. Renderer. Canvas

Parameters

containerID{String}

Functions

eraseGeometry

eraseGeometry: function(geometry,
featureId)

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}
featureId{String}

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}

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}

drawText

drawText: function(location,
style)

This method is only called by the renderer itself.

Parameters

location{<OpenLayers.Point>}
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.

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.

Constants

OpenLayers. Renderer. Canvas. LABEL_ALIGN

{Object}

eraseGeometry: function(geometry,
featureId)
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.
drawText: function(location,
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