Add a feature layer

Learn how to use a URL to access and display a feature layer in a map.

add a feature layer

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 URLs to access the Trailheads, Trails, and Parks and Open Spaces feature layers and display them in a map.

The following are required for this tutorial:

  1. An ArcGIS account to access your API keys. If you don't have an account, sign up for free.
  2. Your system meets the system requirements.


Add a layer to the map

  1. In the project navigator, open the ViewController.swift file. Update the setupMap() method to create an AGSServiceFeatureTable to access the trail heads data and an AGSFeatureLayer to view it. Add the layer to the map's operational layers.

    Use dark colors for code blocks
    6 = AGSMap(basemapType: .topographicVector, latitude: 34.09042, longitude: -118.71511, levelOfDetail: 10)
         // *** ADD ***
         let featureServiceURL = URL(string: "")!
         let trailheadsTable = AGSServiceFeatureTable(url: featureServiceURL)!.operationalLayers.add(AGSFeatureLayer(featureTable: trailheadsTable))
  2. Press Command-R to run the app in the iOS Simulator.

    Other ways to run the project in Xcode:

    • In Xcode's app menu, select Product > Run.
    • Press the Run button at the top-left of the Xcode project window.

Congratulations, you're done!

The app should run and show features displayed on top of a basemap. Compare your solution with our completed solution project.

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.