OpenLayers.Layer.Vector - OpenLayers

# OpenLayers. Layer. Vector

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.

#### Inherits from

- OpenLayers.Layer

Summary

OpenLayers. Layer. Vector | Instances of OpenLayers.Layer.Vector are used to render vector data from a variety of sources.
Constants |
EVENT_TYPES | {Array(String)} Supported application event types.
Properties |
isBaseLayer | {Boolean} The layer is a base layer.
isFixed | {Boolean} Whether the layer remains in one place while dragging the map.
isVector | {Boolean} Whether the layer is a vector layer.
features | {Array(OpenLayers.Feature.Vector)}
selectedFeatures | {Array(OpenLayers.Feature.Vector)}
unrenderedFeatures | {Object} hash of features, keyed by feature.id, that the renderer failed to draw
reportError | {Boolean} report friendly error message when loading of renderer fails.
style | {Object} Default style for the layer
styleMap | {OpenLayers.StyleMap}
strategies | {Array(OpenLayers.Strategy})} Optional list of strategies for the layer.
protocol | {OpenLayers.Protocol} Optional protocol for the layer.
renderers | {Array(String)} List of supported Renderer classes.
renderer | {OpenLayers.Renderer}
rendererOptions | {Object} Options for the renderer.
geometryType | {String} geometryType allows you to limit the types of geometries this layer supports.
drawn | {Boolean} Whether the Vector Layer features have been drawn yet.
Constructor |
OpenLayers. Layer. Vector | Create a new vector layer
Functions |
destroy | Destroy this layer
refresh | Ask the layer to request features again and redraw them.
assignRenderer | Iterates through the available renderer implementations and selects and assigns the first one whose “supported()” function returns true.
displayError | Let the user know their browser isn’t supported.
setMap | The layer has been added to the map.
removeMap | The layer has been removed from the map.
onMapResize | Notify the renderer of the change in size.
moveTo | Reset the vector layer’s div so that it once again is lined up with the map.
addFeatures | Add Features to the layer.
removeFeatures |
destroyFeatures | Erase and destroy features on the layer.
drawFeature | Draw (or redraw) a feature on the layer.
eraseFeatures | Erase features from the layer.
getFeatureFromEvent | Given an event, return a feature if the event occurred over one.
getFeatureById | Given a feature id, return the feature if it exists in the features array
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.

### Constants

### EVENT_TYPES

{Array(String)} Supported application event types. Register a listener for a particular event with the following syntax:

>     layer.events.register(type, obj, listener);

Listeners will be called with a reference to an event object. The properties of this event depends on exactly what happened.

#### All event objects have at least the following properties

- object {Object} A reference to layer.events.object.
- element {DOMElement} A reference to layer.events.element.

#### Supported map event types (in addition to those from OpenLayers.Layer)

- beforefeatureadded Triggered before a feature is added. Listeners will receive an object with a feature property referencing the feature to be added. To stop the feature from being added, a listener should return false.
- beforefeaturesadded Triggered before an array of features is added. Listeners will receive an object with a features property referencing the feature to be added. To stop the features from being added, a listener should return false.
- featureadded Triggered after a feature is added. The event object passed to listeners will have a feature property with a reference to the added feature.
- featuresadded Triggered after features are added. The event object passed to listeners will have a features property with a reference to an array of added features.
- beforefeatureremoved Triggered before a feature is removed. Listeners will receive an object with a feature property referencing the feature to be removed.
- featureremoved Triggerd after a feature is removed. The event object passed to listeners will have a feature property with a reference to the removed feature.
- featuresremoved Triggered after features are removed. The event object passed to listeners will have a features property with a reference to an array of removed features.
- featureselected Triggered after a feature is selected. Listeners will receive an object with a feature property referencing the selected feature.
- featureunselected Triggered after a feature is unselected. Listeners will receive an object with a feature property referencing the unselected feature.
- beforefeaturemodified Triggered when a feature is selected to be modified. Listeners will receive an object with a feature property referencing the selected feature.
- featuremodified Triggered when a feature has been modified. Listeners will receive an object with a feature property referencing the modified feature.
- afterfeaturemodified Triggered when a feature is finished being modified. Listeners will receive an object with a feature property referencing the modified feature.
- refresh Triggered when something wants a strategy to ask the protocol for a new set of features.

### 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

{Array(OpenLayers.Feature.Vector)}

### selectedFeatures

{Array(OpenLayers.Feature.Vector)}

### unrenderedFeatures

{Object} hash of features, keyed by feature.id, that the renderer failed to draw

### reportError

{Boolean} report friendly error message when loading of renderer fails.

### style

{Object} Default style for the layer

### styleMap

{OpenLayers.StyleMap}

### strategies

{Array(OpenLayers.Strategy})} Optional list of strategies for the layer.

### protocol

{OpenLayers.Protocol} Optional protocol 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.

### renderer

{OpenLayers.Renderer}

### rendererOptions

{Object} Options for the renderer. See {OpenLayers.Renderer} for supported options.

### 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} Optional 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

### refresh

> refresh: function( | obj | )

Ask the layer to request features again and redraw them. Triggers the refresh event if the layer is in range and visible.

#### Parameters

obj | {Object} Optional object with properties for any listener of the refresh event.

### 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}

### removeMap

> removeMap: function( | map | )

The layer has been removed from the map.

#### 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,
> | options | )

Add Features to the layer.

#### Parameters

features | {Array(OpenLayers.Feature.Vector)}
options | {Object}

### removeFeatures

> removeFeatures: function( | features,
> | options | )

#### Parameters

features | {Array(OpenLayers.Feature.Vector)}
options | {Object}

### destroyFeatures

> destroyFeatures: function( | features,
> | options | )

Erase and destroy features on the layer.

#### Parameters

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

> 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} Symbolizer hash or {String} renderIntent

### 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}

### getDataExtent

> getDataExtent: function ()

Calculates the max extent which includes all of the features.

#### Returns

{OpenLayers.Bounds}

Vector features use the OpenLayers.Geometry classes as geometry description.
Abstract vector layer strategy class.
Abstract vector layer protocol class.
This is the base class for all renderers.

> destroy: function()

Destroy this layer

> refresh: function( | obj | )

Ask the layer to request features again and redraw them.

> 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.

> removeMap: function( | map | )

The layer has been removed from 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,
> | options | )

Add Features to the layer.

> removeFeatures: function( | features,
> | options | )

> destroyFeatures: function( | features,
> | options | )

Erase and destroy features on the layer.

> 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.

> getDataExtent: function ()

Calculates the max extent which includes all of the features.
Create a new vector layer
Instances of OpenLayers.Map are interactive maps embedded in a web page.
Instances of this class represent bounding boxes.
Close