OpenLayers.Renderer.SVG - OpenLayers

# OpenLayers.Renderer.SVG

#### Inherits

- OpenLayers.Renderer.Elements

Summary

OpenLayers.Renderer.SVG |
Properties |
xmlns | {String}
xlinkns | {String}
Constants |
MAX_PIXEL | {Integer} Firefox has a limitation where values larger or smaller than about 15000 in an SVG document lock the browser up.
Properties |
translationParameters | {Object} Hash with “x” and “y” properties
symbolMetrics | {Object} Cache for symbol metrics according to their svg coordinate space.
Constructor |
OpenLayers.Renderer.SVG |
Functions |
supported | {Boolean} Whether or not the browser supports the SVG renderer
inValidRange | See #669 for more information
setExtent |
translate | Transforms the SVG coordinate system
setSize | Sets the size of the drawing surface.
getNodeType |
setStyle | Use to set all the style attributes to a SVG node.
dashStyle |
createNode |
nodeTypeCompare |
createRenderRoot | {DOMElement} The specific render engine’s root element
createRoot |
createDefs | {DOMElement} The element to which we’ll add the symbol definitions
drawPoint | This method is only called by the renderer itself.
drawCircle | 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.
drawRectangle | This method is only called by the renderer itself.
drawText | This method is only called by the renderer itself.
getComponentString |
clipLine | Given two points (one inside the valid range, and one outside), clips the line betweeen the two points so that the new points are both inside the valid range.
getShortString |
getPosition | Finds the position of an svg node.
importSymbol | add a new symbol definition from the rendererer’s symbol hash
getFeatureIdFromEvent |
Constants |
OpenLayers.Renderer.SVG.LABEL_ALIGN | {Object}
OpenLayers.Renderer.SVG.LABEL_VSHIFT | {Object}
OpenLayers.Renderer.SVG.LABEL_VFACTOR | {Object}
Functions |
OpenLayers.Renderer.SVG.preventDefault | Deprecated.

### Properties

### xmlns

{String}

### xlinkns

{String}

### Constants

### MAX_PIXEL

{Integer} Firefox has a limitation where values larger or smaller than about 15000 in an SVG document lock the browser up. This works around it.

### Properties

### translationParameters

{Object} Hash with “x” and “y” properties

### symbolMetrics

{Object} Cache for symbol metrics according to their svg coordinate space. This is an object keyed by the symbol’s id, and values are an array of [width, centerX, centerY].

### Constructor

### OpenLayers.Renderer.SVG

#### Parameters

containerID | {String}

### Functions

### supported

> supported: function()

#### Returns

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

### inValidRange

> inValidRange: function( | x,
> | y,
> | xyOnly | )

See #669 for more information

#### Parameters

x | {Integer}
y | {Integer}
xyOnly | {Boolean} whether or not to just check for x and y, which means to not take the current translation parameters into account if true.

#### Returns

{Boolean} Whether or not the ‘x’ and ‘y’ coordinates are in the valid range.

### setExtent

> setExtent: function( | extent,
> | resolutionChanged | )

#### Parameters

extent | {OpenLayers.Bounds}
resolutionChanged | {Boolean}

#### Returns

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

### translate

> translate: function( | x,
> | y | )

Transforms the SVG coordinate system

#### Parameters

x | {Float}
y | {Float}

#### Returns

{Boolean} true if the translation parameters are in the valid coordinates range, false otherwise.

### setSize

> setSize: function( | size | )

Sets the size of the drawing surface.

#### Parameters

size | {OpenLayers.Size} The size of the drawing surface

### getNodeType

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

#### Parameters

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

#### Returns

{String} The corresponding node type for the specified geometry

### setStyle

> setStyle: function( | node,
> | style,
> | options | )

Use to set all the style attributes to a SVG node.

Takes care to adjust stroke width and point radius to be resolution-relative

#### Parameters

node | {SVGDomElement} An SVG element to decorate
style | {Object}
options | {Object} Currently supported options include ‘isFilled’ {Boolean} and ‘isStroked’ {Boolean}

### dashStyle

> dashStyle: function( | style,
> | widthFactor | )

#### Parameters

style | {Object}
widthFactor | {Number}

#### Returns

{String} A SVG compliant ‘stroke-dasharray’ value

### createNode

> createNode: function( | type,
> | id | )

#### Parameters

type | {String} Kind of node to draw
id | {String} Id for node

#### Returns

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

### nodeTypeCompare

> nodeTypeCompare: function( | node,
> | type | )

#### Parameters

node | {SVGDomElement} An SVG element
type | {String} Kind of node

#### Returns

{Boolean} Whether or not the specified node is of the specified type

### createRenderRoot

> createRenderRoot: function()

#### Returns

{DOMElement} The specific render engine’s root element

### createRoot

> createRoot: function( | suffix | )

#### Parameters

suffix | {String} suffix to append to the id

#### Returns

{DOMElement}

### createDefs

> createDefs: function()

#### Returns

{DOMElement} The element to which we’ll add the symbol definitions

### drawPoint

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

This method is only called by the renderer itself.

#### Parameters

node | {DOMElement}
geometry | {OpenLayers.Geometry}

#### Returns

{DOMElement} or false if the renderer could not draw the point

### drawCircle

> drawCircle: function( | node,
> | geometry,
> | radius | )

This method is only called by the renderer itself.

#### Parameters

node | {DOMElement}
geometry | {OpenLayers.Geometry}
radius | {Float}

#### Returns

{DOMElement} or false if the renderer could not draw the circle

