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

Create, save, and preview a KML multi-track captured from a location data source.

Create KML multi-track sample

Use case

When capturing location data for outdoor activities such as hiking or skiing, it can be useful to record and share your path. This sample demonstrates how you can collect individual KML tracks during a navigation session, then combine and export them as a KML multi-track.

How to use the sample

Tap “Record Track” to start recording your current path on the simulated trail. Tap “Stop Recording” to end recording and capture a KML track. Repeat these steps to capture multiple KML tracks in a single session. Tap the save button to convert the recorded tracks into a KML multi-track and save it to a local

file. Then, use the picker to select a track from the saved KML multi-track. Tap the Delete button to remove the local file and reset the sample.

How it works

  1. Create a
    with a basemap style and a
    to display the path geometry for your navigation route.
  2. Create a
    to drive the
    .
  3. As you receive
    updates, add each point to a list of
    objects while recording.
  4. Once recording stops, create a
    using one or more
    objects.
  5. Combine one or more
    objects into a
    .
  6. Save the
    inside a
    , then export the document to a
    file.
  7. Load the saved
    file into a
    and locate the
    in the dataset’s
    . From the document’s
    , get the
    and retrieve the
    geometry.
  8. Retrieve the geometry of each track in the
    by iterating through the list of tracks and obtaining the respective
    .

Relevant API

  • KMLDataset
  • KMLDocument
  • KMLMultiTrack
  • KMLPlacemark
  • KMLTrack
  • KMLTrackElement
  • LocationDisplay
  • SimulatedLocationDataSource

Tags

export, hiking, KML, KMZ, multi-track, record, track