To display a polygon on a static map/with-polygon endpoint from the ArcGIS Static Maps servicepolygon parameter, where each ring is defined by 3 to 10 x,y coordinate pairs that form the polygon boundary. You can also specify the polygon fill and outline colors. Additionally, specify the image width and height in pixels, along with the output format (png, jpeg, or webp).
How to display a static map with a polygon
The typical workflow to display a static map with a polygon is:
- Map: Define the
basemapand map area withStyle centerandX center, andY zoomorradius. - Geometry: Define the
polygonarray containing the rings with x,y coordinate pairs that define the polygon. - Image: Specify the image
heightandwidthin pixels,format, andattributionstyle. - Request: Send a
GETrequest to the/with-polygonendpoint to generate the static map.
Service URL
https://static-maps-api.arcgis.com/arcgis/rest/services/static-maps-service/v1/static-mapsPath parameters
These are required parameters to specify the style to access.
https://static-maps-api.arcgis.com/arcgis/rest/services/static-maps-service/v1/static-maps/{basemapStyle}/with-polygon| Name | Description | Example |
|---|---|---|
{version} | Required: The API version. | v1 |
{basemap | Required: The basemap style for the static map. | arcgis/navigation, arcgis/navigation-night, arcgis/imagery, arcgis/streets-night, or arcgis/streets |
Query parameters
| Name | Type | Required | Default value | Description |
|---|---|---|---|---|
token | string | | An access token with the static maps service privilege. To pass the token as an authorization header, see HTTP authorization headers. | |
polygon | Ring | | An array of x,y coordinate pairs in the WGS84 spatial reference defining a polygon boundary. Accepts 3 to 10 coordinate pairs. | |
fillColor | HexColor | 007 | Polygon fill color in hexadecimal format. | |
fillStyle | string | solid | Polygon fill style. Supported values include | |
format | ImageFormat | webp | Output image format of the map. Supported formats include | |
height | ImageDimensionHeight | 400 | Height of the map image in pixels. Values must be between | |
width | ImageDimensionWidth | 400 | Width of the map image in pixels. Values must be between | |
outlineColor | HexColor | 007 | Polygon outline color in hexadecimal format. | |
outlineStyle | LineStyle | solid | Polygon outline stroke. Supported values include | |
outlineWidth | integer | 4 | Polygon outline width in device-independent pixels. Values range from | |
padding | ImagePadding | 10 | Padding percentages around the map extent. Accepts an array of 1–4 values; default is | |
centerX | number(double) | | X-coordinate of the map center in WGS84 decimal degrees. Values range from | |
centerY | number(double) | | Y-coordinate of the map center in WGS84 decimal degrees. Values range from | |
zoom | ZoomLevel | | A number that defines the level of detail of the map. Values range from | |
radius | RadiusDistance | | A number (in meters) that defines the minimum geographic area around a center point of the map. If no center point is supplied, the radius is applied to the geometry. Values range from | |
attribution | string | auto | Attribution footer style. To learn more about attribution requirements for static maps, see Esri and data attribution. | |
referenceDetails | string | all | A basemap option that controls the visibility of labels and feature symbology. This parameter is currently supported only for the |
Code examples
Display a polygon for a building footprint
Use the Static Maps service to display a static map with polygons highlighting the building footprints of Denver Health Hospital. This allows you to identify specific buildings and understand their layout. The map uses the ArcGIS Navigation basemap style.
Steps
- Reference the service.
- Set the API key in the
Authorizationrequest header using theBearerauthentication scheme. - Define the polygon array, fill and outline colors, and other parameters for the request.
- Send the request to the Static Maps service to generate the static map.
const res = await fetch(
`https://static-maps-api.arcgis.com/arcgis/rest/services/static-maps-service/v1/static-maps/${basemapStyle}/with-polygon?fillStyle=solid&format=png&height=250&width=500&outlineStyle=solid&outlineWidth=2&polygon=${polygon}¢erX=-104.99188¢erY=39.726894&zoom=15&fillColor=00509f1A&outlineColor=003366c2`,
{
method: "GET",
headers: {
Authorization: `Bearer ${accessToken}`,
},
}
);
const blob = await res.blob();
const mapEl = document.getElementById("parkMap");
mapEl.src = URL.createObjectURL(blob);
mapEl.style.display = "block";
REST API
curl -X GET \
'https://static-maps-api.arcgis.com/arcgis/rest/services/static-maps-service/v1/static-maps/arcgis/navigation/with-polygon?fillStyle=solid&format=png&height=250&width=500&outlineStyle=solid&outlineWidth=2&polygon=[[-104.9920565,39.7287284],[-104.9920565,39.7281439],[-104.9916087,39.7281439],[-104.9916087,39.7285822],[-104.9918903,39.7287962],[-104.9920565,39.7287284]]¢erX=-104.991326¢erY=39.7280192&zoom=15&fillColor=00509f87&outlineColor=003366c2&token=<ACCESS_TOKEN>'Tutorials
