View on GitHub
import InlineCode from "@esri-dx/starship-doc-components/components/InlineCode.astro";

Construct a KML document and save it as a KMZ file.

KML style settings Sketching a KML

Use case

If you need to create and save data on the fly, you can use KML to create points, lines, and polygons by sketching on the map, customizing the style, and serializing them as KML nodes in a KML Document. Once complete, you can share the KML data with others that are using a KML reading application, such as ArcGIS Earth.

How to use the sample

Tap on the sketch button in the toolbar to add a new KML. Select a type of feature and choose its color or icon. Tap on the map to sketch the KML. Tap the sketch button and tap “Save Sketch” to complete the sketch. Tap the file export button in the toolbar to export the file. Tap the sketch button and the “Clear Saved Sketches” button to clear the current KML document.

How it works

  1. Create an
    .
  2. Create an
    using the
    .
  3. Create an
    using the
    and add it to the map’s
    array.
  4. Create
    using
    .
  5. Project that
    to WGS84 using
    .
  6. Create an
    object using that projected
    .
  7. Create an
    using the
    .
  8. Add the
    to the
    .
  9. Set the
    for the
    .
  10. When finished with adding
    nodes to the
    , save the
    to a file using the
    method.

Relevant API

  • GeometryEditor
  • GeometryEngine
  • KMLDataset
  • KMLDocument
  • KMLGeometry
  • KMLLayer
  • KMLNode
  • KMLPlacemark
  • KMLStyle

Tags

Keyhole, KML, KMZ, OGC