A renderer based on the 2D ‘canvas’ drawing element.
OpenLayers. | A renderer based on the 2D ‘canvas’ drawing element. |
Properties | |
hitDetection | {Boolean} Allow for hit detection of features. |
hitOverflow | {Number} The method for converting feature identifiers to color values supports 16777215 sequential values. |
canvas | {Canvas} The canvas context object. |
features | {Object} Internal object of feature/style pairs for use in redrawing the layer. |
pendingRedraw | {Boolean} The renderer needs a redraw call to render features added while the renderer was locked. |
cachedSymbolBounds | {Object} Internal cache of calculated symbol extents. |
Constructor | |
OpenLayers. | |
Functions | |
setExtent | Set the visible part of the layer. |
eraseGeometry | Erase a geometry from the renderer. |
supported | {Boolean} Whether or not the browser supports the renderer class |
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. |
drawNamedSymbol | Called to draw Well Known Graphic Symbol Name. |
setCanvasStyle | Prepare the canvas for drawing by setting various global settings. |
featureIdToHex | Convert a feature ID string into an RGB hex string. |
setHitContextStyle | Prepare the hit 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. |
renderPath | Render a path with stroke and optional fill. |
drawPolygon | This method is only called by the renderer itself. |
drawText | 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. |
Constants | |
OpenLayers. | {Object} |
OpenLayers. | {Object} |
OpenLayers. | {Number} Scale factor to apply to the canvas drawImage arguments. |
{Number} The method for converting feature identifiers to color values supports 16777215 sequential values. Two features cannot be predictably detected if their identifiers differ by more than this value. The hitOverflow allows for bigger numbers (but the difference in values is still limited).
containerID | {String} |
options | {Object} Optional properties to be set on the renderer. |
setExtent: function()
Set the visible part of the layer.
extent | {OpenLayers.Bounds} |
resolutionChanged | {Boolean} |
{Boolean} true to notify the layer that the new extent does not exceed the coordinate range, and the features will not need to be redrawn. False otherwise.
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.
geometry | {OpenLayers.Geometry} |
featureId | {String} |
setSize: function( size )
Sets the size of the drawing surface.
Once the size is updated, redraw the canvas.
size | {OpenLayers.Size} |
drawFeature: function( feature, style )
Draw the feature. Stores the feature in the features list, then redraws the layer.
feature | {OpenLayers.Feature.Vector} |
style | {<Object>} |
{Boolean} The feature has been drawn completely. If the feature has no geometry, undefined will be returned. If the feature is not rendered for other reasons, false will be returned.
drawGeometry: function( geometry, style, featureId )
Used when looping (in redraw) over the features; draws the canvas.
geometry | {OpenLayers.Geometry} |
style | {Object} |
drawExternalGraphic: function( geometry, style, featureId )
Called to draw External graphics.
geometry | {OpenLayers.Geometry} |
style | {Object} |
featureId | {String} |
drawNamedSymbol: function( geometry, style, featureId )
Called to draw Well Known Graphic Symbol Name. This method is only called by the renderer itself.
geometry | {OpenLayers.Geometry} |
style | {Object} |
featureId | {String} |
setHitContextStyle: function( type, featureId, symbolizer, strokeScaling )
Prepare the hit canvas for drawing by setting various global settings.
type | {String} one of ‘stroke’, ‘fill’, or ‘reset’ |
featureId | {String} The feature id. |
symbolizer | {OpenLayers.Symbolizer} The symbolizer. |
drawPoint: function( geometry, style, featureId )
This method is only called by the renderer itself.
geometry | {OpenLayers.Geometry} |
style | {Object} |
featureId | {String} |
drawLineString: function( geometry, style, featureId )
This method is only called by the renderer itself.
geometry | {OpenLayers.Geometry} |
style | {Object} |
featureId | {String} |
drawLinearRing: function( geometry, style, featureId )
This method is only called by the renderer itself.
geometry | {OpenLayers.Geometry} |
style | {Object} |
featureId | {String} |
drawPolygon: function( geometry, style, featureId )
This method is only called by the renderer itself.
geometry | {OpenLayers.Geometry} |
style | {Object} |
featureId | {String} |
getLocalXY: function( point )
transform geographic xy into pixel xy
point | {OpenLayers.Geometry.Point} |
getFeatureIdFromEvent: function( evt )
Returns a feature id from an event on the renderer.
evt | {OpenLayers.Event} |
{<OpenLayers.Feature.Vector} A feature or undefined. This method returns a feature instead of a feature id to avoid an unnecessary lookup on the layer.
eraseFeatures: function( features )
This is called by the layer to erase features; removes the feature from the list, then redraws the layer.
features | {Array(OpenLayers.Feature.Vector)} |
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.
{Number} Scale factor to apply to the canvas drawImage arguments. This is always 1 except for Android 2.1 devices, to work around http://code.google.com
Set the visible part of the layer.
setExtent: function()
Erase a geometry from the renderer.
eraseGeometry: function( geometry, featureId )
{Boolean} Whether or not the browser supports the renderer class
supported: function()
Sets the size of the drawing surface.
setSize: function( size )
Draw the feature.
drawFeature: function( feature, style )
Used when looping (in redraw) over the features; draws the canvas.
drawGeometry: function( geometry, style, featureId )
Called to draw External graphics.
drawExternalGraphic: function( geometry, style, featureId )
Called to draw Well Known Graphic Symbol Name.
drawNamedSymbol: function( geometry, style, featureId )
Prepare the canvas for drawing by setting various global settings.
setCanvasStyle: function( type, style )
Convert a feature ID string into an RGB hex string.
featureIdToHex: function( featureId )
Prepare the hit canvas for drawing by setting various global settings.
setHitContextStyle: function( type, featureId, symbolizer, strokeScaling )
This method is only called by the renderer itself.
drawPoint: function( geometry, style, featureId )
This method is only called by the renderer itself.
drawLineString: function( geometry, style, featureId )
This method is only called by the renderer itself.
drawLinearRing: function( geometry, style, featureId )
Render a path with stroke and optional fill.
renderPath: function( context, geometry, style, featureId, type )
This method is only called by the renderer itself.
drawPolygon: function( geometry, style, featureId )
This method is only called by the renderer itself.
drawText: function( location, style )
transform geographic xy into pixel xy
getLocalXY: function( point )
Clear all vectors from the renderer.
clear: function()
Returns a feature id from an event on the renderer.
getFeatureIdFromEvent: function( evt )
This is called by the layer to erase features; removes the feature from the list, then redraws the layer.
eraseFeatures: function( features )
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.
redraw: function()