This class takes care of figuring out which order elements should be placed in the DOM based on given indexing methods.
OpenLayers. | This class takes care of figuring out which order elements should be placed in the DOM based on given indexing methods. |
Properties | |
maxZIndex | {Integer} This is the largest-most z-index value for a node contained within the indexer. |
order | {Array<String>} This is an array of node id’s stored in the order that they should show up on screen. |
indices | {Object} This is a hash that maps node ids to their z-index value stored in the indexer. |
compare | {Function} This is the function used to determine placement of of a new node within the indexer. |
Functions | |
initialize | Create a new indexer with |
insert | Insert a new node into the indexer. |
remove | |
clear | |
exists | |
getZIndex | Get the z-index value for the current node from the node data itself. |
determineZIndex | Determine the z-index for the current node if there isn’t one, and set the maximum value if we’ve found a new maximum. |
getNextElement | Get the next element in the order stack. |
OpenLayers. | These are the compare methods for figuring out where a new node should be placed within the indexer. |
Functions | |
Z_ORDER | This compare method is used by other comparison methods. |
Z_ORDER_DRAWING_ORDER | This method orders nodes by their z-index, but does so in a way that, if there are other nodes with the same z-index, the newest drawn will be the front most within that z-index. |
Z_ORDER_Y_ORDER | This one should really be called Z_ORDER_Y_ORDER_DRAWING_ORDER, as it best describes which ordering methods have precedence (though, the name would be too long). |
OpenLayers. | This is another virtual class in that it should never be instantiated by itself as a Renderer. |
Properties | |
rendererRoot | {DOMElement} |
root | {DOMElement} |
vectorRoot | {DOMElement} |
textRoot | {DOMElement} |
xmlns | {String} |
xOffset | {Number} Offset to apply to the renderer viewport translation in x direction. |
rightOfDateLine | {Boolean} Keeps track of the location of the map extent relative to the date line. |
Indexer | {<OpenLayers.ElementIndexer>} An instance of OpenLayers.ElementsIndexer created upon initialization if the zIndexing or yOrdering options passed to this renderer’s constructor are set to true. |
Constants | |
BACKGROUND_ID_SUFFIX | {String} |
LABEL_ID_SUFFIX | {String} |
LABEL_OUTLINE_SUFFIX | {String} |
Constructor | |
OpenLayers. | |
Functions | |
destroy | |
clear | Remove all the elements from the root |
setExtent | Set the visible part of the layer. |
getNodeType | This function is in charge of asking the specific renderer which type of node to create for the given geometry and style. |
drawGeometry | Draw the geometry, creating new nodes, setting paths, setting style, setting featureId on the node. |
redrawNode | |
redrawBackgroundNode | Redraws the node using special ‘background’ style properties. |
drawGeometryNode | Given a node, draw a geometry on the specified layer. |
postDraw | Things that have do be done after the geometry node is appended to its parent node. |
drawPoint | Virtual function for drawing Point Geometry. |
drawLineString | Virtual function for drawing LineString Geometry. |
drawLinearRing | Virtual function for drawing LinearRing Geometry. |
drawPolygon | Virtual function for drawing Polygon Geometry. |
drawRectangle | Virtual function for drawing Rectangle Geometry. |
drawCircle | Virtual function for drawing Circle Geometry. |
removeText | Removes a label |
getFeatureIdFromEvent | |
eraseGeometry | Erase a geometry from the renderer. |
nodeFactory | Create new node of the specified type, with the (optional) specified id. |
nodeTypeCompare | |
createNode | |
moveRoot | moves this renderer’s root to a different renderer. |
getRenderLayerId | Gets the layer that this renderer’s output appears on. |
isComplexSymbol | Determines if a symbol cannot be rendered using drawCircle |
insert: function( newNode )
Insert a new node into the indexer. In order to find the correct positioning for the node to be inserted, this method uses a binary search. This makes inserting O(log(n)).
newNode | {DOMElement} The new node to be inserted. |
Returns {DOMElement} the node before which we should insert our newNode, or null if newNode can just be appended.
These are the compare methods for figuring out where a new node should be placed within the indexer. These methods are very similar to general sorting methods in that they return -1, 0, and 1 to specify the direction in which new nodes fall in the ordering.
Functions | |
Z_ORDER | This compare method is used by other comparison methods. |
Z_ORDER_DRAWING_ORDER | This method orders nodes by their z-index, but does so in a way that, if there are other nodes with the same z-index, the newest drawn will be the front most within that z-index. |
Z_ORDER_Y_ORDER | This one should really be called Z_ORDER_Y_ORDER_DRAWING_ORDER, as it best describes which ordering methods have precedence (though, the name would be too long). |
Z_ORDER: function( indexer, newNode, nextNode )
This compare method is used by other comparison methods. It can be used individually for ordering, but is not recommended, because it doesn’t subscribe to drawing order.
indexer | {OpenLayers.ElementsIndexer} |
newNode | {DOMElement} |
nextNode | {DOMElement} |
{Integer}
Z_ORDER_DRAWING_ORDER: function( indexer, newNode, nextNode )
This method orders nodes by their z-index, but does so in a way that, if there are other nodes with the same z-index, the newest drawn will be the front most within that z-index. This is the default indexing method.
indexer | {OpenLayers.ElementsIndexer} |
newNode | {DOMElement} |
nextNode | {DOMElement} |
{Integer}
Z_ORDER_Y_ORDER: function( indexer, newNode, nextNode )
This one should really be called Z_ORDER_Y_ORDER_DRAWING_ORDER, as it best describes which ordering methods have precedence (though, the name would be too long). This method orders nodes by their z-index, but does so in a way that, if there are other nodes with the same z-index, the nodes with the lower y position will be “closer” than those with a higher y position. If two nodes have the exact same y position, however, then this method will revert to using drawing order to decide placement.
indexer | {OpenLayers.ElementsIndexer} |
newNode | {DOMElement} |
nextNode | {DOMElement} |
{Integer}
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.
Properties | |
rendererRoot | {DOMElement} |
root | {DOMElement} |
vectorRoot | {DOMElement} |
textRoot | {DOMElement} |
xmlns | {String} |
xOffset | {Number} Offset to apply to the renderer viewport translation in x direction. |
rightOfDateLine | {Boolean} Keeps track of the location of the map extent relative to the date line. |
Indexer | {<OpenLayers.ElementIndexer>} An instance of OpenLayers.ElementsIndexer created upon initialization if the zIndexing or yOrdering options passed to this renderer’s constructor are set to true. |
Constants | |
BACKGROUND_ID_SUFFIX | {String} |
LABEL_ID_SUFFIX | {String} |
LABEL_OUTLINE_SUFFIX | {String} |
Constructor | |
OpenLayers. | |
Functions | |
destroy | |
clear | Remove all the elements from the root |
setExtent | Set the visible part of the layer. |
getNodeType | This function is in charge of asking the specific renderer which type of node to create for the given geometry and style. |
drawGeometry | Draw the geometry, creating new nodes, setting paths, setting style, setting featureId on the node. |
redrawNode | |
redrawBackgroundNode | Redraws the node using special ‘background’ style properties. |
drawGeometryNode | Given a node, draw a geometry on the specified layer. |
postDraw | Things that have do be done after the geometry node is appended to its parent node. |
drawPoint | Virtual function for drawing Point Geometry. |
drawLineString | Virtual function for drawing LineString Geometry. |
drawLinearRing | Virtual function for drawing LinearRing Geometry. |
drawPolygon | Virtual function for drawing Polygon Geometry. |
drawRectangle | Virtual function for drawing Rectangle Geometry. |
drawCircle | Virtual function for drawing Circle Geometry. |
removeText | Removes a label |
getFeatureIdFromEvent | |
eraseGeometry | Erase a geometry from the renderer. |
nodeFactory | Create new node of the specified type, with the (optional) specified id. |
nodeTypeCompare | |
createNode | |
moveRoot | moves this renderer’s root to a different renderer. |
getRenderLayerId | Gets the layer that this renderer’s output appears on. |
isComplexSymbol | Determines if a symbol cannot be rendered using drawCircle |
{Number} Offset to apply to the renderer viewport translation in x direction. If the renderer extent’s center is on the right of the dateline (i.e. exceeds the world bounds), we shift the viewport to the left by one world width. This avoids that features disappear from the map viewport. Because our dateline handling logic in other places ensures that extents crossing the dateline always have a center exceeding the world bounds on the left, we need this offset to make sure that the same is true for the renderer extent in pixel space as well.
{Boolean} Keeps track of the location of the map extent relative to the date line. The setExtent method compares this value (which is the one from the previous setExtent call) with the current position of the map extent relative to the date line and updates the xOffset when the extent has moved from one side of the date line to the other.
setExtent: function( extent, resolutionChanged )
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.
getNodeType: function( geometry, style )
This function is in charge of asking the specific renderer which type of node to create for the given geometry and style. 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.
geometry | {OpenLayers.Geometry} |
style | {Object} |
{String} The corresponding node type for the specified geometry
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.
geometry | {OpenLayers.Geometry} |
style | {Object} |
featureId | {String} |
{Boolean} true if the geometry has been drawn completely; null if incomplete; false otherwise
redrawNode: function( id, geometry, style, featureId )
id | {String} |
geometry | {OpenLayers.Geometry} |
style | {Object} |
featureId | {String} |
{Boolean} true if the complete geometry could be drawn, null if parts of the geometry could not be drawn, false otherwise
redrawBackgroundNode: function( id, geometry, style, featureId )
Redraws the node using special ‘background’ style properties. Basically just calls redrawNode(), but instead of directly using the ‘externalGraphic’, ‘graphicXOffset’, ‘graphicYOffset’, and ‘graphicZIndex’ properties directly from the specified ‘style’ parameter, we create a new style object and set those properties from the corresponding ‘background’-prefixed properties from specified ‘style’ parameter.
id | {String} |
geometry | {OpenLayers.Geometry} |
style | {Object} |
featureId | {String} |
{Boolean} true if the complete geometry could be drawn, null if parts of the geometry could not be drawn, false otherwise
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.
node | {DOMElement} |
geometry | {OpenLayers.Geometry} |
style | {Object} |
{Object} a hash with properties “node” (the drawn node) and “complete” (null if parts of the geometry could not be drawn, false if nothing could be drawn)
drawPoint: function( node, geometry )
Virtual function for drawing Point Geometry. Should be implemented by subclasses. This method is only called by the renderer itself.
node | {DOMElement} |
geometry | {OpenLayers.Geometry} |
{DOMElement} or false if the renderer could not draw the point
drawLineString: function( node, geometry )
Virtual function for drawing LineString Geometry. Should be implemented by subclasses. This method is only called by the renderer itself.
node | {DOMElement} |
geometry | {OpenLayers.Geometry} |
{DOMElement} or null if the renderer could not draw all components of the linestring, or false if nothing could be drawn
drawLinearRing: function( node, geometry )
Virtual function for drawing LinearRing Geometry. Should be implemented by subclasses. This method is only called by the renderer itself.
node | {DOMElement} |
geometry | {OpenLayers.Geometry} |
{DOMElement} or null if the renderer could not draw all components of the linear ring, or false if nothing could be drawn
drawPolygon: function( node, geometry )
Virtual function for drawing Polygon Geometry. Should be implemented by subclasses. This method is only called by the renderer itself.
node | {DOMElement} |
geometry | {OpenLayers.Geometry} |
{DOMElement} or null if the renderer could not draw all components of the polygon, or false if nothing could be drawn
drawRectangle: function( node, geometry )
Virtual function for drawing Rectangle Geometry. Should be implemented by subclasses. This method is only called by the renderer itself.
node | {DOMElement} |
geometry | {OpenLayers.Geometry} |
{DOMElement} or false if the renderer could not draw the rectangle
drawCircle: function( node, geometry )
Virtual function for drawing Circle Geometry. Should be implemented by subclasses. This method is only called by the renderer itself.
node | {DOMElement} |
geometry | {OpenLayers.Geometry} |
{DOMElement} or false if the renderer could not draw the circle
getFeatureIdFromEvent: function( evt )
evt | {Object} An OpenLayers.Event object |
{String} A feature id or undefined.
eraseGeometry: function( geometry, featureId )
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.
geometry | {OpenLayers.Geometry} |
featureId | {String} |
nodeFactory: function( id, type )
Create new node of the specified type, with the (optional) specified id.
If node already exists with same ID and a different type, we remove it and then call ourselves again to recreate it.
id | {String} |
type | {String} type Kind of node to draw. |
{DOMElement} A new node of the given type and id.
moveRoot: function( renderer )
moves this renderer’s root to a different renderer.
renderer | {OpenLayers.Renderer} target renderer for the moved root |
Create a new indexer with
initialize: function( yOrdering )
Insert a new node into the indexer.
insert: function( newNode )
remove: function( node )
clear: function()
exists: function( node )
Get the z-index value for the current node from the node data itself.
getZIndex: function( node )
Determine the z-index for the current node if there isn’t one, and set the maximum value if we’ve found a new maximum.
determineZIndex: function( node )
Get the next element in the order stack.
getNextElement: function( index )
This compare method is used by other comparison methods.
Z_ORDER: function( indexer, newNode, nextNode )
This method orders nodes by their z-index, but does so in a way that, if there are other nodes with the same z-index, the newest drawn will be the front most within that z-index.
Z_ORDER_DRAWING_ORDER: function( indexer, newNode, nextNode )
This one should really be called Z_ORDER_Y_ORDER_DRAWING_ORDER, as it best describes which ordering methods have precedence (though, the name would be too long).
Z_ORDER_Y_ORDER: function( indexer, newNode, nextNode )
destroy: function()
Remove all the elements from the root
clear: function()
Set the visible part of the layer.
setExtent: function( extent, resolutionChanged )
This function is in charge of asking the specific renderer which type of node to create for the given geometry and style.
getNodeType: function( geometry, style )
Draw the geometry, creating new nodes, setting paths, setting style, setting featureId on the node.
drawGeometry: function( geometry, style, featureId )
redrawNode: function( id, geometry, style, featureId )
Redraws the node using special ‘background’ style properties.
redrawBackgroundNode: function( id, geometry, style, featureId )
Given a node, draw a geometry on the specified layer.
drawGeometryNode: function( node, geometry, style )
Things that have do be done after the geometry node is appended to its parent node.
postDraw: function( node )
Virtual function for drawing Point Geometry.
drawPoint: function( node, geometry )
Virtual function for drawing LineString Geometry.
drawLineString: function( node, geometry )
Virtual function for drawing LinearRing Geometry.
drawLinearRing: function( node, geometry )
Virtual function for drawing Polygon Geometry.
drawPolygon: function( node, geometry )
Virtual function for drawing Rectangle Geometry.
drawRectangle: function( node, geometry )
Virtual function for drawing Circle Geometry.
drawCircle: function( node, geometry )
Removes a label
removeText: function( featureId )
getFeatureIdFromEvent: function( evt )
Erase a geometry from the renderer.
eraseGeometry: function( geometry, featureId )
Create new node of the specified type, with the (optional) specified id.
nodeFactory: function( id, type )
nodeTypeCompare: function( node, type )
createNode: function( type, id )
moves this renderer’s root to a different renderer.
moveRoot: function( renderer )
Gets the layer that this renderer’s output appears on.
getRenderLayerId: function()
Determines if a symbol cannot be rendered using drawCircle
isComplexSymbol: function( graphicName )