Skip To Content ArcGIS for Developers Sign In Dashboard


You will learn: how to add feature layers to a 2D map.

With the ArcGIS Runtime SDK for macOS 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 a copy of the finished starter app project (or download here) and open the .xcodeproj file in Xcode.


Add a layer to the map

  1. In the project navigator, find the ViewController.swift file. Create an AGSServiceFeatureTable to access the Trail Heads data and an AGSFeatureLayer to view it. Add the layer to the map's operationalLayers.

    override func viewDidLoad() {
        let map = AGSMap(basemapType: .navigationVector, latitude: 34.05293, longitude: -118.24368, levelOfDetail: 9)
    = map
        /*** ADD ***/
        let trailheadsTable = AGSServiceFeatureTable(url: URL(string: "")!)
        let trailheadsLayer = AGSFeatureLayer(featureTable: trailheadsTable)
  2. Now press Command-R to run the app.

Congratulations, you're done!

The app should run and show features displayed on top of a basemap.

Your project should look something like this.


Explore basemap

Visit the macOS 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 that limits the city to Los Angeles.

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

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.