Class GSPolyline

Extends GSVectorGraphics, GSVectorGraphics.

GSPolyline represents a vector-based polyline feature. A polyline defines a set of connected straight line segments. Typically 'polyline' elements define open shapes.

Requires: svg module

Class Summary
Constructor Attributes Constructor Name and Description
 
GSPolyline(points, options)
Constructs a new GSPolyline
Method Summary
Method Attributes Method Name and Description
 
addPoint(point)
Adds a new point to this shape
 
addPointAt(point, idx)
Adds a new point to this shape at the specified index
 
Creates a copy of this polyline
 
Deselects this polyline
 
Gets the minimum bounding box necessary to contain this map feature
 
Returns the NZMG coordinates that define this this shape
 
Hides the drag handles for this shape
 
A boolean flag indicating if this is currently in editing mode
 
A boolean flag indicating if this is currently in editing mode
 
Returns true if other features may be snapped to the vertices of this feature
 
projectPoint(point)
Projects a point onto this polyline
 
removePoint(point)
Removes the specified point from this shape
 
Removes the specified point from this shape at the specified index
 
replacePoint(newPoint, oldPoint)
Replaces an existing point with a new point
 
Selects this polyline
 
setPoints(points)
Sets the array of NZMG points that describe this polyline.
 
Returns true if the handles of this polyline should be able to be snapped to snappable points on the map
 
Shows the drag handles for this shape.
 
Enables editing of this shape.
 
Enables editing of this shape.
 
Disables editing of this shape.
 
Outputs a GML representation of this map feature.
 
Outputs a JSON representation of this map feature
 
Outputs a Well-Known Text (WKT) representation of this map feature.
Methods borrowed from class GSVectorGraphics:
getFill, getFillOpacity, getOpacity, getPreparedCanvasContext, getStroke, getStrokeLinecap, getStrokeLinejoin, getStrokeOpacity, getStrokeStyle, getStrokeWidth, getStyle, setFill, setFillOpacity, setOpacity, setStroke, setStrokeLinecap, setStrokeLinejoin, setStrokeOpacity, setStrokeStyle, setStrokeWidth, setStyle, setText, setVisible
Methods borrowed from class GSMapFeature:
addContextMenuItem, addEventHandler, addEventListener, addListener, deleteProperty, disableContextMenu, enableContextMenu, getContextMenu, getProperties, getProperty, isSelectable, isVisible, removeContextMenu, removeContextMenuItem, removeEventHandler, removeEventListener, removeEventListeners, removeListener, setContextMenu, setProperty, setTip, setZIndex, showInfoWindow
Events borrowed from class GSVectorGraphics:
shapeStyleChanged
Events borrowed from class GSMapFeature:
featureClicked, featureRemoved
Class Detail
GSPolyline(points, options)
Constructs a new GSPolyline
Parameters:
{Array} points
the NZMG coordinates describing this polyline specified as an array of GSPoint instances
{Object} options Optional
optional configuration properties to set on this feature:
{Object} options.style
properties specified as name-value pairs. A subset of the SVG presentation attributes are supported:
{String} options.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} options.style.stroke-width
the width of the stroke on the current object
{float} options.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} options.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} options.style.stroke-linejoin
specifies the way lines connect at the corners of the current object. Value should be one of: miter | round | bevel.
{float} options.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} options.style.stroke-style
specifies the style of the line use to stroke the current object. Value should be one of: solid | dashed
{String} options.style.opacity
the uniform opacity setting to be applied across an entire object.
{String} options.text
a label to be displayed on this feature
{GSPoint} options.text-position
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} options.text-style
style properties specified as name-value pairs A subset of the CSS styling properties are supported:
{String} options.text-style.font-family
a prioritized list of font family names
{String} options.text-style.font-size
the size of the font, may use absolute or relative units
{String} options.text-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} options.text-style.font-style
specifies whether the text is to be rendered using a normal, italic or oblique face, available values: normal | italic | oblique
{String} options.text-style.color
the color to render the text, may be specified using either an HTML4 keyword, RGB hex value, or rgb(...) functional value
{String} options.text-style.text-align
aligns the text within this shape. Availiable values: left | center | right
{String} options.text-style.vertical-align
vertically aligns the text within this shape. Available values: top | middle | bottom
{boolean} options.editable
true if context menu actions should be enabled for editing this feature. Defaults to false
{boolean} options.clickToEdit
if true, and the editable option is also true, the feature geometry may be edited by clicking it
{boolean} options.snapHandles
if true this feature's handles will 'snap' to any features visible within the map viewport marked as snappable
{boolean} options.snappable
if true if other features may be snapped to the vertices of this feature
Method Detail
addPoint(point)
Adds a new point to this shape
Parameters:
{GSPoint} point
the point to add

