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
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 ¢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.
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.
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.
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
This example opens the OSM vector basemap layer and adds Recent Earthquakes (from ArcGIS Living Atlas) using the item ID with the &layers parameter.
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.
More information
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)
Commenting is not enabled for this article.