Instances of ALKMaps.Layer.Vector are used to render vector data from a variety of sources. Create a new vector layer with the ALKMaps.Layer.Vector constructor.
ALKMaps. | Instances of ALKMaps.Layer.Vector are used to render vector data from a variety of sources. |
Properties | |
events | {ALKMaps.Events} |
isBaseLayer | {Boolean} The layer is a base layer. |
isFixed | {Boolean} Whether the layer remains in one place while dragging the map. |
features | {Array(ALKMaps.Feature.Vector)} |
filter | {ALKMaps.Filter} The filter set in this layer, a strategy launching read requests can combined this filter with its own filter. |
selectedFeatures | {Array(ALKMaps.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 | {ALKMaps.StyleMap} |
strategies | {Array(ALKMaps.Strategy})} Optional list of strategies for the layer. |
protocol | {ALKMaps.Protocol} Optional protocol for the layer. |
renderers | {Array(String)} List of supported Renderer classes. |
renderer | {<ALKMaps.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. |
ratio | {Float} This specifies the ratio of the size of the visiblity of the Vector Layer features to the size of the map. |
arrowLookup | {Array<Object>} An array of objects containing the featureId and array of arrow features for a given line feature. |
Constructor | |
ALKMaps. | Create a new vector layer |
Functions | |
destroy | Destroy this layer |
clone | Create a clone of 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. |
afterAdd | Called at the end of the map.addLayer sequence. |
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. |
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. |
eraseFeatures | Erase features from the layer. |
getFeatureFromEvent | Given an event, return a feature if the event occurred over one. |
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. |
setOpacity | Sets the opacity for the entire layer (all images) |
drawVectorArrows | First removes any existing arrows on the specified route. |
createVectorArrow | Creates a new arrow feature using the given Point geometry, style, rotation, and routeId. |
getFeatureArrows | Searches for and returns the arrows object from the lookup array that corresponds to the given feature. |
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.
object | {Object} A reference to layer.events.object. |
element | {DOMElement} A reference to layer.events.element. |
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. |
beforefeaturesremoved | Triggered before multiple features are removed. Listeners will receive an object with a features property referencing the features 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. |
beforefeatureselected | Triggered before a feature is selected. Listeners will receive an object with a feature property referencing the feature to be selected. To stop the feature from being selected, a listener should return false. |
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. |
vertexmodified | Triggered when a vertex within any feature geometry has been modified. Listeners will receive an object with a feature property referencing the modified feature, a vertex property referencing the vertex modified (always a point geometry), and a pixel property referencing the pixel location of the modification. |
vertexremoved | Triggered when a vertex within any feature geometry has been deleted. Listeners will receive an object with a feature property referencing the modified feature, a vertex property referencing the vertex modified (always a point geometry), and a pixel property referencing the pixel location of the removal. |
sketchstarted | Triggered when a feature sketch bound for this layer is started. Listeners will receive an object with a feature property referencing the new sketch feature and a vertex property referencing the creation point. |
sketchmodified | Triggered when a feature sketch bound for this layer is modified. Listeners will receive an object with a vertex property referencing the modified vertex and a feature property referencing the sketch feature. |
sketchcomplete | Triggered when a feature sketch bound for this layer is complete. Listeners will receive an object with a feature property referencing the sketch feature. By returning false, a listener can stop the sketch feature from being added to the layer. |
refresh | Triggered when something wants a strategy to ask the protocol for a new set of features. |
featureclicked | Triggered when a feature is clicked. |
featureclickedout | Triggered when a click outside a feature. Last stored feature will be returned in the event. |
overFeature | Triggered when mouse over a feature. |
outFeature | Triggered when mouse out a feature. |
{Array(ALKMaps.Feature.Vector)}
{ALKMaps.Filter} The filter set in this layer, a strategy launching read requests can combined this filter with its own filter.
{Array(ALKMaps.Feature.Vector)}
{Array(ALKMaps.Strategy})} Optional list of strategies for the layer.
{ALKMaps.Protocol} Optional protocol for the layer.
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. |
{ALKMaps.Layer.Vector} A new vector layer
clone: function ( obj )
Create a clone of this layer.
Note: Features of the layer are also cloned.
{ALKMaps.Layer.Vector} An exact clone of this 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 | {ALKMaps.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 | {ALKMaps.Bounds} |
zoomChanged | {Boolean} |
dragging | {Boolean} |
addFeatures: function( features, options )
Add Features to the layer.
features | {Array(ALKMaps.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 suppress event triggering, use the silent option.
features | {Array(ALKMaps.Feature.Vector)} List of features to be removed. |
options | {Object} Optional properties for changing behavior of the removal. |
silent | {Boolean} Suppress event triggering. Default is false. |
destroyFeatures: function( features, options )
Erase and destroy features on the layer.
features | {Array(ALKMaps.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 | {ALKMaps.Feature.Vector} |
style | {String | Object} Named render intent or full symbolizer object. |
eraseFeatures: function( features )
Erase features from the layer.
features | {Array(ALKMaps.Feature.Vector)} |
getFeatureFromEvent: function( evt )
Given an event, return a feature if the event occurred over one. Otherwise, return null.
evt | {Event} |
{ALKMaps.Feature.Vector} A feature if one was under the event.
getFeatureBy: function( property, value )
Given a property value, return the feature if it exists in the features array
property | {String} |
value | {String} |
{ALKMaps.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} |
{ALKMaps.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} |
{ALKMaps.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({ALKMaps.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 | {ALKMaps.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 | {ALKMaps.Feature.Vector} |
getDataExtent: function ()
Calculates the max extent which includes all of the features.
{ALKMaps.Bounds} or null if the layer has no features with geometries.
drawVectorArrows: function ( arrowsObj )
First removes any existing arrows on the specified route. Then either draws new arrows along the route line at a given spacing interval or draws a single arrow at the end of the route.
arrowsObj | {Object} Object containing an array of arrow point features and the ID of the route that the arrows correspond to. |
createVectorArrow: function( point, style, bearing, id )
Creates a new arrow feature using the given Point geometry, style, rotation, and routeId.
point | {ALKMaps.Geometry.Point} Arrow feature’s point geometry. |
style | {Object} Route’s style object. |
bearing | {Number} Rotation of arrow. |
id | {String} ID of the vector that the arrow corresponds to. |
{ALKMaps.Feature.Vector} New arrow feature.
getFeatureArrows: function ( feature )
Searches for and returns the arrows object from the lookup array that corresponds to the given feature. If no entry exists, null is returned.
feature | {ALKMaps.Feature.Vector} |
{id: “ALKMaps.Feature.Vector_91”, arrows: [ALKMaps.Feature.Vector]} Arrows Object.
Destroy this layer
destroy: function()
Create a clone of this layer.
clone: function ( obj )
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 )
Called at the end of the map.addLayer sequence.
afterAdd: function()
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 )
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 )
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 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 ()
Sets the opacity for the entire layer (all images)
setOpacity: function( opacity )
First removes any existing arrows on the specified route.
drawVectorArrows: function ( arrowsObj )
Creates a new arrow feature using the given Point geometry, style, rotation, and routeId.
createVectorArrow: function( point, style, bearing, id )
Searches for and returns the arrows object from the lookup array that corresponds to the given feature.
getFeatureArrows: function ( feature )