URL parameters can be used to pass along additional information or instructions to Map Viewer, controlling the maps that are opened, their zoom level, layer visibility, and more.
URL parameters follow a question mark (?) and are made of a key-value pair connected with an equal sign (=). For example, Map Viewer takes the ID of the web map to open as a URL parameter.
To include multiple parameters, separate them with ampersands (&).
URL encoding replaces characters with the percent sign (%) followed by their hex (hexadecimal) equivalent. In modern browsers, URL encoding is automatically added as needed when entering a URL in the browser address bar. When using embedded maps, encoding may be necessary.
For example, the following is an example that uses find to locate Redlands California. The space in the location is automatically replaced by %20 in the browser address bar:
The full URL encoding is as follows:
For more information, and to encode your URL strings, see URLEncoder.io
The following examples show using URL parameters to open and modify maps.
Open an existing map as configured
The map is referenced by its ID, in this case 8152694dd9594393a1db4d62d2020fe3.
Open an existing map and specify a scale level
Scale is specified using &level=<LOD>
Specify a location and scale level
The map is centered using ¢er=<x>,<y>.
Specify an extent
&Extent uses two x,y coordinates to define the bounding box.
Find the location of a feature to open the map
Use &find= followed by any search string.
Find an address to open the map
Add a marker with a pop-up
&Marker uses the following properties. To skip a property use double semicolons (;;). The marker properties must be in this order: &marker=<x>,<y>,<WKID>,<title>,<symbol URL>,<text>. Click the marker to view the pop-up.
- <x coordinate>,<y coordinate>—The location for the marker.
- <WKID>—Spatial reference of the x,y coordinates to be added to the map. If you do not include a WKID, GCS coordinates are used.
- <title>—Pop-up title. If you do not include a title, the pop-up will be empty.
- <symbol URL>—Symbol for the point. If you do not include a symbol, a black circle marker symbol is used.
- <text>—Text to include in the pop-up.
https://www.arcgis.com/apps/mapviewer/index.html?webmap=8152694dd9594393a1db4d62d2020fe3&marker=-118.292176;36.578494;;Mount Whitney;https://downloads.esri.com/agol/resources/symbols/misc/rm1.png;Mount Whitney is the highest mountain in the contiguous United States with an elevation of 14,505 feet (4,421 m).
Add a marker with a pop-up and specify a zoom level
Add &level to the URL above. Click the marker to view the pop-up.
https://www.arcgis.com/apps/mapviewer/index.html?webmap=8152694dd9594393a1db4d62d2020fe3&marker=-118.292176;36.578494;;Mount Whitney;https://downloads.esri.com/agol/resources/symbols/misc/rm1.png;Mount Whitney is the highest mountain in the contiguous United States with an elevation of 14,505 feet (4,421 m).&level=14
Open a map and add layers
Open Map Viewer and define the basemap
Set basemapUrl to the basemap layer you want to use. Note the capitalization of U in the parameter. This examples opens with the OpenStreetMap (OSM) vector basemap layer. Add the &level parameter to zoom in.
Open Map Viewer, define the basemap, and add a layer
Open Map Viewer, add a basemap and reference layer
Use basemapReferenceUrl to set the reference layer to be used. This must be used along with basemapUrl. The example below adds the World Boundaries and Places reference layer to the Vintage Shaded Relief basemap layer, both from ArcGIS Living Atlas.
Set sublayer visibility
To set the visibility of sublayers for a layer that opened in the map, use layers=show. In this example using Bureau of Labor Statistics Unemployment from the Living Atlas, only the 3rd sublayer is visible. Note that sublayer numbering begins with zero (0) as shown in the REST endpoint.
Add two layers and set sublayer visibility
This example adds two layers and sets the visibility of sublayers for the second layer. The layers are separated by commas, note that the additional URL parameters for sublayer visibility apply to the second layer, plus the addition of an overall extent parameter which controls the map.
For more information, see:
- Use URL parameters to create and modify maps (Help)
- Use URL parameters to modify embedded maps (Help)
- Use URL parameters in scenes (Help)
- Use URL parameters in ArcGIS Dashboards (Help)
- Use URL parameters in ArcGIS Instant Apps (Blog)