Skip To Content ArcGIS for Developers Sign In Dashboard


You will learn: how to build an app to load and display a web map from ArcGIS Online.

A web map is a JSON structure that contains the settings required to display a 2D map. ArcGIS and custom applications can load web maps and automatically configure the map extent, basemap, layers and styles, pop-ups, labels and more. Web maps can be created interactively with the Map Viewer and ArcGIS Pro. Web maps are stored in ArcGIS Online or ArcGIS Enterprise as an item with a unique ID.

In this tutorial you will search ArcGIS Online for an existing web map and display it.

Before you begin

The ArcGIS API for Python tutorials use Jupyter Notebooks to execute Python code. If you are new to this environment, please see the guide to install the API and use notebooks locally.


Create a new notebook

  1. Go to Esri Juptyter Notebooks and click New > Python 3 to create a new notebook.

    In each step below, type (or copy and paste) the commands into a new notebook cell and run the code by clicking run cell or pressing shift + Enter.

  1. Import the GIS module.

    from arcgis.gis import GIS
  2. Make an anonymous connection to ArcGIS Online.

    gis = GIS()

Display a web map with the ArcGIS API for Python

  1. Get a publicly available web map titled LA Parks and Trails Map (styled with popups) owned by esri_devlabs. It contains datasets about Los Angeles, CA parks and trails. Use item ID 41281c51f9de45edaf1c8ed44bb10e30 for the web map.

    webmap = gis.content.get('41281c51f9de45edaf1c8ed44bb10e30')
  2. Import the WebMap class from the arcgis.mapping module and visualize the web map.

    from arcgis.mapping import WebMap
    la_parks_trails = WebMap(webmap)

Congratulations, you're done!

Your map and layers (feature services) should look something like this.


Explore the layers in the Web Map with the REST API.

All hosted feature layers have a REST endpoint that you can use to access the data directly. This can be accomplished with a URL request from a web browser, a custom application, or the ArcGIS APIs.

Let's use the web map to retrieve the layers. You can query the web map as a dictionary.

  1. operational_layers = la_parks_trails.layers
    n = len(operational_layers)
    print("The webmap has {} layers.".format(n))
  2. Query the list for the id and url values of each layer.

    for layer in operational_layers:
        print("{}\n\t{}".format(layer['id'], layer['url']))
  3. In your browser, add the URL for the Trails_7558 layer to the browser (or just copy/paste from below) to explore the REST endpoint:

  4. Explore the other layers through the same steps.

To learn more about querying data with the REST API, see the Query a feature layer tutorial.