Instances of OpenLayers.Layer.Vector are used to render vector data from a variety of sources. Create a new vector layer with the OpenLayers.Layer.Vector constructor.
| OpenLayers. | Instances of OpenLayers.Layer.Vector are used to render vector data from a variety of sources. |
| Properties | |
| isBaseLayer | {Boolean} The layer is a base layer. |
| isFixed | {Boolean} Whether the layer remains in one place while dragging the map. |
| features | {Array(OpenLayers.Feature.Vector)} |
| reportError | {Boolean} report friendly error message when loading of renderer fails. |
| style | {Object} Default style for the layer |
| rendererOptions | {Object} Options for the renderer. |
| geometryType | {String} geometryType allows you to limit the types of geometries this layer supports. |
| ratio | {Float} This specifies the ratio of the size of the visiblity of the Vector Layer features to the size of the map. |
| Constructor | |
| OpenLayers. | Create a new vector layer |
| Functions | |
| destroy | Destroy this layer |
| redraw | Redraws the layer. |
| display | Hide or show the Layer |
| addFeatures | Add Features to the layer. |
| removeFeatures | Remove features from the layer. |
| removeAllFeatures | Remove all features from the layer. |
| destroyFeatures | Erase and destroy features on the layer. |
| drawFeature | Draw (or redraw) a feature on the layer. |
| getFeatureBy | Given a property value, return the feature if it exists in the features array |
| getFeatureById | Given a feature id, return the feature if it exists in the features array |
| getFeatureByFid | Given a feature fid, return the feature if it exists in the features array |
| getFeaturesByAttribute | Returns an array of features that have the given attribute key set to the given value. |
| onFeatureInsert | method called after a feature is inserted. |
| preFeatureInsert | method called before a feature is inserted. |
| getDataExtent | Calculates the max extent which includes all of the features. |
{Array(OpenLayers.Feature.Vector)}
{Object} Options for the renderer. See {OpenLayers.Renderer} for supported options.
Create a new vector layer
| name | {String} A name for the layer |
| options | {Object} Optional object with non-default properties to set on the layer. |
{OpenLayers.Layer.Vector} A new vector layer
addFeatures: function( features, options )
Add Features to the layer.
| features | {Array(OpenLayers.Feature.Vector)} |
| options | {Object} |
removeFeatures: function( features, options )
Remove features from the layer. This erases any drawn features and removes them from the layer’s control. The beforefeatureremoved and featureremoved events will be triggered for each feature. The featuresremoved event will be triggered after all features have been removed. To supress event triggering, use the silent option.
| features | {Array(OpenLayers.Feature.Vector)} List of features to be removed. |
| options | {Object} Optional properties for changing behavior of the removal. |
| silent | {Boolean} Supress event triggering. Default is false. |
destroyFeatures: function( features, options )
Erase and destroy features on the layer.
| features | {Array(OpenLayers.Feature.Vector)} An optional array of features to destroy. If not supplied, all features on the layer will be destroyed. |
| options | {Object} |
drawFeature: function( feature, style )
Draw (or redraw) a feature on the layer. If the optional style argument is included, this style will be used. If no style is included, the feature’s style will be used. If the feature doesn’t have a style, the layer’s style will be used.
This function is not designed to be used when adding features to the layer (use addFeatures instead). It is meant to be used when the style of a feature has changed, or in some other way needs to visually updated after it has already been added to a layer. You must add the feature to the layer for most layer-related events to happen.
| feature | {OpenLayers.Feature.Vector} |
| style | {String | Object} Named render intent or full symbolizer object. |
getFeatureBy: function( property, value )
Given a property value, return the feature if it exists in the features array
| property | {String} |
| value | {String} |
{OpenLayers.Feature.Vector} A feature corresponding to the given property value or null if there is no such feature.
getFeatureById: function( featureId )
Given a feature id, return the feature if it exists in the features array
| featureId | {String} |
{OpenLayers.Feature.Vector} A feature corresponding to the given featureId or null if there is no such feature.
getFeatureByFid: function( featureFid )
Given a feature fid, return the feature if it exists in the features array
| featureFid | {String} |
{OpenLayers.Feature.Vector} A feature corresponding to the given featureFid or null if there is no such feature.
getFeaturesByAttribute: function( attrName, attrValue )
Returns an array of features that have the given attribute key set to the given value. Comparison of attribute values takes care of datatypes, e.g. the string ‘1234’ is not equal to the number 1234.
| attrName | {String} |
| attrValue | {Mixed} |
Array(OpenLayers.Feature.Vector) An array of features that have the passed named attribute set to the given value.
onFeatureInsert: function( feature )
method called after a feature is inserted. Does nothing by default. Override this if you need to do something on feature updates.
| feature | {OpenLayers.Feature.Vector} |
preFeatureInsert: function( feature )
method called before a feature is inserted. Does nothing by default. Override this if you need to do something when features are first added to the layer, but before they are drawn, such as adjust the style.
| feature | {OpenLayers.Feature.Vector} |
getDataExtent: function ()
Calculates the max extent which includes all of the features.
{OpenLayers.Bounds} or null if the layer has no features with geometries.
Destroy this layer
destroy: function()
Redraws the layer.
redraw: function()
Hide or show the Layer
display: function( display )
Add Features to the layer.
addFeatures: function( features, options )
Remove features from the layer.
removeFeatures: function( features, options )
Remove all features from the layer.
removeAllFeatures: function( options )
Erase and destroy features on the layer.
destroyFeatures: function( features, options )
Draw (or redraw) a feature on the layer.
drawFeature: function( feature, style )
Given a property value, return the feature if it exists in the features array
getFeatureBy: function( property, value )
Given a feature id, return the feature if it exists in the features array
getFeatureById: function( featureId )
Given a feature fid, return the feature if it exists in the features array
getFeatureByFid: function( featureFid )
Returns an array of features that have the given attribute key set to the given value.
getFeaturesByAttribute: function( attrName, attrValue )
method called after a feature is inserted.
onFeatureInsert: function( feature )
method called before a feature is inserted.
preFeatureInsert: function( feature )
Calculates the max extent which includes all of the features.
getDataExtent: function ()