addPointAt(point, idx)
Adds a new point to this shape at the specified index
Parameters:
{GSPoint} point
the point to add
{int} idx
the index to add the point at

{GSPolyline} clone()
Creates a copy of this polyline
Returns:
{GSPolyline} a copy of this polyline

deselect()
Deselects this polyline

{GSBounds} getBounds()
Gets the minimum bounding box necessary to contain this map feature
Returns:
{GSBounds} the bounds of this map feature

{Array} getPoints()
Returns the NZMG coordinates that define this this shape
Returns:
{Array} an array of GSPoint objects

hideHandles()
Hides the drag handles for this shape
Deprecated:
Since version 3.0. Use stopEditing instead

{boolean} isCreating()
A boolean flag indicating if this is currently in editing mode
Returns:
{boolean} true if this shape is currently in editing mode

{boolean} isEditing()
A boolean flag indicating if this is currently in editing mode
Returns:
{boolean} true if this shape is currently in editing mode

{boolean} isSnappable()
Returns true if other features may be snapped to the vertices of this feature
Returns:
{boolean} the value of the options.snappable property

{Object} projectPoint(point)
Projects a point onto this polyline
Parameters:
{GSPoint} point
The point to project onto the polyline
Throws:
{Error}
if the polyline contains < 2 points
Returns:
{Object} An object with properties: "distance" from the polyline; and the "coordinate" of where on the polyline the point was projected; "start" and "end" points of line segment

{boolean} removePoint(point)
Removes the specified point from this shape
Parameters:
{GSPoint} point
the NZMG point to remove from this shape
Returns:
{boolean} true if the point was removed

{boolean} removePointAt(idx)
Removes the specified point from this shape at the specified index
Parameters:
{int} idx
the index of the point to remove
Returns:
{boolean} true if the point was removed

replacePoint(newPoint, oldPoint)
Replaces an existing point with a new point
Parameters:
{GSPoint} newPoint
the replacement point
{GSPoint} oldPoint
the point to be replaced

select()
Selects this polyline

setPoints(points)
Sets the array of NZMG points that describe this polyline. All coordinate values are specified using the GSPoint class
Parameters:
{Array} points
the points to set. If an odd number of coordinates is provided the element will not be rendered

{boolean} shouldSnapHandles()
Returns true if the handles of this polyline should be able to be snapped to snappable points on the map
Returns:
{boolean} the value of the options.snapHandles property

showHandles()
Shows the drag handles for this shape. For each vertice of the shape a drag handle is provided
Deprecated:
Since version 3.0. Use startEditing() instead

startCreating()
Enables editing of this shape.

startEditing()
Enables editing of this shape.

stopEditing()
Disables editing of this shape.

{String} toGML()
Outputs a GML representation of this map feature. Output is a GML 2.x string.
Returns:
{String} a GML string

{String} toJson()
Outputs a JSON representation of this map feature
Returns:
{String} a JSON string

{String} toWKT()
Outputs a Well-Known Text (WKT) representation of this map feature.
Returns:
{String} a WKT string

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