OpenLayers. Layer. Vector

Instances of OpenLayers.Layer.Vector are used to render vector data from a variety of sources.  Create a new image layer with the OpenLayers.Layer.Vector constructor.

Inherits from

Summary
Instances of OpenLayers.Layer.Vector are used to render vector data from a variety of sources.
{Boolean} The layer is a base layer.
{Boolean} Whether the layer remains in one place while dragging the map.
{Boolean} Whether the layer is a vector layer.
{Boolean} report error message via alert() when loading of renderers fails.
{Object} Default style for the layer
Array({String}) List of supported Renderer classes.
{String} geometryType allows you to limit the types of geometries this layer supports.
{Boolean} Whether the Vector Layer features have been drawn yet.
Create a new vector layer
Destroy this layer
Iterates through the available renderer implementations and selects and assigns the first one whose “supported()” function returns true.
Let the user know their browser isn’t supported.
The layer has been added to the map.
Notify the renderer of the change in size.
Reset the vector layer’s div so that it once again is lined up with the map.
Add Features to the layer.
Destroy all features on the layer and empty the selected features array.
Draw (or redraw) a feature on the layer.
Erase features from the layer.
Given an event, return a feature if the event occurred over one.
Given a feature id, return the feature if it exists in the features array
method called after a feature is inserted.
method called before a feature is inserted.

Properties

isBaseLayer

{Boolean} The layer is a base layer.  Default is true.  Set this property in the layer options

isFixed

{Boolean} Whether the layer remains in one place while dragging the map.

isVector

{Boolean} Whether the layer is a vector layer.

features

selectedFeatures

reportError

{Boolean} report error message via alert() when loading of renderers fails.

style

{Object} Default style for the layer

renderers

Array({String}) List of supported Renderer classes.  Add to this list to add support for additional renderers.  This list is ordered: the first renderer which returns true for the ‘supported()’ method will be used, if not defined in the ‘renderer’ option.

geometryType

{String} geometryType allows you to limit the types of geometries this layer supports.  This should be set to something like “OpenLayers.Geometry.Point” to limit types.

drawn

{Boolean} Whether the Vector Layer features have been drawn yet.

Constructor

OpenLayers. Layer. Vector

Create a new vector layer

Parameters

name{String} A name for the layer
options{Object} options Object with non-default properties to set on the layer.

Returns

{OpenLayers.Layer.Vector} A new vector layer

Functions

destroy

destroy: function()

Destroy this layer

assignRenderer

assignRenderer: function()

Iterates through the available renderer implementations and selects and assigns the first one whose “supported()” function returns true.

displayError

displayError: function()

Let the user know their browser isn’t supported.

setMap

setMap: function(map)

The layer has been added to the map.

If there is no renderer set, the layer can’t be used.  Remove it.  Otherwise, give the renderer a reference to the map and set its size.

Parameters

map{OpenLayers.Map}

onMapResize

onMapResize: function()

Notify the renderer of the change in size.

moveTo

moveTo: function(bounds,
zoomChanged,
dragging)

Reset the vector layer’s div so that it once again is lined up with the map.  Notify the renderer of the change of extent, and in the case of a change of zoom level (resolution), have the renderer redraw features.

If the layer has not yet been drawn, cycle through the layer’s features and draw each one.

Parameters

bounds{OpenLayers.Bounds}
zoomChanged{Boolean}
dragging{Boolean}

addFeatures

addFeatures: function(features)

Add Features to the layer.

Parameters

features{Array(OpenLayers.Feature.Vector)}

removeFeatures

removeFeatures: function(features)

Parameters

features{Array(OpenLayers.Feature.Vector)}

destroyFeatures

destroyFeatures: function ()

Destroy all features on the layer and empty the selected features array.

drawFeature

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.

Parameters

feature{OpenLayers.Feature.Vector}
style{Object}

eraseFeatures

eraseFeatures: function(features)

Erase features from the layer.

Parameters

features{Array(OpenLayers.Feature.Vector)}

getFeatureFromEvent

getFeatureFromEvent: function(evt)

Given an event, return a feature if the event occurred over one.  Otherwise, return null.

Parameters

evt{Event}

Returns

{OpenLayers.Feature.Vector} A feature if one was under the event.

getFeatureById

getFeatureById: function(featureId)

Given a feature id, return the feature if it exists in the features array

Parameters

featureId{String}

Returns

{OpenLayers.Feature.Vector} A feature corresponding to the given featureId

onFeatureInsert

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.

Paarameters

feature{OpenLayers.Feature.Vector}

preFeatureInsert

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.

Parameters

feature{OpenLayers.Feature.Vector}
Vector features use the OpenLayers.Geometry classes as geometry description.
This is the base class for all renderers.
destroy: function()
Destroy this layer
assignRenderer: function()
Iterates through the available renderer implementations and selects and assigns the first one whose “supported()” function returns true.
displayError: function()
Let the user know their browser isn’t supported.
setMap: function(map)
The layer has been added to the map.
onMapResize: function()
Notify the renderer of the change in size.
moveTo: function(bounds,
zoomChanged,
dragging)
Reset the vector layer’s div so that it once again is lined up with the map.
addFeatures: function(features)
Add Features to the layer.
removeFeatures: function(features)
destroyFeatures: function ()
Destroy all features on the layer and empty the selected features array.
drawFeature: function(feature,
style)
Draw (or redraw) a feature on the layer.
eraseFeatures: function(features)
Erase features from the layer.
getFeatureFromEvent: function(evt)
Given an event, return a feature if the event occurred over one.
getFeatureById: function(featureId)
Given a feature id, return the feature if it exists in the features array
onFeatureInsert: function(feature)
method called after a feature is inserted.
preFeatureInsert: function(feature)
method called before a feature is inserted.
Create a new vector layer
Instances of OpenLayers.Map are interactive maps embedded in a web page.
Instances of this class represent bounding boxes.