Display KML from a URL, portal item, or local KML file.

Use case
Keyhole Markup Language (KML) is a data format used by Google Earth. KML is popular as a transmission format for consumer use and for sharing geographic data between apps. You can use the Maps SDKs to display KML files, with full support for a variety of features, including network links, 3D models, screen overlays, and tours.
How to use the sample
Use the picker to select a source. A KML layer created from that source will then be displayed in the map.
How it works
- To create a KML layer from a URL, create a
KMLDatasetwith the URL to the KML file. Then, create aKMLLayerusing the dataset. - To create a KML layer from a portal item, create a
PortalItemwith aPortaland the KML portal item ID. Then, create aKMLLayerusing the portal item. - To create a KML layer from a local file, create a
KMLDatasetusing the absolute file path to the local KML file. Then, create aKMLLayerusing the dataset. - Add the layer to the map with
addOperationalLayer(_:).
Relevant API
- KMLDataset
- KMLLayer
Offline data
This sample uses the US State Capitals KML file. It is downloaded from ArcGIS Online automatically.
About the data
This sample displays three different KML files:
- From URL: This is a map of the convective outlook produced by NOAA/NWS Storm Prediction Center. It uses KML network links to always show the latest data.
- From local file: This is a map of U.S. state capitals. It doesn’t define an icon, so the default pushpin is used for the points.
- From portal item: This is a map of U.S. states.
Tags
keyhole, KML, KMZ, OGC