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. 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. |
{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.
{Array(OpenLayers.Feature.Vector)}
{Array(OpenLayers.Feature.Vector)}
{Array(OpenLayers.Strategy})} Optional list of strategies for the layer.
{OpenLayers.Protocol} Optional protocol for the layer.
{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
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.
map | {OpenLayers.Map} |
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.
bounds | {OpenLayers.Bounds} |
zoomChanged | {Boolean} |
dragging | {Boolean} |
addFeatures: function( features, options )
Add Features to the layer.
features | {Array(OpenLayers.Feature.Vector)} |
options | {Object} |
removeFeatures: function( features, options )
features | {Array(OpenLayers.Feature.Vector)} |
options | {Object} |
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.
feature | {OpenLayers.Feature.Vector} |
style | {Object} Symbolizer hash or {String} renderIntent |
eraseFeatures: function( features )
Erase features from the layer.
features | {Array(OpenLayers.Feature.Vector)} |
getFeatureFromEvent: function( evt )
Given an event, return a feature if the event occurred over one. Otherwise, return null.
evt | {Event} |
{OpenLayers.Feature.Vector} A feature if one was under the event.
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
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} |
Destroy this layer
destroy: function()
Ask the layer to request features again and redraw them.
refresh: function( obj )
Iterates through the available renderer implementations and selects and assigns the first one whose “supported()” function returns true.
assignRenderer: function()
Let the user know their browser isn’t supported.
displayError: function()
The layer has been added to the map.
setMap: function( map )
The layer has been removed from the map.
removeMap: function( map )
Notify the renderer of the change in size.
onMapResize: function()
Reset the vector layer’s div so that it once again is lined up with the map.
moveTo: function( bounds, zoomChanged, dragging )
Add Features to the layer.
addFeatures: function( features, options )
removeFeatures: function( features, options )
Erase and destroy features on the layer.
destroyFeatures: function( features, options )
Draw (or redraw) a feature on the layer.
drawFeature: function( feature, style )
Erase features from the layer.
eraseFeatures: function( features )
Given an event, return a feature if the event occurred over one.
getFeatureFromEvent: function( evt )
Given a feature id, return the feature if it exists in the features array
getFeatureById: function( featureId )
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 ()