Create, save and preview a KML multi-track, captured from a location data source.
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.
Tap Start Navigation to begin moving along a simulated trail. Tap Record Track to start recording your current path. 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 save your recorded tracks as a .kmz
file to local storage. Then load the created .kmz
file containing your KML multi-track to view all created tracks on the map.
- Create an
ArcGISMap
with a basemap and aGraphicsOverlay
to display the path geometry for your navigation route. - Create a
SimulatedLocationDataSource
to drive theLocationDisplay
. - As you receive
Location
updates, add each point to a list ofKmlTrackElement
objects while recording. - Once recording stops, create a
KmlTrack
using one or moreKmlTrackElement
objects. - Combine one or more
KmlTrack
objects into aKmlMultiTrack
. - Save the
KmlMultiTrack
inside aKmlDocument
, then export the document to a.kmz
file. - Load the saved
.kmz
file into aKmlDataset
and locate theKmlDocument
in the dataset'sRootNodes
. From the document'sChildNodes
get theKmlPlacemark
and retrieve theKmlMultiTrack
geometry. - Retrieve the geometry of each track in the
KmlMultiTrack
by iterating through the list of tracks and obtaining the respectiveKmlTrack.Geometry
.
- KmlDataset
- KmlDocument
- KmlMultiTrack
- KmlPlacemark
- KmlTrack
- LocationDisplay
- SimulatedLocationDataSource
export, geoview-compose, hiking, kml, kmz, multi-track, record, track