ArcGIS Online

Use URL parameters in Map Viewer

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.

URL parameter syntax

To include multiple parameters, separate them with ampersands (&).

Map Viewer URL parameters

 

URL encoding

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:

https://www.arcgis.com/apps/mapviewer/index.html?
webmap=8152694dd9594393a1db4d62d2020fe3&find=redlands california

https://www.arcgis.com/apps/mapviewer/index.html?webmap=8152694dd9594393a1db4d62d2020fe3&find=redlands%20california

The full URL encoding is as follows:

https%3A%2F%2Fwww.arcgis.com%2Fapps%2Fmapviewer%2Findex.html
%3Fwebmap%3D8152694dd9594393a1db4d62d2020fe3%26find%3Dredlands%20california

For more information, and to encode your URL strings, see URLEncoder.io

 

Examples

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.

https://www.arcgis.com/apps/mapviewer/index.html?webmap=8152694dd9594393a1db4d62d2020fe3

Open an existing map and specify a scale level

Scale is specified using &level=<LOD>

https://www.arcgis.com/apps/mapviewer/index.html?webmap=8152694dd9594393a1db4d62d2020fe3&level=9

Specify a location and scale level

The map is centered using &center=<x>,<y>.

https://www.arcgis.com/apps/mapviewer/index.html?webmap=8152694dd9594393a1db4d62d2020fe3&center=-75.164422,39.954757&level=14

Specify an extent

&Extent uses two x,y coordinates to define the bounding box.

https://www.arcgis.com/apps/mapviewer/index.html?webmap=8152694dd9594393a1db4d62d2020fe3&extent=-117.20,34.055,-117.19,34.06

Find the location of a feature to open the map

Use &find= followed by any search string.

https://www.arcgis.com/apps/mapviewer/index.html?webmap=8152694dd9594393a1db4d62d2020fe3&find=Niagara Falls

Find location via URL parameters

Find an address to open the map

https://www.arcgis.com/apps/mapviewer/index.html?webmap=8152694dd9594393a1db4d62d2020fe3&find=380 new york street, redlands, ca

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.

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

URL parameters to create pop-up

Open a map and add layers

This example opens a map and adds Recent Earthquakes and VIIRS Thermal Hotspots from ArcGIS Living Atlas. Use the &layers parameter to add the layers using their IDs, separated by a comma.

https://www.arcgis.com/apps/mapviewer/index.html?webmap=8152694dd9594393a1db4d62d2020fe3
&layers=9e2f2b544c954fda9cd13b7f3e6eebce,dece90af1a0242dcbf0ca36d30276aa3

Layers added via URL parameters

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.

https://www.arcgis.com/apps/mapviewer/index.html?basemapUrl=https://basemaps.arcgis.com/arcgis/rest/services/OpenStreetMap_v2/VectorTileServer

https://www.arcgis.com/apps/mapviewer/index.html?basemapUrl=https://basemaps.arcgis.com/arcgis/rest/services/OpenStreetMap_v2/VectorTileServer&level=3

Open Map Viewer, define the basemap, and add a layer

This example opens the OSM vector basemap layer and adds Recent Earthquakes (from ArcGIS Living Atlas) using the item ID with the &layers parameter.

https://www.arcgis.com/apps/mapviewer/index.html?basemapUrl=https://basemaps.arcgis.com/arcgis/rest/services/OpenStreetMap_v2/VectorTileServer
&layers=9e2f2b544c954fda9cd13b7f3e6eebce

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.

https://www.arcgis.com/apps/mapviewer/index.html?basemapUrl=https://tiles.arcgis.com/tiles/nGt4QxSblgDfeJn9/arcgis/rest/services/VintageShadedRelief/MapServer
&basemapReferenceUrl=https://services.arcgisonline.com/ArcGIS/rest/services/Reference/World_Boundaries_and_Places/MapServer
&level=3

Basemap and reference via URL parameters

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.

Layers in REST endpoint

https://www.arcgis.com/apps/mapviewer/index.html?url=https://services.arcgis.com/P3ePLMYs2RVChkJx/arcgis/rest/services/BLS_Monthly_Unemployment_Current_14_Months/FeatureServer?layers=show:2&find=Pennsylvania

Sublayer visibility using URL parameters

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.

https://www.arcgis.com/apps/mapviewer/index.html?urls=https://services9.arcgis.com/RHVPKKiFTONKtxq3/arcgis/rest/services/NOAA_METAR_current_wind_speed_direction_v1/FeatureServer,
https://services9.arcgis.com/RHVPKKiFTONKtxq3/arcgis/rest/services/NOAA_storm_reports_v1/FeatureServer
?layers=show:4&extent=-108,40,-85,31

 

More information

For more information, see:

 

About the author

Corporate technology evangelist and advocate at Esri, focusing on ways to broaden access to geographic information and helping customers succeed with the ArcGIS system. On a good day I'm making a map, on a great day I'm on one. Email bszukalski@esri.com or connect on LinkedIn (https://www.linkedin.com/in/bernszukalski/).

Connect:

Next Article

Multi-Scale Contour Styling in ArcGIS Pro

Read this article