API / geotoolkit / map / layers / KML / KML
The implementation is capable of loading KML (Keyhole Markup Language) data.
↳
KML
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 |
idfield | string | Field that contains the id for this shape |
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
• new KML(options?)
| Name | Type | Description |
|---|---|---|
Optional options | Options | options |
Vector.constructor
Methods
▸ addCssClass(cssclass): KML
Adds new css class to node
| Name | Type | Description |
|---|---|---|
cssclass | string | string[] | css class name('s) |
this
▸ addFeature(parameter): KML
Adds feature(s)
Throws
if a feature to add is not supported
| Name | Type | Description |
|---|---|---|
parameter | AbstractFeature | AbstractFeature[] | feature(s) to be added |
▸ addInvalidateHandler(handler): KML
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(features?): Rect
The implementation builds default limits from scratch if no iterator is provided; otherwise, it extends previously calculated limits with limits calculated over new features.
| Name | Type | Description |
|---|---|---|
Optional features | AbstractFeature[] | Iterator<AbstractFeature> | iterator or array of the new features |
Vector.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(): KML
Clear cache
this
▸ clearFeatures(): KML
Removes all feature(s)
this
▸ clone(): Node
All subclasses should override copyConstructor or provide custom implementation for this method
clone
▸ connectStyle(style, type, callback): KML
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?): KML
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): KML
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): KML
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): KML
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: KML) => void | Function to execute |
The result if any or this
▸ execute<T>(delegate): T
| Name |
|---|
T |
| Name | Type |
|---|---|
delegate | (this: KML) => 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
▸ 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)
▸ getGeometryToText(feature): IGeometryToText
Gets feature_geometry-to-text_anchor_position adapter
| Name | Type | Description |
|---|---|---|
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
▸ 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
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
▸ 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
▸ getTemplate(parameter): BaseTemplate
Gets template associated with a feature or its class name
| Name | Type | Description |
|---|---|---|
parameter | string | AbstractFeature | reference to a feature instance OR feature class name |
template
▸ 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?): AbstractFeature[]
Performs selection of the features with its device coordinates
| Name | Type | Description |
|---|---|---|
pt | Point | is the device coordinates received by mouse event |
Optional radius | number | the radius of selection (in px) |
features features selected
▸ invalidate(bounds?, force?): KML
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?): KML
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
Vector.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<KML>
Returns promise that is resolved when all layer data is loaded and ready to be rendered
Promise<KML>
▸ notify<E>(event, source, args?): KML
Notify listeners of the Node
| Name | Type |
|---|---|
E | extends string |
| Name | Type | Description |
|---|---|---|
event | E | type of event |
source | Template | source who called the event |
Optional args | EventMap[E] | event arguments |
this
▸ off<E>(type?, callback?): KML
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: KML, args: EventMap[E]) => void | function to be called |
this
▸ on<E>(type, callback): KML
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: KML, args: EventMap[E]) => void | to be called |
this
▸ Protected onParentChanged(node): KML
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
▸ 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): KML
Removes css class from node
| Name | Type | Description |
|---|---|---|
cssclass | string | string[] | css class name('s) |
this
▸ removeFeature(parameter): KML
Removes feature(s)
| Name | Type | Description |
|---|---|---|
parameter | AbstractFeature | feature(s) to be removed |
this
▸ removeInvalidateHandler(handler): KML
Remove invalidate handler
Deprecated
since 4.0, use Node.off instead
| Name | Type | Description |
|---|---|---|
handler | Function | handler to be notified about invalidation |
this
Vector.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[] | 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
▸ renderFeatures(featuresIt, context): void
Renders features.
NOTE:
When picking is performed, then feature is selected if its shape gets picked.
| Name | Type | Description |
|---|---|---|
featuresIt | AbstractFeature[] | iterator over filtered features |
context | RenderingContext | rendering context |
void
▸ resetFeatureTemplates(features?, suppressInvalidate?): KML
If no features provided then resets all shape templates to their initial states;
otherwise resets specific templates for the features provided
| Name | Type | Description |
|---|---|---|
Optional features | AbstractFeature | AbstractFeature[] | Iterator<AbstractFeature> | features to reset their specific template(s) to a default one |
Optional suppressInvalidate | boolean | suppress layer invalidation flag |
▸ setCache(cache): KML
Sets cache to be used to cache
| Name | Type | Description |
|---|---|---|
cache | Cache | cache to be used |
this
▸ setCssClass(name): KML
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): KML
Allows the user to associate any identifier
| Name | Type | Description |
|---|---|---|
id | string | number | object id |
this
▸ setLayerAlpha(alpha): KML
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): KML
Sets a map coordinate system
| Name | Type | Description |
|---|---|---|
system | AbstractSystem | GeodeticSystem | coordinate system |
this
▸ setModelLimits(limits): KML
Sets model limits
| Name | Type | Description |
|---|---|---|
limits | Rect | new model limits |
this
▸ setName(name): KML
Sets name of the node
| Name | Type | Description |
|---|---|---|
name | string | The node name |
this
▸ setNotification(notify, force?): KML
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?): KML
Sets options
| Name | Type | Description |
|---|---|---|
Optional options | OptionsBase | options |
this
▸ setProperties(properties?): KML
Sets all the properties pertaining to this object see Vector.getProperties
| Name | Type | Description |
|---|---|---|
Optional properties | Options | object containing the properties to set |
this
▸ setProperty(name, value): KML
Sets dynamic property by name
| Name | Type | Description |
|---|---|---|
name | string | property name |
value | any | property value |
this
▸ setSelectable(selectable): KML
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): KML
Sets the url to the layer source
| Name | Type | Description |
|---|---|---|
url | string | string[] | server url |
▸ setSilent(bool): KML
Set silent mode
| Name | Type | Description |
|---|---|---|
bool | boolean | flag to enable silent mode |
this
▸ setTag(tag): KML
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
▸ setTemplate(parameter, template, suppressInvalidate?): KML
Sets template associated with a feature or features
| Name | Type | Description |
|---|---|---|
parameter | string | AbstractFeature | AbstractFeature[] | Iterator<AbstractFeature> | feature class name OR reference to a feature instance OR feature iterator |
template | BaseTemplate | feature(s) template or feature class template |
Optional suppressInvalidate | boolean | suppress layer invalidation flag |
▸ setUniqueField(field): KML
Sets the unique identifier for the features
| Name | Type | Description |
|---|---|---|
field | string | unique identifier |
this
▸ setVisible(value): KML
Sets visibility of the node. Send event Events.VisibilityChanged
| Name | Type | Description |
|---|---|---|
value | boolean | flag specifying visibility of the node |
this
▸ setZIndex(value): KML
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 |
▸ 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 |
▸ updateGeometry(feature, geometry): KML
updates the geometry for the feature in this layer
| Name | Type | Description |
|---|---|---|
feature | AbstractFeature | feature to be modified |
geometry | Geometry | Geometry[] | the geometry to be set on the feature |
▸ updateSceneTransformation(): KML
Update scene transformation
this
Vector.updateSceneTransformation
▸ updateState(regions?, changes?): KML
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(): KML
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
Vector.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