OpenLayers. Renderer. Elements

This is another virtual class in that it should never be instantiated by itself as a Renderer.  It exists because there is tons of shared functionality between different vector libraries which use nodes/elements as a base for rendering vectors.

The highlevel bits of code that are implemented here are the adding and removing of geometries, which is essentially the same for any element-based renderer.  The details of creating each node and drawing the paths are of course different, but the machinery is the same.

Inherits

Summary
This is another virtual class in that it should never be instantiated by itself as a Renderer.
{DOMElement}
{DOMElement}
{String}
Remove all the elements from the root
This function is in charge of asking the specific renderer which type of node to create for the given geometry.
Draw the geometry, creating new nodes, setting paths, setting style, setting featureId on the node.
Given a node, draw a geometry on the specified layer.
Virtual function for drawing Point Geometry.
Virtual function for drawing LineString Geometry.
Virtual function for drawing LinearRing Geometry.
Virtual function for drawing Polygon Geometry.
Virtual function for drawing Rectangle Geometry.
Virtual function for drawing Circle Geometry.
Virtual function for drawing Curve Geometry.
Virtual function for drawing Surface Geometry.
Erase a geometry from the renderer.
Create new node of the specified type, with the (optional) specified id.

Properties

rendererRoot

{DOMElement}

root

{DOMElement}

xmlns

{String}

Constructor

OpenLayers. Renderer. Elements

Parameters

containerID{String}

Functions

destroy

destroy: function()

clear

clear: function()

Remove all the elements from the root

getNodeType

getNodeType: function(geometry)

This function is in charge of asking the specific renderer which type of node to create for the given geometry.  All geometries in an Elements-based renderer consist of one node and some attributes.  We have the nodeFactory() function which creates a node for us, but it takes a ‘type’ as input, and that is precisely what this function tells us.

Parameters

geometry{OpenLayers.Geometry}

Returns

{String} The corresponding node type for the specified geometry

drawGeometry

drawGeometry: function(geometry,
style,
featureId)

Draw the geometry, creating new nodes, setting paths, setting style, setting featureId on the node.  This method should only be called by the renderer itself.

Parameters

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

drawGeometryNode

drawGeometryNode: function(node,
geometry,
style)

Given a node, draw a geometry on the specified layer. node and geometry are required arguments, style is optional.  This method is only called by the render itself.

Parameters

node{DOMElement}
geometry{OpenLayers.Geometry}
style{Object}

drawPoint

drawPoint: function(node,
geometry)

Virtual function for drawing Point Geometry.  Should be implemented by subclasses.  This method is only called by the renderer itself.

Parameters

node{DOMElement}
geometry{OpenLayers.Geometry}

drawLineString

drawLineString: function(node,
geometry)

Virtual function for drawing LineString Geometry.  Should be implemented by subclasses.  This method is only called by the renderer itself.

Parameters

node{DOMElement}
geometry{OpenLayers.Geometry}

drawLinearRing

drawLinearRing: function(node,
geometry)

Virtual function for drawing LinearRing Geometry.  Should be implemented by subclasses.  This method is only called by the renderer itself.

Parameters

node{DOMElement}
geometry{OpenLayers.Geometry}

drawPolygon

drawPolygon: function(node,
geometry)

Virtual function for drawing Polygon Geometry.  Should be implemented by subclasses.  This method is only called by the renderer itself.

Parameters

node{DOMElement}
geometry{OpenLayers.Geometry}

drawRectangle

drawRectangle: function(node,
geometry)

Virtual function for drawing Rectangle Geometry.  Should be implemented by subclasses.  This method is only called by the renderer itself.

Parameters

node{DOMElement}
geometry{OpenLayers.Geometry}

drawCircle

drawCircle: function(node,
geometry)

Virtual function for drawing Circle Geometry.  Should be implemented by subclasses.  This method is only called by the renderer itself.

Parameters

node{DOMElement}
geometry{OpenLayers.Geometry}

drawCurve

drawCurve: function(node,
geometry)

Virtual function for drawing Curve Geometry.  Should be implemented by subclasses.  This method is only called by the renderer itself.

Parameters

node{DOMElement}
geometry{OpenLayers.Geometry}

drawSurface

drawSurface: function(node,
geometry)

Virtual function for drawing Surface Geometry.  Should be implemented by subclasses.  This method is only called by the renderer itself.

Parameters

node{DOMElement}
geometry{OpenLayers.Geometry}

getFeatureIdFromEvent

getFeatureIdFromEvent: function(evt)

Parameters

evt{Object} An OpenLayers.Event object

Returns

{OpenLayers.Geometry} A geometry from an event that happened on a layer

eraseGeometry

eraseGeometry: function(geometry)

Erase a geometry from the renderer.  In the case of a multi-geometry, we cycle through and recurse on ourselves.  Otherwise, we look for a node with the geometry.id, destroy its geometry, and remove it from the DOM.

Parameters

geometry{OpenLayers.Geometry}

nodeFactory

nodeFactory: function(id,
type,
geometry)

Create new node of the specified type, with the (optional) specified id.

If node already exists with same ID and type, we remove it and then call ourselves again to recreate it.

Parameters

id{String}
type{String} type Kind of node to draw
geometry{OpenLayers.Geometry}

Returns

{DOMElement} A new node of the given type and id

destroy: function()
clear: function()
Remove all the elements from the root
getNodeType: function(geometry)
This function is in charge of asking the specific renderer which type of node to create for the given geometry.
drawGeometry: function(geometry,
style,
featureId)
Draw the geometry, creating new nodes, setting paths, setting style, setting featureId on the node.
drawGeometryNode: function(node,
geometry,
style)
Given a node, draw a geometry on the specified layer.
drawPoint: function(node,
geometry)
Virtual function for drawing Point Geometry.
drawLineString: function(node,
geometry)
Virtual function for drawing LineString Geometry.
drawLinearRing: function(node,
geometry)
Virtual function for drawing LinearRing Geometry.
drawPolygon: function(node,
geometry)
Virtual function for drawing Polygon Geometry.
drawRectangle: function(node,
geometry)
Virtual function for drawing Rectangle Geometry.
drawCircle: function(node,
geometry)
Virtual function for drawing Circle Geometry.
drawCurve: function(node,
geometry)
Virtual function for drawing Curve Geometry.
drawSurface: function(node,
geometry)
Virtual function for drawing Surface Geometry.
getFeatureIdFromEvent: function(evt)
eraseGeometry: function(geometry)
Erase a geometry from the renderer.
nodeFactory: function(id,
type,
geometry)
Create new node of the specified type, with the (optional) specified id.
This is the base class for all renderers.
A Geometry is a description of a geographic object.
Utility functions for event handling.