Options
All
  • Public
  • Public/Protected
  • All
Menu

Decodes KML and KMZ files (strings, ArrayBuffers, and Blobs) into a Cursor of KMLPlacemarkFeatures, KMLScreenOverlayFeatures and KMLGroundOverlayFeatures. Other features are emitted from events:

A KMLCodec is typically used by a Store to decode strings into LuciadRIA KMLFeatures. Consult the class documentation of the Store class for more information.

Styles are resolved according to the KML specification, as long as they are defined in the original KML file. Externally referenced styles are not resolved.

Supported versions

The current version of LuciadRIA supports the KML 2.3 standard.

Limitations

  • This KML Codec will only decode the following features:
    • Placemarks and internal styles
    • Shared Styles
    • NetworkLinks (references to other KML files)
    • KMZ files that consist of a single zipped KML-file; KML files that reference packaged resources are not currently supported.
    • GroundOverlays
    • ScreenOverlays
  • Cross-Origin requests that do not contain an "Access-Control-Allow-Origin" header in the response can not be loaded.
  • Camera positions are not supported.
  • LOD regions are not supported.
  • Collada models are not supported.
  • PhotoOverlays are not supported.

NOTE: This codec only handles well-formed, serialized KML documents and does not handle extensions to the KML Specification.

const codec = new KMLCodec();
const nlHandle = codec.on(KMLNetworkLinkEvent, (networkLink: KMLNetworkLinkFeature) => {});
const cursor = codec.decode({ content: "<kml>...</kml>" });
since

2020.1

Hierarchy

Implements

Overview

Constructors

Events

Methods

Constructors

constructor

  • Creates a KML codec that can decode KML 2.3 strings.

    since

    2020.1

    Parameters

    Returns KMLCodec

Events

on

  • Registers a callback function for the "KMLNetworkLink" event to process KMLNetworkLinkFeatures. This event is fired by the cursor when it identifies a <NetworkLink> element in the document.

    Parameters

    Returns Handle

  • Registers a callback function for the "KMLTree" event. The callback function receives an array of KMLFeatures. This event is fired when the cursor has finished processing, and contains all of the previously processed and emitted nodes from that cursor.

    Parameters

    • event: "KMLTree"

      Always set to "KMLTree" for this event type.

    • callback: (rootArray: KMLFeature[]) => void

      The callback function to be executed when the KMLCodec.decode function is called.

    • Optional context: any

      The context in which the function should be invoked.

    Returns Handle

  • Registers a callback function for the "KMLGroundOverlay" event, that allows a listener to process KMLGroundOverlayFeatures. This event is triggered by the cursor whenever it identifies a <GroundOverlay> element in the document.

    Parameters

    Returns Handle

  • Registers a callback function for the "KMLScreenOverlay" event, that allows a listener to process KMLScreenOverlayFeatures. This event is triggered by the cursor whenever it identifies a <ScreenOverlay> element in the document.

    since

    2021.0

    Parameters

    Returns Handle

    a handle to the registered callback with a single function 'remove'. This function can be used to unregister the callback function.

  • Registers a callback function for the "KMLFatalError" event, that allows a listener to process errors which cause the KMLCodec to abort operations.

    since

    2021.0

    Parameters

    • event: "KMLFatalError"

      Always set to "KMLFatalError" for this event type.

    • callback: (errorMessage: string) => void

      The callback function to be executed when the KMLCodec encounters a fatal error.

        • (errorMessage: string): void
        • Parameters

          • errorMessage: string

          Returns void

    • Optional context: any

      The context in which the function should be invoked.

    Returns Handle

Methods

decode

encode

  • (cursor: Cursor): { content: string; contentType: string }
  • This is not yet implemented and will throw a ProgrammingError if it is used.

    Parameters

    Returns { content: string; contentType: string }

    The encoded version of the features.

    • content: string
    • contentType: string

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Type alias with type parameter
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method