Class GSLayer

Extends GSAbstractLayer.

GSLayer objects are used to work with collections of features. Layers allow all features owned by the layer to be added, removed, or updated collectively.

Class Summary
Constructor Attributes Constructor Name and Description
 
GSLayer(name, options)
Creates a new GSLayer.
Properties borrowed from class GSAbstractLayer:
name
Method Summary
Method Attributes Method Name and Description
 
addFeature(feature)
Adds the specified feature to this layer.
 
addFeatures(features)
Adds the features in the specified array to this layer.
 
addFeaturesJson(data, onCreate, args)
Adds the features specified in JSON notation to this layer.
 
Removes all features from this layer
 
Returns the minimum bounds (NZMG) that encompasses all features that belong to this layer
 
Gets the feature with the passed id
 
Returns this layer's features
 
Called by the map when removing this layer
 
removeFeature(feature, destroy)
Removes the specified feature from this layer.
 
setVisible(visible)
Sets the visibility of the features contained by this layer
 
Outputs a JSON representation of this layer
 
Returns a string representation of this layer for debugging purposes
Methods borrowed from class GSAbstractLayer:
isBaseLayer, isVisible, setZIndex
Class Detail
GSLayer(name, options)
Creates a new GSLayer. The name parameter is required and is used to reference this layer in map operations that work with layers.
Parameters:
{String} name
the unique name for this layer
{Object} options Optional
an object literal specifying options for this layer. The following options may be specified:
{int} options.zIndex
the zIndex to display this layer at
{boolean} options.visible
true if this layer should initially be visible on the map (defaults to true)
Method Detail
addFeature(feature)
Adds the specified feature to this layer.
Parameters:
{Object} feature
the map feature to add

addFeatures(features)
Adds the features in the specified array to this layer.
Parameters:
{Array} features
an array of features to be added to this layer

addFeaturesJson(data, onCreate, args)
Adds the features specified in JSON notation to this layer. Currently this method can be used to instantiate point features only.

The minimum properties required for each POI data object are:

Parameters:
{Array} data
an array of map features described in JSON notation
{Function} onCreate
an optional callback function that will be called after each map feature has been created. It takes 2 parameters: the first is the instance of the feature class that's been created, and the 2nd is the current array element
{mixed} args Optional
any number of optional, user-defined arguments that will be passed to the onCreate callback function
Deprecated:
use GSLayer#addFeatures instead
Throws:
{Error}
if the feature data specifies a non-existent map feature class to instantiate

clear()
Removes all features from this layer

{GSBounds} getBounds()
Returns the minimum bounds (NZMG) that encompasses all features that belong to this layer
Returns:
{GSBounds} the minimum bounds that encompass this layer's features

{Object} getFeatureById(id)
Gets the feature with the passed id
Parameters:
id
Returns:
{Object} the feature with the passed id or undefined if no features were matched

{Array} getFeatures()
Returns this layer's features
Returns:
{Array} an array of map features

remove()
Called by the map when removing this layer

{GSMapFeature} removeFeature(feature, destroy)
Removes the specified feature from this layer.
Parameters:
{Object} feature
the map feature to remove
{Boolean} destroy
if true feature event listeners will be removed in addition to removing the feature from the DOM. Defaults to true
Returns:
{GSMapFeature} the map feature that was removed or null if the feature was not contained within this layer

setVisible(visible)
Sets the visibility of the features contained by this layer
Parameters:
{boolean} visible
true if this layer's features should be visible

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

{String} toString()
Returns a string representation of this layer for debugging purposes
Returns:
{String} the string representation of the features contained by this layer

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