Build a URL to create a static map with a polyline.

To display a polyline on a static map, use the /with-polyline endpoint from the ArcGIS Static Maps service. Provide an array of 2 to 10 x,y coordinate pairs in the polyline parameter to define the path. You can also specify the polyline color, line style, and width. 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 polyline

The typical workflow to display a static map with a polyline is:

  1. Map: Define the basemapStyle and map area with centerX andcenterY, and zoom or radius.
  2. Geometry: Define the polyline array containing the x,y coordinate pairs that define the polyline.
  3. Image: Specify the image size height and width in pixels, format, and attribution style.
  4. Request: Send a GET request to the /with-polyline endpoint to generate the static map.

Service URL

Use dark colors for code blocksCopy
1
https://static-maps-api.arcgis.com/arcgis/rest/services/static-maps-service/v1/static-maps

Path parameters

These are required parameters to specify the style to access.

Use dark colors for code blocksCopy
1
https://static-maps-api.arcgis.com/arcgis/rest/services/static-maps-service/v1/static-maps/{basemapStyle}/with-polyline
NameDescriptionExample
{version}Required: The API version.v1
{basemapStyle}Required: The basemap style for the static map.arcgis/navigation, arcgis/navigation-night, arcgis/imagery, arcgis/streets-night, or arcgis/streets

Query parameters

NameTypeRequiredDefault valueDescription
tokenstring

An access token with the static maps service privilege. To pass the token as an authorization header, see HTTP authorization headers.

polylinePathGeometryGet

An array of x,y coordinate pairs defining a polyline in WGS84 spatial reference. Accepts 2 to 10 coordinate pairs.

endSymbolLabelSymbolLabel

Label displayed on the point symbol at the end of a polyline. Accepts 1–2 alphanumeric characters (A-Z, a-z, 0-9).

endSymbolColorstring007AC2

Point symbol color at the end of a polyline in hexadecimal format.

endSymbolStyleSymbolStylepin

Point symbol style at the end of the polyline. Supported values include pin, circle, square, none.

lineColorHexColor007AC2

Line symbol color in hexadecimal format.

lineStyleLineStylesolid

Line symbol stroke applied to the polyline. Supported values include solid, dash, dot.

lineWidthinteger4

Line symbol width in device-independent pixels. Values range from 1 to 16.

formatImageFormatwebp

Output image format of the map. Supported formats include png, jpeg, and webp.

heightImageDimensionHeight400

Height of the map image in pixels. Values must be between 128 and 1024.

widthImageDimensionWidth400

Width of the map image in pixels. Values must be between 128 and 1024.

paddingImagePadding10

Padding percentages around the map extent. Accepts an array of 1–4 values; default is 10 on all sides, maximum is 25.

startSymbolLabelSymbolLabel

Label displayed on the point symbol at the start of a polyline. Accepts 1–2 alphanumeric characters (A-Z, a-z, 0-9).

startSymbolColorstring007AC2

Point symbol color at the start of a polyline in hexadecimal format.

startSymbolStyleSymbolStylepin

Point symbol style at the start of the polyline. Supported values include pin, circle, square, and none.

symbolScaleSymbolScale1

Scale factor applied to the point symbol size. Values range from 0.1 to 4.0.

centerXnumber(double)

X-coordinate of the map center in WGS84 decimal degrees. Values range from -179.99 to 179.99.

centerYnumber(double)

Y-coordinate of the map center in WGS84 decimal degrees. Values range from -85.05 to 85.05.

zoomZoomLevel

A number that defines the level of detail of the map. Values range from 0 to 22.

radiusRadiusDistance

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 10 to 20,000,000.

attributionstringauto

Attribution footer style. To learn more about attribution requirements for static maps, see Esri and data attribution.

referenceDetailsstringall

A basemap option that controls the visibility of labels and feature symbology. This parameter is currently supported only for the arcgis/imagery style. Supported values include all and none.

Code examples

Display a polyline for a driving route

Use the Static Maps service to draw a line representing a route on a static map. The image is displayed in a rideshare receipt along with details such as pick-up and drop-off points, distance, travel time, and fare breakdown. The image uses a pin to represent the destination and a circle to indicate the starting point.

Steps

  1. Reference the service.
  2. Define the polyline as an array of x,y coordinate pairs in the WGS84 spatial reference.
  3. Set the API key in the Authorization request header using the Bearer authentication scheme.
  4. Send the request to the Static Maps service to generate the static map.
Rideshare receipt showing a static map with a polyline
JavaScript
Expand
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
      fetch(
        `https://static-maps-api.arcgis.com/arcgis/rest/services/static-maps-service/v1/static-maps/${basemapStyle}/with-polyline?polyline=${JSON.stringify(route)}&startSymbolStyle=circle&endSymbolStyle=pin&symbolScale=1&lineColor=007AC2&startSymbolColor=35AB46&endSymbolColor=F36F21&lineWidth=5&width=400&height=500&format=png&zoom=13`,
        {
          headers: {
            Authorization: `Bearer ${accessToken}`,
          },
        }
      )
        .then((response) => response.blob())
        .then((blob) => {
          document.getElementById("mapImage").src = URL.createObjectURL(blob);
        });
Expand

REST API

cURLcURLHTTP
Use dark colors for code blocksCopy
1
2
curl -X GET "https://static-maps-api.arcgis.com/arcgis/rest/services/static-maps-service/v1/static-maps/arcgis/streets/with-polyline?polyline=[[-116.51055445979493,33.82303750349174],[-116.53701714772251,33.82306348953144],[-116.5368920286327,33.82677940662155],[-116.53958208906323,33.826857361194676]]&startSymbolStyle=circle&endSymbolStyle=pin&symbolScale=1&lineColor=007AC2&startSymbolColor=35AB46&endSymbolColor=F36F21&lineWidth=5&width=400&height=500&format=png" \
	-H "Authorization: Bearer <ACCESS_TOKEN>"

Tutorials

Display a simple static map

Display a static map with a point, polyline, or polygon.


Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.