### drawLineString

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

This method is only called by the renderer itself.

#### Parameters

node | {DOMElement}
geometry | {OpenLayers.Geometry}

#### Returns

{DOMElement} or null if the renderer could not draw all components of the linestring, or false if nothing could be drawn

### drawLinearRing

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

This method is only called by the renderer itself.

#### Parameters

node | {DOMElement}
geometry | {OpenLayers.Geometry}

#### Returns

{DOMElement} or null if the renderer could not draw all components of the linear ring, or false if nothing could be drawn

### drawPolygon

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

This method is only called by the renderer itself.

#### Parameters

node | {DOMElement}
geometry | {OpenLayers.Geometry}

#### Returns

{DOMElement} or null if the renderer could not draw all components of the polygon, or false if nothing could be drawn

### drawRectangle

> drawRectangle: function( | node,
> | geometry | )

This method is only called by the renderer itself.

#### Parameters

node | {DOMElement}
geometry | {OpenLayers.Geometry}

#### Returns

{DOMElement} or false if the renderer could not draw the rectangle

### drawText

> drawText: function( | featureId,
> | style,
> | location | )

This method is only called by the renderer itself.

#### Parameters

featureId | {String} style -
location | {OpenLayers.Geometry.Point}

### getComponentString

#### Parameters

components | {Array(OpenLayers.Geometry.Point)} Array of points
separator | {String} character between coordinate pairs. Defaults to “,”

#### Returns

{Object} hash with properties “path” (the string created from the components and “complete” (false if the renderer was unable to draw all components)

### clipLine

> clipLine: function( | badComponent,
> | goodComponent | )

Given two points (one inside the valid range, and one outside), clips the line betweeen the two points so that the new points are both inside the valid range.

#### Parameters

badComponent | {OpenLayers.Geometry.Point} original geometry of the invalid point
goodComponent | {OpenLayers.Geometry.Point} original geometry of the valid point Returns {String} the SVG coordinate pair of the clipped point (like getShortString), or an empty string if both passed componets are at the same point.

### getShortString

> getShortString: function( | point | )

#### Parameters

point | {OpenLayers.Geometry.Point}

#### Returns

{String} or false if point is outside the valid range

### getPosition

> getPosition: function( | node | )

Finds the position of an svg node.

#### Parameters

node | {DOMElement}

#### Returns

{Object} hash with x and y properties, representing the coordinates within the svg coordinate system

### importSymbol

> importSymbol: function ( | graphicName | )

add a new symbol definition from the rendererer’s symbol hash

#### Parameters

graphicName | {String} name of the symbol to import

#### Returns

{DOMElement} | the imported symbol

### getFeatureIdFromEvent

> getFeatureIdFromEvent: function( | evt | )

#### Parameters

evt | {Object} An OpenLayers.Event object

#### Returns

{String} A feature id or undefined.

### Constants

### OpenLayers.Renderer.SVG.LABEL_ALIGN

{Object}

### OpenLayers.Renderer.SVG.LABEL_VSHIFT

{Object}

### OpenLayers.Renderer.SVG.LABEL_VFACTOR

{Object}

### Functions

### OpenLayers.Renderer.SVG.preventDefault

> OpenLayers.Renderer.SVG.preventDefault = function( | e | )

Deprecated. Use OpenLayers.Event.preventDefault method instead. Used to prevent default events (especially opening images in a new tab on ctrl-click) from being executed for externalGraphic symbols

> supported: function()

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

> inValidRange: function( | x,
> | y,
> | xyOnly | )

See #669 for more information

> setExtent: function( | extent,
> | resolutionChanged | )

> translate: function( | x,
> | y | )

Transforms the SVG coordinate system

> setSize: function( | size | )

Sets the size of the drawing surface.

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

> setStyle: function( | node,
> | style,
> | options | )

Use to set all the style attributes to a SVG node.

> dashStyle: function( | style,
> | widthFactor | )

> createNode: function( | type,
> | id | )

> nodeTypeCompare: function( | node,
> | type | )

> createRenderRoot: function()

{DOMElement} The specific render engine’s root element

> createRoot: function( | suffix | )

> createDefs: function()

{DOMElement} The element to which we’ll add the symbol definitions

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

This method is only called by the renderer itself.

> drawCircle: function( | node,
> | geometry,
> | radius | )

This method is only called by the renderer itself.

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

This method is only called by the renderer itself.

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

This method is only called by the renderer itself.

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

This method is only called by the renderer itself.

> drawRectangle: function( | node,
> | geometry | )

This method is only called by the renderer itself.

> drawText: function( | featureId,
> | style,
> | location | )

This method is only called by the renderer itself.

> clipLine: function( | badComponent,
> | goodComponent | )

Given two points (one inside the valid range, and one outside), clips the line betweeen the two points so that the new points are both inside the valid range.

> getShortString: function( | point | )

> getPosition: function( | node | )

Finds the position of an svg node.

> importSymbol: function ( | graphicName | )

add a new symbol definition from the rendererer’s symbol hash

> getFeatureIdFromEvent: function( | evt | )

> OpenLayers.Renderer.SVG.preventDefault = function( | e | )

Deprecated.
This is another virtual class in that it should never be instantiated by itself as a Renderer.
Instances of this class represent bounding boxes.
Instances of this class represent a width/height pair
A Geometry is a description of a geographic object.
Point geometry class.
Utility functions for event handling.

> preventDefault: function( | event | )

Cancels the event if it is cancelable, without stopping further propagation of the event.
Close