Add a feature layer from an item
Learn how to use a ID to access and display a feature layer in a map.
A map contains layers of geographic data. A map contains a basemap layer and, optionally, one or more data layers. This tutorial shows you how to access and display a feature layer in a map. You access feature layers with an item ID or URL. You will use item IDs to access the Trailheads, Trails, and Parks and Open Spaces feature layers and display in them in a map.
The following are required for this tutorial:
- An ArcGIS account to access your API keys. If you don't have an account, sign up for free.
- Your system meets the system requirements.
- The ArcGIS Runtime API for iOS is installed.
In your browser, go to the Trailheads Styled layer on ArcGIS Online and find the item ID at the end of the URL. It should be 2e4b3df6ba4b44969a3bc9827de746b3
.
Steps
Open the ViewController.swift file, update the
setupMap()
method to create anAGSPortal
object and anAGSPortalItem
object referencing the feature layer.Create an
AGSFeatureLayer
object from the portal item and a layer ID. Add the layer to the map's operational layers.Press Command-R to run the app in the iOS Simulator.
Congratulations, you're done!
Your app should display a map with the trailheads centered on the Santa Monica Mountains. Compare your solution with our completed solution project.