Using URL parameters

A web map authored with the map viewer contains a basemap; data layers; an extent; a legend; and navigation tools such as zoom, pan, place finders, and bookmarks. Many web maps also contain interactive elements such as a basemap gallery that lets you switch between maps like imagery and streets, plus measure tools, pop-up windows that display attributes about a specific feature, and buttons for playing data over time.

As an alternative to creating web maps with the map viewer, you can author web maps directly with URL parameters. URL parameters let you define the contents of a map, for example the basemap, operational layers, and the extent.

For example, here's how you could construct a web map with URL parameters that shows onshore wind farms within the United Kingdom.

http://www.arcgis.com/home/webmap/viewer.html?basemapUrl=http%3A%2F%2Fservices.arcgisonline.com%2FArcGIS%2Frest%2Fservices%2FOcean_Basemap%2FMapServer&url=http%3A%2F%2Fservices.arcgis.com%2FWQ9KVmV6xGGMnCiQ%2Farcgis%2Frest%2Fservices%2FOnshore_Windfarms%2FFeatureServer&extent=-24.3161%2C45.2274%2C18.0911%2C63.5381
NoteNote:

All query parameters must be encoded. URL encoding ensures that valid characters are sent to the portal website. Encoding replaces invalid characters with % followed by their hex equivalent.

For example, here is an unencoded URL parameter:

basemapUrl=http://services.arcgisonline.com/ArcGIS/rest/services/Ocean_Basemap/MapServer

Here is the same parameter encoded:

basemapUrl=http%3A%2F%2Fservices.arcgisonline.com%2FArcGIS%2Frest%2Fservices%2FOcean_Basemap%2FMapServer

Parameters within parameters must also be encoded. For example:

urls=http%3A%2F%2Fmaps.ngdc.noaa.gov%2Frest%2Fservices%2Fweb_mercator%2Ftrackline_gravity%2FMapServer%2Chttp%3A%2F%2Fmaps.ngdc.noaa.gov%2Frest%2Fservices%2Fweb_mercator%2Fhazards%2FMapServer%3Flayers%3Dshow%3A5%2C6
The web has many free sites and tools for generating encoded URLs. For readability, the rest of the examples in this topic are not encoded.

The URL always begins with the following:

http://www.arcgis.com/home/webmap/viewer.html?

The URL also includes one or more of the query parameters listed below.

To include more than one parameter, use an ampersand (&) to separate the parameters.

For example:

http://www.arcgis.com/home/webmap/viewer.html?center=20,45&level=4

Define the basemap used in the viewer.

Set basemapUrl= to the map service. If a basemap is not defined, the default basemap will be the World Topographic basemap. For example:

http://www.arcgis.com/home/webmap/viewer.html?
     basemapUrl=http://services.arcgisonline.com/ArcGIS/rest/services/World_Physical_Map/MapServer

Include a reference layer with the basemap. It must be used in addition to the basemapUrl.

Set basemapReferenceUrl= to the service. For example:

http://www.arcgis.com/home/webmap/viewer.html?
basemapUrl=http://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer
&basemapReferenceUrl=http://services.arcgisonline.com/ArcGIS/rest/services/Reference/World_Boundaries_and_Places/MapServer

Define the operational layers that overlay the basemap.

Use webmap=, url=, or urls=.

The webmap= parameter accepts the item ID of a saved web map. For example:

http://www.arcgis.com/home/webmap/viewer.html?webmap=2def3f0c7be74f05af33ac87b8d03ef2

The url= parameter accepts a single service URL. For example:

http://www.arcgis.com/home/webmap/viewer.html?
     url=http://services.arcgisonline.com/ArcGIS/rest/services/Demographics/USA_Population_Density/MapServer

Use urls= to include more than one service. Separate services with a comma. The map extent is based on the last service in the list or the slowest one to load. To zoom to a specific extent, include the extent= parameter. For example:

http://www.arcgis.com/home/webmap/viewer.html?urls=http://maps.ngdc.noaa.gov/rest/services/web_mercator/trackline_gravity/MapServer,http://maps.ngdc.noaa.gov/rest/services/web_mercator/hazards/MapServer?layers=show:5,6,12&extent=5,45,10,50

Center the map at a particular location.

Set center= using geographic coordinates (x,y) or projected coordinates (x,y,WKID).

Geographic coordinates example:

http://www.arcgis.com/home/webmap/viewer.html?center=20,45

Projected coordinates example:

http://www.arcgis.com/home/webmap/viewer.html?center=500000,5500000,102100

Define the scale level of the map viewer.

Use the center parameter and level=. The level parameter accepts the level ID of the cache scale as listed in the REST service endpoint. The cache scale level can be determined using the information on the map service's REST endpoint. The resolution is inversely related to the scale.

NoteNote:

Scale is automatically set when you use the webmap or find parameter; level is ignored. If you use the webmap parameter, the map is automatically zoomed to the full extent of the map. If you use the find parameter, the map is automatically zoomed to the best extent of the found location.

Geographic coordinates example:

http://www.arcgis.com/home/webmap/viewer.html?center=20,45&level=4

Projected coordinates example:

http://www.arcgis.com/home/webmap/viewer.html?center=500000,5500000,102100&level=4

Define the extent of the map.

Use extent= to define the extent of the map. The extent parameter accepts geographic coordinates (GCS) as MinX,MinY,MaxX,MaxY or projected coordinates (PCS) as MinX,MinY,MaxX,MaxY,WKID.

Geographic coordinates example:

http://www.arcgis.com/home/webmap/viewer.html?extent=-117.20,34.055,-117.19,34.06

Projected coordinates example:

http://www.arcgis.com/home/webmap/viewer.html?extent=-13079253.954115,3959110.38566837,-12918205.318785,4086639.70193162,102113

Set the visibility of layers in the map.

Use layers=show:. For example:

http://www.arcgis.com/home/webmap/viewer.html?url=http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/BloomfieldHillsMichigan/Parcels/MapServer?layers=show:1,2

Find a location that is used to open the map. The map is automatically zoomed to the closest match and a callout marker is added to the map.

Use find=. The find parameter accepts single-line addresses, partial addresses (such as city only or country only), place-names, and latitude-longitude coordinates. For example:

http://www.arcgis.com/home/webmap/viewer.html?find=380 new york st,redlands,ca
3/24/2014