API / geotoolkit / map / layers / AbstractFeatureLayer / AbstractFeatureLayer
layers.AbstractFeatureLayer.AbstractFeatureLayer
This layer is a collection of features (see AbstractFeature).
addFeature() and removeFeature() are used to add and remove features; getFeatures() to iterate.
Constructors
Methods
Css Properties
| Name | Type | Description |
|---|---|---|
alpha | number | The alpha of the layer |
cssclass | string | The css class name of this node |
id | string | number | Id of the node, its a unique identifier |
limits | Rect | Limits of this layer |
limits-height | number | Height |
limits-readonly | boolean | Readonly |
limits-width | number | Width |
limits-x | number | Left |
limits-y | number | Top |
name | string | Name of the node. It is often used for debugging purposes or to simplify queries |
selectable | boolean | Selectable node, a boolean to determine if selection should consider this node |
source | AbstractSource | The layer data source |
source-system | string | Initial data coordinate system |
source-url | string | Data server url |
system | GeodeticSystem | Coordinate system this layer's data is in |
tag | any | Custom information associated with node. It is a user object which can be used by client code to store information or attach an application object to the shape |
url | string | Server url |
visible | boolean | Visibility of the node, a boolean to determine if the node should be rendered or not |
z-index | number | Define node z-index |
Constructors
• Protected new AbstractFeatureLayer(options?)
Creates feature layer
| Name | Type | Description |
|---|---|---|
Optional options | Options | options |
AbstractLayer.constructor
Methods
▸ addCssClass(cssclass): AbstractFeatureLayer
Adds new css class to node
| Name | Type | Description |
|---|---|---|
cssclass | string | string[] | css class name('s) |
this
▸ addInvalidateHandler(handler): AbstractFeatureLayer
Add invalidate handler
Deprecated
since 4.0, use Node.on instead
| Name | Type | Description |
|---|---|---|
handler | Function | handler to be notified about invalidation |
this
AbstractLayer.addInvalidateHandler
▸ Protected calculateDefaultModelLimits(data?): Rect
Returns default model limits (based on the map coordinate system)
| Name | Type | Description |
|---|---|---|
Optional data | AbstractFeature[] | Iterator<AbstractFeature> | feature data changed (for feature layers), nothing otherwise |
AbstractLayer.calculateDefaultModelLimits
▸ checkCollision(context): boolean
Check if this node is within the area being rendered by the context
| Name | Type | Description |
|---|---|---|
context | RenderingContext | Rendering Context |
boolean
true if object is inside of renderable area
▸ clearCache(): AbstractFeatureLayer
Clear cache
this
▸ clone(): Node
All subclasses should override copyConstructor or provide custom implementation for this method
clone
▸ connectStyle(style, type, callback): AbstractFeatureLayer
Connects style.
This convenience method subscribes a listener to given style for the specified type.
And automatically un-subscribes listener if node is disposed to prevent memory leaks
| Name | Type | Description |
|---|---|---|
style | EventDispatcher | connect style |
type | string | type of event or property |
callback | AttributeCallback<EventDispatcher> | function to be called |
this
▸ Protected copyConstructor(src, deepCopy?): AbstractFeatureLayer
Copy constructor function.
Function used as part of the cloning mechanism.
Implementations should copy the given instance state to this instance.
| Name | Type | Description |
|---|---|---|
src | AbstractLayer | Source to copy from |
Optional deepCopy | boolean | deep copy |
this
▸ disconnectStyle(style, type, callback): AbstractFeatureLayer
Disconnect style
This convenience method un-subscribes a listener to given style for the specified type.
| Name | Type | Description |
|---|---|---|
style | EventDispatcher | connect style |
type | string | type of event or property |
callback | AttributeCallback<EventDispatcher> | function to be called |
this
▸ dispose(): void
Disposes this layer, once disposed it should not be used anymore.
void
▸ enableEventPropagation(enable): AbstractFeatureLayer
Enable event propagation from the node hierarchy from bottom to top
This option is similar to DOM Event bubbling, which allows to get any event from child node. By default it is disabled for better performance.
Example
import {Group} from '@int/geotoolkit/scene/Group';
import {Events as SceneEvents} from '@int/geotoolkit/scene/Node';
const parentGroup = new Group()
.setName('ParentGroup')
.enableEventPropagation(true);
const childGroup = new Group()
.setName('ChildGroup');
parentGroup.addChild(childGroup);
parentGroup.on(SceneEvents.Invalidate, (eventName, sender, args) => {
// Got notifications from all children of parent group
});
childGroup.invalidate();| Name | Type | Description |
|---|---|---|
enable | boolean | enable |
this
AbstractLayer.enableEventPropagation
▸ execute(delegate): AbstractFeatureLayer
Executes delegate and return the result. It allows us to keep all initialization calls in one place,
and we do not need to scroll up or down in IDE to find how and where it was initialized.
Example
// All setters (.setName() for example) returns reference to the this.
// In order to modify inner object like LineStyle or Pattern, to get this object (property) we should call getter to get object reference.
// Then modify it as shown below in Option 1 or you can use execute methods shown in Option 2.
import {Group} from '@int/geotoolkit/scene/Group';
import {Rect} from '@int/geotoolkit/util/Rect';
// Option 1
const group = new Group()
.setName('MyGroup')
.setBounds(new Rect(0, 0, 42, 16))
.enableClipping(true)
.setTag({'type': 'sometype'});
group.getLineStyle().setPattern('pattern');
return group;
// Options 2 ( using execute method )
return group
.execute(function () {
this.getLineStyle()
.setPattern("pattern");
});| Name | Type | Description |
|---|---|---|
delegate | (this: AbstractFeatureLayer) => void | Function to execute |
The result if any or this
▸ execute<T>(delegate): T
| Name |
|---|
T |
| Name | Type |
|---|---|
delegate | (this: AbstractFeatureLayer) => T |
T
▸ getCache(): Cache
Return cache strategy to be used to cache children nodes
cache cache strategy
▸ getClassName(): string
string
▸ getCoordinateSystem(): AbstractSystem
Return coordinate system for this layer
AbstractLayer.getCoordinateSystem
▸ getCssClass(): string
Returns css class name to be used to apply CSS style
string
the css class name
▸ getCssClasses(): string[]
Gets list of css class names which applied to this node
string[]
▸ getDataSource(): AbstractSource
Returns current data source
source
▸ getDefaultModelLimits(): Rect
Gets calculated model limits
limits calculated model limits
AbstractLayer.getDefaultModelLimits
▸ getFeatureById(id): AbstractFeature
Gets feature by feature id.
| Name | Type | Description |
|---|---|---|
id | string | number | feature identifier |
feature if found; null otherwise
▸ getFeatures(filter?): Iterator<AbstractFeature>
Gets features iterator
| Name | Type | Description |
|---|---|---|
Optional filter | Query | (feature: AbstractFeature) => boolean | features query filter. |
feature iterator (over all features if filter is null)
▸ Abstract getGeometryToText(feature?): IGeometryToText
Gets feature_geometry-to-text_anchor_position adapter
| Name | Type | Description |
|---|---|---|
Optional feature | AbstractFeature | feature to get adapter for |
▸ getId(): string | number
Returns the associated identifier of the node
string | number
The node's id
▸ getLayerAlpha(): number
Return a the alpha of the layer between 0.0 (fully transparent) and 1.0 (fully opaque). The default value is 1.0.
number
alpha alpha
▸ getMapCoordinateSystem(): AbstractSystem
Return a map coordinate system
AbstractLayer.getMapCoordinateSystem
▸ getModelLimits(): Rect
Gets user defined model limits if set; calculated model limits otherwise
limits user defined or calculated model limits
▸ getName(): string
Returns the node name
string
The node name
▸ getOptions(): Options
Gets options
options options
▸ getParent(): Node
Return parent node
parent node
▸ getProperties(): OptionsOut
Gets all the properties pertaining to this object
object containing the properties
▸ getProperty(name): any
Gets dynamic property by name. These properties can be used as a property bags
| Name | Type | Description |
|---|---|---|
name | string | property name |
any
▸ getPropertyKeys(): string[]
Returns known properties keys
string[]
▸ getRoot(): Node
Returns root node.
If node doesn't have parent then it returns itself.
the root node
▸ getSceneTransform(): Transformation
Returns transformation from node to root scene
a transformation from node to root scene
AbstractLayer.getSceneTransform
▸ getServerURL(): string | string[]
Gets the server url from the layer source
string | string[]
▸ getTag(): any
Returns the object associated with the node by user.
any
The node's user-object
▸ getTooltipFormatter(): Formatter
Returns the format function to use for the tooltip info (null if tooltips are not visible)
AbstractLayer.getTooltipFormatter
▸ getVisible(): boolean
Return visibility of the node
boolean
true if node is visible
▸ getVisibleModelLimits(ignoreModelLimits?): Rect
Return visible model limits
| Name | Type | Description |
|---|---|---|
Optional ignoreModelLimits | boolean | flag defines whether to ignore ModelLimits or not |
AbstractLayer.getVisibleModelLimits
▸ getWorldTransform(): Transformation
getWorldTransform retrieves the local transformation of the inner node coordinates to parent coordinates.
the world transform.
AbstractLayer.getWorldTransform
▸ getZIndex(): number
Returns node z-index (null if not set)
number
▸ hasCssClass(cssClass): boolean
Check if node has specified css class
| Name | Type | Description |
|---|---|---|
cssClass | string | css class name |
boolean
▸ hasEventListener(type, callback?): boolean
Check if a list of event listeners for this type contains this listener
| Name | Type | Description |
|---|---|---|
type | string | type of event or property |
Optional callback | Function | to be called, if null, check if any callback is registered |
boolean
AbstractLayer.hasEventListener
▸ hitTest(pt, radius?): (AbstractNode | AbstractFeature)[]
Performs selection of the data with its device coordinates. Returns null, if no data available but will be loaded asynchronously later (fires Events.InfoUpdated).
| Name | Type | Description |
|---|---|---|
pt | Point | is the device coordinates to select |
Optional radius | number | the radius of selection (in px) |
(AbstractNode | AbstractFeature)[]
data data selected
▸ invalidate(bounds?, force?): AbstractFeatureLayer
Invalidate layer
| Name | Type | Description |
|---|---|---|
Optional bounds | Rect | bounds of the invalid rectangle in the inner node coordinates |
Optional force | boolean | true if parent should be invalidated immediately if null is provided then cache (if any will be completely refreshed) otherwise only specified rect or node.bounds will be refreshed |
this
▸ Protected invalidateParent(bounds?, force?): AbstractFeatureLayer
Invalidate parent and notify all listeners. NOTE: Don't keep arguments of the event, because instance can be changed
Fires
| Name | Type | Description |
|---|---|---|
Optional bounds | Rect | bounds of the invalid rectangle in the inner node coordinates |
Optional force | boolean | force rendering |
this
AbstractLayer.invalidateParent
▸ isDisposed(): boolean
Returns whether this object has been disposed
boolean
▸ isEventPropagationEnabled(): boolean
Return true if event propagation is enabled from child to parent
boolean
AbstractLayer.isEventPropagationEnabled
▸ isLoading(): boolean
Checks if layer data is still loading and not ready
boolean
▸ isNotificationEnabled(): boolean
return state of notification
boolean
current notification state
AbstractLayer.isNotificationEnabled
▸ isSelectable(): boolean
Returns true if node can be picked/selected.
boolean
The selectable flag
▸ isSilent(): boolean
Return true if the event dispatcher doesn't notify any events
boolean
▸ load(): Promise<AbstractFeatureLayer>
Returns promise that is resolved when all layer data is loaded and ready to be rendered
Promise<AbstractFeatureLayer>
▸ notify<E>(type, source, args?): AbstractFeatureLayer
Notify listeners of the Node
| Name | Type |
|---|---|
E | extends string |
| Name | Type | Description |
|---|---|---|
type | E | type of event |
source | AbstractFeatureLayer | source who called the event |
Optional args | EventMap[E] | event arguments |
this
▸ off<E>(type?, callback?): AbstractFeatureLayer
Detach listener on event. Calling .off() with no arguments removes all attached listeners. Calling .off(type) with no callback removes all attached listeners for specific type.
| Name | Type |
|---|---|
E | extends string |
| Name | Type | Description |
|---|---|---|
Optional type | E | type of the event |
Optional callback | (eventType: E, sender: AbstractFeatureLayer, args: EventMap[E]) => void | function to be called |
this
▸ on<E>(type, callback): AbstractFeatureLayer
Attach listener on event that will be called whenever the specified event is delivered to the target
If the callback function is already in the list of event listeners for this target, the function is not added a second time.
If a particular anonymous function is in the list of event listeners registered for a certain target, and then later in the code, an identical anonymous function is given in an "on" call, the second function will also be added to the list of event listeners for that target.
| Name | Type |
|---|---|
E | extends string |
| Name | Type | Description |
|---|---|---|
type | E | type of event or property |
callback | (eventType: E, sender: AbstractFeatureLayer, args: EventMap[E]) => void | to be called |
this
▸ Protected onParentChanged(node): AbstractFeatureLayer
This method is called when parent changes. Do not call it directly.
| Name | Type | Description |
|---|---|---|
node | Node | node to change parent |
this
▸ Protected onVisibilityChanged(): void
This method is called if visibility is changed. Send event Events.VisibilityChanged
void
AbstractLayer.onVisibilityChanged
▸ queryFeatures(query): AbstractFeature[]
queries layer for items that match the search
| Name | Type | Description |
|---|---|---|
query | Query | (feature: AbstractFeature) => boolean | query |
features selected features
▸ removeCssClass(cssclass): AbstractFeatureLayer
Removes css class from node
| Name | Type | Description |
|---|---|---|
cssclass | string | string[] | css class name('s) |
this
▸ removeInvalidateHandler(handler): AbstractFeatureLayer
Remove invalidate handler
Deprecated
since 4.0, use Node.off instead
| Name | Type | Description |
|---|---|---|
handler | Function | handler to be notified about invalidation |
this
AbstractLayer.removeInvalidateHandler
▸ render(context): void
Renders node
| Name | Type | Description |
|---|---|---|
context | RenderingContext | The rendering context to be used to draw the node |
void
▸ renderAnnotations(featuresIt, context): void
Renders annotations (to filtered features only)
| Name | Type | Description |
|---|---|---|
featuresIt | AbstractFeature[] | Iterator<AbstractFeature> | features iterator |
context | RenderingContext | rendering context |
void
▸ renderAsync(context, callback): void
Render node in asynchronous mode. Default implementation creates call method "render" inside
| Name | Type | Description |
|---|---|---|
context | RenderingContext | The rendering context to be used to draw the node |
callback | () => void | callback function |
void
▸ renderContent(context): void
Renders content. The implementation:
- Applies features filter(s) if set;
- Execute "renderFeatures"; If annotations visible then:
- Applies annotations filter(s) if set;
- Execute "renderAnnotations"
| Name | Type | Description |
|---|---|---|
context | RenderingContext | to render layer |
void
▸ renderContentAsync(context, callback): void
Renders async layer content
| Name | Type | Description |
|---|---|---|
context | RenderingContext | the Rendering Context |
callback | () => void | callback to be called after rendering of layer content |
void
AbstractLayer.renderContentAsync
▸ renderFeatures(featuresIt, context): void
Renders features. The basic implementations iterates over the features provided and renders them if derived from Node.
| Name | Type | Description |
|---|---|---|
featuresIt | AbstractFeature[] | Iterator<AbstractFeature> | features iterator |
context | RenderingContext | rendering context |
void
▸ setCache(cache): AbstractFeatureLayer
Sets cache to be used to cache
| Name | Type | Description |
|---|---|---|
cache | Cache | cache to be used |
this
▸ setCssClass(name): AbstractFeatureLayer
Sets css class name of the node to be used to apply CSS style
| Name | Type | Description |
|---|---|---|
name | string | css class name of the node |
this
▸ setId(id): AbstractFeatureLayer
Allows the user to associate any identifier
| Name | Type | Description |
|---|---|---|
id | string | number | object id |
this
▸ setLayerAlpha(alpha): AbstractFeatureLayer
Set the alpha of the layer
| Name | Type | Description |
|---|---|---|
alpha | number | between 0.0 (fully transparent) and 1.0 (fully opaque). The default value is 1.0. |
this
▸ setMapCoordinateSystem(system): AbstractFeatureLayer
Sets a map coordinate system
| Name | Type | Description |
|---|---|---|
system | AbstractSystem | GeodeticSystem | coordinate system |
this
AbstractLayer.setMapCoordinateSystem
▸ setModelLimits(limits): AbstractFeatureLayer
Sets model limits
| Name | Type | Description |
|---|---|---|
limits | Rect | new model limits |
this
▸ setName(name): AbstractFeatureLayer
Sets name of the node
| Name | Type | Description |
|---|---|---|
name | string | The node name |
this
▸ setNotification(notify, force?): AbstractFeatureLayer
set notification state
| Name | Type | Description |
|---|---|---|
notify | boolean | flag set to invalidate parent or not |
Optional force | boolean | true if parent should be invalidated immediately |
this
▸ setOptions(options?): AbstractFeatureLayer
Sets options
| Name | Type | Description |
|---|---|---|
Optional options | OptionsBase | options |
this
▸ setProperties(properties?): AbstractFeatureLayer
Sets all the properties pertaining to this object
| Name | Type | Description |
|---|---|---|
Optional properties | Options | properties |
this
▸ setProperty(name, value): AbstractFeatureLayer
Sets dynamic property by name
| Name | Type | Description |
|---|---|---|
name | string | property name |
value | any | property value |
this
▸ setSelectable(selectable): AbstractFeatureLayer
Allows to select node. If node is not selectable then child node is not selectable.
| Name | Type | Description |
|---|---|---|
selectable | boolean | flag to allow node selection |
this
▸ setServerURL(url): AbstractFeatureLayer
Sets the url to the layer source
| Name | Type | Description |
|---|---|---|
url | string | string[] | server url |
▸ setSilent(bool): AbstractFeatureLayer
Set silent mode
| Name | Type | Description |
|---|---|---|
bool | boolean | flag to enable silent mode |
this
▸ setTag(tag): AbstractFeatureLayer
Allows the user to associate any arbitrary object with the node.
| Name | Type | Description |
|---|---|---|
tag | any | The object to be associated with the node. |
this
▸ setVisible(value): AbstractFeatureLayer
Sets visibility of the node. Send event Events.VisibilityChanged
| Name | Type | Description |
|---|---|---|
value | boolean | flag specifying visibility of the node |
this
▸ setZIndex(value): AbstractFeatureLayer
Sets z-index for node (set null for default)
| Name | Type | Description |
|---|---|---|
value | number | index determining node z-position |
this
▸ toCSV(base?): string[][]
Converts layer features into CSV formatted object
| Name | Type | Description |
|---|---|---|
Optional base | number | latitude/longitude accuracy base |
string[][]
geoJson geoJson object
▸ toGeoJSON(): Feature
Converts layer features into GeoJSON format
geoJson geoJson object
▸ toString(): string
Returns a string representation of this object (generally the classname)
string
A string representation
▸ transformFromMap(point, dst?, clamp?): Point
Transform a point from map coordinate system to layer coordinate system
| Name | Type | Description |
|---|---|---|
point | Point | point to transform |
Optional dst | Point | optional destination point |
Optional clamp | boolean | if set to true, coordinate values will be clamped |
AbstractLayer.transformFromMap
▸ transformPoint(point, from, to, dst?, clamp?): Point
Transform point
| Name | Type | Description |
|---|---|---|
point | Point | point to transform |
from | AbstractSystem | GeodeticSystem | system converting from |
to | AbstractSystem | GeodeticSystem | system converting to |
Optional dst | Point | optional destination point |
Optional clamp | boolean | if set to true, coordinate values will be clamped |
▸ transformToMap(point, dst?, clamp?): Point
Transform a point from layer coordinate system to map coordinate system
| Name | Type | Description |
|---|---|---|
point | Point | point to transform |
Optional dst | Point | optional destination point |
Optional clamp | boolean | if set to true, coordinate values will be clamped |
▸ updateSceneTransformation(): AbstractFeatureLayer
Update scene transformation
this
AbstractLayer.updateSceneTransformation
▸ updateState(regions?, changes?): AbstractFeatureLayer
Update state. These methods reset node state and update state for children. this method is useful to refresh a scene graph
| Name | Type | Description |
|---|---|---|
Optional regions | Rect[] | optional array to return invalid rectangles in the parent coordinates |
Optional changes | StateChanges | optional parameter to specify a reason of changes |
this
▸ Protected updateTimeStamp(): AbstractFeatureLayer
Update time stamp to indicate that Node or Children has been changed.
this
▸ Static enableSceneGraphNotification(enabled): void
Enable / disable all notifications
| Name | Type | Description |
|---|---|---|
enabled | boolean | sets if this object sends notifications |
void
AbstractLayer.enableSceneGraphNotification
▸ Static findParent<T>(node, classType, filter?): InstanceType<T>
Find root of the node with specified type
| Name | Type |
|---|---|
T | extends Constructor<any> |
| Name | Type | Description |
|---|---|---|
node | Node | node to start search |
classType | T | type of the class to search for |
Optional filter | (node: Node) => boolean | additional filter to apply |
InstanceType<T>
▸ Static findParent(node, classType, filter?): Node
Find root of the node with specified type
| Name | Type | Description |
|---|---|---|
node | Node | node to start search |
classType | string | interface name to search for |
Optional filter | (node: Node) => boolean | additional filter to apply |
▸ Static getClassName(): string
string
▸ Static isSceneGraphNotificationEnabled(): boolean
Return status of the global notification for all nodes.
boolean