LuciadRIA (2026.0.10)
    Preparing search index...

    Decodes KML and KMZ files (strings, ArrayBuffers, and Blobs) into KMLPlacemarkFeature and KMLGroundOverlayFeature instances. 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 defined in the source KML are resolved according to the KML specification. Externally referenced styles are not resolved.

    Supported versions

    The current version of LuciadRIA supports the KML 2.3 standard.

    This codec decodes only 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 and image resources. KML files that reference packaged resources are not currently supported.
    • GroundOverlays
    • ScreenOverlays
    • ExtendedData (defined via: Data, SchemaData and foreign-namespace elements)

    Limitations

    • Cross-Origin requests that do not contain an "Access-Control-Allow-Origin" header in the response cannot be loaded.
    • Camera positions are not supported.
    • LOD regions are not supported.
    • Collada models are not supported.
    • PhotoOverlays are not supported.
    • SchemaData: only local schemaUrl references in the same file are supported (e.g. #S1 points to the local <Schema id="S1">).

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

      const codec = new KMLCodec();
    const handle = codec.on("KMLNetworkLink", (networkLink: KMLNetworkLinkFeature) => {
    // Create a KML layer from the received network link.
    });
    const cursor = codec.decode({content: "<kml>...</kml>"});

    2020.1

    Hierarchy (View Summary)

    Implements

    Constructors

    Properties

    handleAs: "arraybuffer"

    Specifies how stores should read the response body before passing it to decode. All RIA stores support this option and use its value automatically. Codecs for binary formats should override it to arraybuffer.

    • string - passes a string primitive. This is the default and fallback value.
    • arraybuffer - passes an ArrayBuffer object.
    • blob - passes a raw Blob object.
    • json - parses the content into a JavaScript object.

    2026.0.10

    Methods

    Events

    • 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

      • event: "KMLNetworkLink"

        Always set to "KMLNetworkLink" for this event type.

      • callback: (networkLink: KMLNetworkLinkFeature) => void

        The callback function to be executed when KMLNetworkLinkFeature objects are decoded by the KMLCodec.decode function.

      • Optionalcontext: any

        The context in which the callback function should be invoked.

        "KMLNetworkLink"

      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<KMLFeatureProperties>[]) => void

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

      • Optionalcontext: any

        The context in which the function should be invoked.

        "KMLTree"

      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

      • event: "KMLGroundOverlay"

        Always set to "KMLGroundOverlay" for this event type.

      • callback: (groundOverlay: KMLGroundOverlayFeature) => void

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

      • Optionalcontext: any

        The context in which the function should be invoked.

        "KMLGroundOverlay"

      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.

      Parameters

      • event: "KMLScreenOverlay"

        Always set to "KMLScreenOverlay" for this event type.

      • callback: (screenOverlay: KMLScreenOverlayFeature) => void

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

      • Optionalcontext: any

        The context in which the function should be invoked.

      Returns Handle

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

      "KMLScreenOverlay"

      2021.0

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

      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.

      • Optionalcontext: any

        The context in which the function should be invoked.

        "KMLFatalError"

      Returns Handle

      2021.0