Articles and Tutorials
GSLayer
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.Object
|
+--GSLayer
| Field Summary | |
| String | name The layer name |
| Constructor Summary | |
| GSLayer (<String> name) GSLayer should not be directly instantiated, it's created through a call to the GSMap object that will contain the layer. | |
| Method Summary | |
| void | addFeature(<Object> feature) Adds the specified feature to this layer. |
| void | addFeatures(features) Adds the features in the specified array to this layer. |
| void | addFeaturesJson(<Array> data, <Function> onCreate) Adds the features specified in JSON notation to this layer. |
| void | clear() Removes all features from this layer |
| GSBounds | getBounds() Returns the minimum bounds (NZMG) that encompasses all features that belong to this layer |
| boolean | isVisible() Returns a boolean value indicating the visibility of the features added to this layer |
| void | removeFeature(<Object> feature) Removes the specified feature from this layer. |
| void | setVisible(<boolean> visible) Sets the visibility of the features contained by this layer |
| String | toString() Returns a string representation of this layer for debugging purposes |
| Field Detail |
name
String name- The layer name
| Constructor Detail |
GSLayer
GSLayer(<String> name)- GSLayer should not be directly instantiated, it's created through a call to the GSMap object that will contain the layer. Creates a new GSLayer. The name parameter is required and is used to reference this layer in map operations that work with layers.
-
- name - the unique name for this layer
Parameters:
| Method Detail |
addFeature
void addFeature(<Object> feature)- Adds the specified feature to this layer.
-
- feature - the map feature to add
Parameters:
addFeatures
void addFeatures(features)- Adds the features in the specified array to this layer.
-
- an - array of features to be added to this layer
Parameters:
addFeaturesJson
void addFeaturesJson(<Array> data, <Function> onCreate)-
- name - this will be displayed in the POI feature tooltip
- x - the NZMG X coordinate
- y - the NZMG Y coordinate
- jsclass - the map feature class that should be instantiated, in this case GSPointFeature
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:
-
- data - an array of map features described in JSON notation
- 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
- arg - any number of optional, user-defined arguments that will be passed to the onCreate callback function
Parameters:
-
- - NoSuchClassException if the feature data specifies a non-existent map feature class to instantiate
Throws:
clear
void clear()- Removes all features from this layer
getBounds
GSBounds getBounds()- Returns the minimum bounds (NZMG) that encompasses all features that belong to this layer
-
- the minimum bounds that encompass this layer's features
Returns:
isVisible
boolean isVisible()- Returns a boolean value indicating the visibility of the features added to this layer
-
- true if this layer's features are currently visible on the map
Returns:
removeFeature
void removeFeature(<Object> feature)- Removes the specified feature from this layer.
-
- feature - the map feature to remove
Parameters:
setVisible
void setVisible(<boolean> visible)- Sets the visibility of the features contained by this layer
-
- visible - true if this layer's features should be visible
Parameters:
toString
String toString()- Returns a string representation of this layer for debugging purposes
-
- the string representation of the features contained by this layer
Returns:

