Class GSVectorGraphics

Extends GSMapFeature.

GSVectorGraphics is the abstract base class for all vector graphics components in the SmartFIND Vector Graphics API, providing a cross-browser interface for creating and manipulating these components. It supports a subset of the SVG presentation attributes to set fill and stroke properties for each element.

Requires: svg module

Class Summary
Constructor Attributes Constructor Name and Description
 
GSVectorGraphics(options)
Method Summary
Method Attributes Method Name and Description
<static>  
GSVectorGraphics.canvasDashedLine(ctx, x, y, x2, y2, da)
Function to draw a dashed line using the Canvas element http://stackoverflow.com/questions/4576724/dotted-stroke-in-canvas
 
Gets the minimum bounding box necessary to contain this map feature.
 
Returns the current fill value for this shape
 
Returns the current fill opacity value for this shape
 
Returns the overall opacity value for this graphics element
 
Gets the canvas context, clears it and applies the stroke/fill styles
 
Returns the current stroke value for this shape
 
Returns the current stroke linecap for this shape
 
Returns the current stroke linejoin for this shape
 
Returns the current stroke opacity value for this shape
 
Returns the current stroke style for this shape
 
Returns the current stroke width value for this shape
 
Returns an object literal containing the current style properties set on this shape
 
setFill(value)
Sets the fill for the current graphics element using the browser-native interface
 
Sets the fill opacity for the current graphics element using the browser-native interface
 
setOpacity(value)
Sets the overall opacity for this graphics element using the browser-native interface
 
setStroke(value)
Sets the stroke for the current graphics element using the browser-native interface
 
Sets the stroke linecap for the current graphics element using the browser-native interface
 
Sets the stroke linejoin for the current graphics element using the browser-native interface
 
Sets the stroke opacity for the current graphics element using the browser-native interface
 
Sets the stroke style for the current graphics element using the browser-native interface
 
Sets the stroke width for the current graphics element using the browser-native interface
 
setStyle(style)
A hash of name-value pairs describing how this graphics element should be rendered.
 
setText(text, position, style)
Sets the text to appear inside of the graphics element
 
setVisible(value)
Sets the visibility of this shape
Methods borrowed from class GSMapFeature:
addContextMenuItem, addEventHandler, addEventListener, addListener, deleteProperty, deselect, disableContextMenu, enableContextMenu, getContextMenu, getProperties, getProperty, isSelectable, isVisible, removeContextMenu, removeContextMenuItem, removeEventHandler, removeEventListener, removeEventListeners, removeListener, select, setContextMenu, setProperty, setTip, setZIndex, showInfoWindow, toJson
Event Summary
Event Attributes Event Name and Description
 
shapeStyleChanged(shape, name, oldValue, newValue)
Events borrowed from class GSMapFeature:
featureClicked, featureRemoved
Class Detail
GSVectorGraphics(options)
Parameters:
options
Method Detail
<static> GSVectorGraphics.canvasDashedLine(ctx, x, y, x2, y2, da)
Function to draw a dashed line using the Canvas element http://stackoverflow.com/questions/4576724/dotted-stroke-in-canvas
Parameters:
ctx
x
y
x2
y2
da

{GSBounds} getBounds()
Gets the minimum bounding box necessary to contain this map feature. In GSVectorGraphics this method is abstract, subclasses should provide their own implementation of this method.
Returns:
{GSBounds} the bounds of this map feature

{String} getFill()
Returns the current fill value for this shape
Returns:
{String} the fill value

{Number} getFillOpacity()
Returns the current fill opacity value for this shape
Returns:
{Number} the fill opacity value

{Number} getOpacity()
Returns the overall opacity value for this graphics element
Returns:
{Number} the graphics element opacity

{CanvasRenderingContext2D} getPreparedCanvasContext()
Gets the canvas context, clears it and applies the stroke/fill styles
Returns:
{CanvasRenderingContext2D} the 2D canvas context

{String} getStroke()
Returns the current stroke value for this shape
Returns:
{String} the stroke value

{String} getStrokeLinecap()
Returns the current stroke linecap for this shape
Returns:
{String} the stroke linecap

{String} getStrokeLinejoin()
Returns the current stroke linejoin for this shape
Returns:
{String} the stroke linejoin

{Number} getStrokeOpacity()
Returns the current stroke opacity value for this shape
Returns:
{Number} the stroke opacity

{String} getStrokeStyle()
Returns the current stroke style for this shape
Returns:
{String} the stroke style

{Number} getStrokeWidth()
Returns the current stroke width value for this shape
Returns:
{Number} the stroke width value

{Object} getStyle()
Returns an object literal containing the current style properties set on this shape
Returns:
{Object} the style properties of this shape

{GSVectorGraphics} setFill(value)
Sets the fill for the current graphics element using the browser-native interface
Parameters:
{String} value
a paint value which may be none indicating that no paint is applied, or a color value specified using either an HTML4 keyword, RGB hex value, or rgb(...) functional value
Returns:
{GSVectorGraphics} a reference to this vector graphics map feature

{GSVectorGraphics} setFillOpacity(value)
Sets the fill opacity for the current graphics element using the browser-native interface
Parameters:
{Number} value
a decimal value in the range of 0.0 (fully transparent) to 1.0 (fully opaque).
Returns:
{GSVectorGraphics} a reference to this vector graphics map feature

