Display a pop-up
Learn how to display feature attributes in a pop-up.
A pop-up, also known as a "popup", is a visual element that displays information about a feature when it is clicked. You typically style and configure a pop-up using HTML and CSS for each layer in a map. Pop-ups can display attribute values, calculated values, or rich content such as images, charts, or videos.
In this tutorial, you create an interactive pop-up for the Trailheads feature layer in the Santa Monica Mountains. When a feature is clicked, a pop-up is displayed containing the name of the trail and the service that manages it.
Prerequisites
You need an ArcGIS Developer or ArcGIS Online account to access the developer dashboard and create an API key.
Steps
Create a new pen
- To get started, either complete the Display a map tutorial or .
Set the API key
To access location services, you need an API key or OAuth 2.0 access token. To learn how to create and scope your key, visit the Create an API key tutorial.
Go to your dashboard to get an API key. The API key must be scoped to access the services used in this tutorial.
In CodePen, update
api
to use your key.Key Use dark colors for code blocks Change line
Add the trailheads layer
Use the Feature
class to display the Trailheads layer on your map.
Create a
Feature
and set theLayer url
property to access the feature service.Use dark colors for code blocks Add line. Add line. Add line. Add line. Add line.
Display a pop-up
Use the bind
method to display the attribute information of the trailheads layer.
Append the
bind
method to thePopup trailheads
layer and pass in afunction
to return the attribute information of the layer.Use dark colors for code blocks Add line. Add line. Add line. Set the pop-up contents to display information about the trail and park name.
Use dark colors for code blocks Add line.
Run the app
In CodePen, run your code to display the map.
The map view should display the Trailheads feature layer. When you click a feature, the name of the trailhead and its park name is displayed in a pop-up.
What's next?
Learn how to use additional ArcGIS location services in these tutorials:

Query a feature layer (spatial)
Execute a spatial query to access polygon features from a feature service.

Get global data
Query demographic information for locations around the world with the GeoEnrichment service.

Get local data
Query regional facts, spending trends, and psychographics with the GeoEnrichment service.

Add a feature layer
Add features from feature layers to a map.