Skip To Content ArcGIS for Developers Sign In Dashboard


You will learn: how to build an app that displays feature layers in a 2D map.

With the ArcGIS Runtime SDK for iOS and ArcGIS Online it's easy to create a new web mapping app that displays a basemap and layer. ArcGIS Online hosts a number of tile and vector tile basemaps that you can choose from, including streets, satellite, streets-vector, and streets-navigation-vector. You can also add your own datasets by adding feature layers. These layers are hosted by ArcGIS Online or by other ArcGIS servers. By default, feature layers will draw with pre-set symbols to fill the extent of map, but you can customize this by setting your own styles with a renderer or using a SQL expression to limit the data retrieved.

In this tutorial, you will build a simple mapping app with the topographic vector basemap and a feature layer that represents trailheads near Los Angeles.

Before you begin

Make sure you have installed the latest version of Xcode.

Reuse the starter project

If you have completed the Create a starter app tutorial, then copy the project into a new empty folder. Otherwise, download and unzip the project solution. Open the .xcodeproj file in Xcode. Run and verify the map displays in the device simulator.


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.

         /** UPDATE **/
         private func setupMap() {
            let map = AGSMap(
                basemapType: .topographicVector,
                latitude: 34.09042,
                longitude: -118.71511,
                levelOfDetail: 10
   = map
            /** ADD **/
            let trailheads: AGSFeatureLayer = {
                let trailheadsTable = AGSServiceFeatureTable(url: .trailheads)
                let trailheadsFeatureLayer = AGSFeatureLayer(featureTable: trailheadsTable)
                return trailheadsFeatureLayer
  2. Press Command-R to run the app in the iOS Simulator.

    (Note, as of 100.8 Runtime supports Metal. In order to run your app in a simulator you must meet some minimum requirements. You must be developing on macOS Catalina, using Xcode 11, and simulating iOS 13.)

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.


Explore basemap

Visit the iOS SDK documentation to learn more about the different types of basemaps available. Try some different basemap types such as .lightGrayCanvasVector, .topographicVector or .streetsWithReliefVector and pick your favorite basemap.

Add more layers

Try to add a few more park datasets into the map. Here are a few suggestions:

  • Trails

  • Parks and Open Spaces

Filter features

Sometimes it's necessary to limit the data retrieved from a service. One way to accomplish this is by applying a SQL expression to the layer. Try defining an expression to only draw trails with less than 250 ft of elevation gain.

    let lowElevationGainTrails: AGSFeatureLayer = {
        let trailsURL = URL(string: "")!
        let trailsTable = AGSServiceFeatureTable(url: trailsURL)
        let trailsLayer = AGSFeatureLayer(featureTable: trailsTable)
        trailsLayer.definitionExpression = "ELEV_GAIN < 250"
        return trailsLayer


Investigate the feature request mode

By default, an AGSServiceFeatureTable stores retrieved features using On Interaction Cache mode. See here and here for more details.

Depending on the nature of your data and your app, you might choose to use Interaction No Cache (to get data that changes often) or Manual Cache (to get small amounts of data regardless of the map view extent).

See here for how to populate the data in the case of Manual Cache.