{GSVectorGraphics} setOpacity(value)
Sets the overall opacity for this graphics element using the browser-native interface
Parameters:
{Number} value
a decimal value in the range of 0.0 (fully transparent) to 1.0 (fully opaque).
Returns:
{GSVectorGraphics} a reference to this vector graphics map feature

{GSVectorGraphics} setStroke(value)
Sets the stroke for the current graphics element using the browser-native interface
Parameters:
{String} value
a paint value which may be none indicating that no paint is applied, or a color value specified using either an HTML4 keyword, RGB hex value, or rgb(...) functional value
Returns:
{GSVectorGraphics} a reference to this vector graphics map feature

{GSVectorGraphics} setStrokeLinecap(value)
Sets the stroke linecap for the current graphics element using the browser-native interface
Parameters:
{String} value
the new value for the stroke linecap ('butt', 'round', or 'square')
Returns:
{GSVectorGraphics} a reference to this vector graphics map feature

{GSVectorGraphics} setStrokeLinejoin(value)
Sets the stroke linejoin for the current graphics element using the browser-native interface
Parameters:
{String} value
the new value for the stroke linejoin ('miter', 'round', or 'bevel')
Returns:
{GSVectorGraphics} a reference to this vector graphics map feature

{GSVectorGraphics} setStrokeOpacity(value)
Sets the stroke opacity for the current graphics element using the browser-native interface
Parameters:
{Number} value
a decimal value in the range of 0.0 (fully transparent) to 1.0 (fully opaque).
Returns:
{GSVectorGraphics} a reference to this vector graphics map feature

{GSVectorGraphics} setStrokeStyle(value)
Sets the stroke style for the current graphics element using the browser-native interface
Parameters:
{String} value
the new value for the stroke style ('solid', or 'dashed')
Returns:
{GSVectorGraphics} a reference to this vector graphics map feature

{GSVectorGraphics} setStrokeWidth(value)
Sets the stroke width for the current graphics element using the browser-native interface
Parameters:
{int} value
the new value for the stroke width (in pixels)
Returns:
{GSVectorGraphics} a reference to this vector graphics map feature

setStyle(style)
A hash of name-value pairs describing how this graphics element should be rendered.
Parameters:
{Object} style
properties specified as name-value pairs. A subset of the SVG presentation attributes are supported:
{String} style.stroke
this property paints along the outline of the given graphical element. It takes a paint value which may be none indicating that no paint is applied, or a color value specified using either an HTML4 keyword, RGB hex value, or rgb(...) functional value Note that paint server URIs are not supported as paint values.
{int} style.stroke-width
the width of the stroke on the current object
{float} style.stroke-opacity
specifies the opacity of the painting operation used to stroke the current object. Value should be in the range of 0.0 (fully transparent) to 1.0 (fully opaque).
{String} style.stroke-linecap
specifies the shape of the endpoints of the painting operation used to stroke the current object. Value should be one of: butt | round | square.
{String} style.stroke-linejoin
specifies the way lines connect at the corners of the current object. Value should be one of: miter | round | bevel.
{float} style.stroke-opacity
specifies the opacity of the painting operation used to stroke the current object. Value should be in the range of 0.0 (fully transparent) to 1.0 (fully opaque).
{String} style.stroke-style
specifies the style of the line use to stroke the current object. Value should be one of: solid | dashed
{String} style.fill
this property paints the interior of the given graphical element. It takes a paint value which may be none indicating that no paint is applied, or a color value specified using either an HTML4 keyword, RGB hex value, or rgb(...) functional value Note that paint server URIs are not supported as paint values.
{String} style.fill-opacity
specifies the opacity of the painting operation used to paint the interior of the current object. Value should be in the range of 0.0 (fully transparent) to 1.0 (fully opaque).
{String} style.opacity
the uniform opacity setting to be applied across an entire object.

setText(text, position, style)
Sets the text to appear inside of the graphics element
var text = '12345';
var textPosition = {x: 10px, y: 10px};
var textStyle = {color: '#a80510', 'font-weight': 'normal', 'font-size': '20px'};
feature.setText(text, textPosition, textStyle);
Parameters:
{String} text
the text to set
{GSPoint} position Optional
specifies the position of the text element relative to the coordinate system of the shape's bounding box. x and y values are specified in pixels
{Object} style Optional
text style properties specified as name-value pairs A subset of the CSS styling properties are supported:
{String} style.font-family
a prioritized list of font family names
{String} style.font-size
the size of the font, may use absolute or relative units
{String} style.font-weight
the boldness or lightness of the glyphs used to render the text, available values: normal | bold | bolder | lighter | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 (higher values represent greater boldness)
{String} style..font-style
specifies whether the text is to be rendered using a normal, italic or oblique face, available values: normal | italic | oblique
{String} style.color
the color to render the text, may be specified using either an HTML4 keyword, RGB hex value, or rgb(...) functional value
{String} style.text-align
aligns the text within this shape. Availiable values: left | center | right
{String} style.vertical-align
vertically aligns the text within this shape. Available values: top | middle | bottom

setVisible(value)
Sets the visibility of this shape
Parameters:
{boolean} value
true if this feature should be visible on the map
Event Detail
shapeStyleChanged(shape, name, oldValue, newValue)
Parameters:
{GSVectorGraphics} shape
a reference to the shape that was changed
{String} name
the name of the style property that was changed
{String} oldValue
the old value of the style property
{String} newValue
the new value of the style property

Documentation generated by JsDoc Toolkit 2.3.2 on Wed Mar 07 2012 11:47:30 GMT+1300 (NZDT)