API / geotoolkit / map / layers / AbstractLayer / AbstractLayer
layers.AbstractLayer.AbstractLayer
Defines a Map Layer, an Abstract class that will be used by the Map. Map layer represents the geographic layer which can be a tile layer, map layer or any custom layer.
addLayer(), insertLayer() and removeLayer() is used to add and remove layers.
↳
AbstractLayer↳↳
Image↳↳
Projection↳↳
Shape↳↳
Tile
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 AbstractLayer(options?)
Creates layer
| Name | Type | Description |
|---|---|---|
Optional options | Options | options |
Node.constructor
Methods
▸ addCssClass(cssclass): AbstractLayer
Adds new css class to node
| Name | Type | Description |
|---|---|---|
cssclass | string | string[] | css class name('s) |
this
▸ addInvalidateHandler(handler): AbstractLayer
Add invalidate handler
Deprecated
since 4.0, use Node.on instead
| Name | Type | Description |
|---|---|---|
handler | Function | handler to be notified about invalidation |
this
▸ 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 |
▸ 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(): AbstractLayer
Clear cache
this
▸ clone(): Node
All subclasses should override copyConstructor or provide custom implementation for this method
clone
▸ connectStyle(style, type, callback): AbstractLayer
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?): AbstractLayer
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): AbstractLayer
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): AbstractLayer
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
▸ execute(delegate): AbstractLayer
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: AbstractLayer) => void | Function to execute |
The result if any or this
▸ execute<T>(delegate): T
| Name |
|---|
T |
| Name | Type |
|---|---|
delegate | (this: AbstractLayer) => 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
▸ 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
▸ 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
▸ 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
options
▸ 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
▸ 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)
▸ 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 |
▸ getWorldTransform(): Transformation
getWorldTransform retrieves the local transformation of the inner node coordinates to parent coordinates.
the world transform.
▸ 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
▸ 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?): AbstractLayer
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?): AbstractLayer
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
▸ isDisposed(): boolean
Returns whether this object has been disposed
boolean
▸ isEventPropagationEnabled(): boolean
Return true if event propagation is enabled from child to parent
boolean
Node.isEventPropagationEnabled
▸ isLoading(): boolean
Checks if layer data is still loading and not ready
boolean
▸ isNotificationEnabled(): boolean
return state of notification
boolean
current notification state
▸ 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<AbstractLayer>
Returns promise that is resolved when all layer data is loaded and ready to be rendered
Promise<AbstractLayer>
▸ notify<E>(type, source, args?): AbstractLayer
Notify listeners of the Node
| Name | Type |
|---|---|
E | extends string |
| Name | Type | Description |
|---|---|---|
type | E | type of event |
source | AbstractLayer | source who called the event |
Optional args | EventMap[E] | event arguments |
this
▸ off<E>(type?, callback?): AbstractLayer
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: AbstractLayer, args: EventMap[E]) => void | function to be called |
this
▸ on<E>(type, callback): AbstractLayer
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: AbstractLayer, args: EventMap[E]) => void | to be called |
this
▸ Protected onParentChanged(node): AbstractLayer
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
▸ removeCssClass(cssclass): AbstractLayer
Removes css class from node
| Name | Type | Description |
|---|---|---|
cssclass | string | string[] | css class name('s) |
this
▸ removeInvalidateHandler(handler): AbstractLayer
Remove invalidate handler
Deprecated
since 4.0, use Node.off instead
| Name | Type | Description |
|---|---|---|
handler | Function | handler to be notified about invalidation |
this
▸ render(context): void
Renders node
| Name | Type | Description |
|---|---|---|
context | RenderingContext | The rendering context to be used to draw the node |
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
▸ Abstract renderContent(context): void
Renders layer content
| Name | Type | Description |
|---|---|---|
context | RenderingContext | rendering context |
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
▸ setCache(cache): AbstractLayer
Sets cache to be used to cache
| Name | Type | Description |
|---|---|---|
cache | Cache | cache to be used |
this
▸ setCssClass(name): AbstractLayer
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): AbstractLayer
Allows the user to associate any identifier
| Name | Type | Description |
|---|---|---|
id | string | number | object id |
this
▸ setLayerAlpha(alpha): AbstractLayer
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?): AbstractLayer
Sets a map coordinate system
| Name | Type | Description |
|---|---|---|
Optional system | number | AbstractSystem | GeodeticSystem | new map coordinate system |
▸ setModelLimits(limits): AbstractLayer
Sets model limits
| Name | Type | Description |
|---|---|---|
limits | Rect | new model limits |
this
▸ setName(name): AbstractLayer
Sets name of the node
| Name | Type | Description |
|---|---|---|
name | string | The node name |
this
▸ setNotification(notify, force?): AbstractLayer
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?): AbstractLayer
Sets options (default options listed are for construction time only)
| Name | Type | Description |
|---|---|---|
Optional options | OptionsBase | options |
▸ setProperties(properties?): AbstractLayer
Sets all the properties pertaining to this object
| Name | Type | Description |
|---|---|---|
Optional properties | Options | options |
this
▸ setProperty(name, value): AbstractLayer
Sets dynamic property by name
| Name | Type | Description |
|---|---|---|
name | string | property name |
value | any | property value |
this
▸ setSelectable(selectable): AbstractLayer
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): AbstractLayer
Sets the url to the layer source
| Name | Type | Description |
|---|---|---|
url | string | string[] | server url |
▸ setSilent(bool): AbstractLayer
Set silent mode
| Name | Type | Description |
|---|---|---|
bool | boolean | flag to enable silent mode |
this
▸ setTag(tag): AbstractLayer
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): AbstractLayer
Sets visibility of the node. Send event Events.VisibilityChanged
| Name | Type | Description |
|---|---|---|
value | boolean | flag specifying visibility of the node |
this
▸ setZIndex(value): AbstractLayer
Sets z-index for node (set null for default)
| Name | Type | Description |
|---|---|---|
value | number | index determining node z-position |
this
▸ 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 |
▸ 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(): AbstractLayer
Update scene transformation
this
Node.updateSceneTransformation
▸ updateState(regions?, changes?): AbstractLayer
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(): AbstractLayer
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
Node.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