Publish a vector tile layer

Learn how to use ArcGIS Online and scripting APIs to publish a vector tile layer.

To create a vector tile layer, you first import data as a hosted feature layer and then publish it as a hosted vector tile layer. This workflow is helpful when you need to render large datasets on the client. Using a vector tile layer can significantly improve display performance of the data in a map.

In this tutorial, you use ArcGIS Online or scripting APIs to convert a hosted feature layer to a hosted vector tile layer using the Santa Monica Mountains Parcels dataset, which contains a large amount of polygon features that represent property parcels.

Prerequisites

You need an ArcGIS Developer or ArcGIS Online account to access and manage hosted layers.

Steps

Download the data

Use the Santa Monica Mountains Parcles dataset as the basis for this tutorial. However, you can also use your own feature layer created in either the Import data as a feature layer or Create a new feature layer tutorials.

  1. Download the Santa Monica Mountains Parcles dataset. Do not unzip this file, you will upload it as is.

Create a feature layer

ArcGIS Onlinescripting APIs

Import the downloaded Shapefile to create a hosted feature layer.

  1. Sign in to your account in ArcGIS Online.

  2. Click Content > Add Item > Upload from computer.

  3. Upload the Santa_Monica_Mountains_Parcels.zip Shapefile. Wait for the upload to complete. When it completes, you will be directed to the item page of the new feature layer.

  1. Import libraries.
  2. Provide authentication.
  3. Create a portal item.
  4. Publish portal item.
  5. Handle the results.
ArcGIS REST JSArcGIS REST JSArcGIS Python API
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
  // publish parameters
  // https://developers.arcgis.com/rest/users-groups-and-items/publish-item.htm#ESRI_SECTION1_1016F32E313240D38E8CF741BDBC0BE8
  const publishParams = {
    name: 'Santa Monica Mountains Parcels',
    maxRecordCount: 2000,
    hasStaticData: true,
    layerInfo: { capabilities: 'Query' },
  };

  // create item
  const zipItem = await createItem({
    authentication: auth,
    item: {
      title: 'Santa Monica Mountains Parcels',
      description: 'Santa Monica mountain parcels',
      tags: 'Santa, Monica, mountain, parcels',
      type: 'Shapefile',
    },
    file: f,
  });

  // execute publish operation
  const publishedService = await request(publishURL, {
    authentication: auth,
    params: {
      itemid: zipItem.id,
      filetype: 'shapefile',
      publishParameters: publishParams,
    },
  });

  // handle results
  console.log('New service created: ');
  publishedService.services.forEach((s) => {
    console.log(`\tid: ${s.serviceItemId} \n\turl:${s.serviceurl}`);
  });
Expand

Style the feature layer

ArcGIS Onlinescripting APIs

Before publishing a vector tile layer, it is recommended to style the feature layer. When you style the feature layer, the styles will be applied to the vector tile layer when it's published. You can also associate attributes with the vector tile layer that is published.

  1. Go back to the item page page > Visualization.

  2. In the left panel, click the Change style icon.

  3. Under Choose an attribute to show select: UseType.

  4. Under Select a drawing style > Types(Unique symbols) > Options.

  5. Click Symbols to select a color ramp to display different colors for each type of parcel.

  6. Click Outline and set the following:

    • Hex code: #1A1A1A.
    • Uncheck Adjust outline automatically.
    • Transparency: 5%.
    • Line Width: 1 px.
  7. Click OK

  8. Set the Overall Transparency to 50% > OK > Done.

  9. Click Save to save the stylings for your layer.

  1. Import libraries.
  2. Provide authentication.
  3. Retrieve feature layer properties.
  4. Define a new renderer.
  5. Update feature layer.
  6. Handle results.
ArcGIS REST JSArcGIS REST JSArcGIS Python API
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
  // get layer properties
  const layerAdminInfo = await getServiceAdminInfo(featureLayerURL, auth);

  // update the renderer
  layerAdminInfo.drawingInfo.renderer = newRenderer;

  // reset edit date
  layerAdminInfo.editingInfo.lastEditDate = null;

  // updateDefinition endpoint
  const updateURL = `${adminURL}/updateDefinition`;

  // execute updateDefinition operation
  const results = await request(updateURL, {
    authentication: auth,
    params: {
      updateDefinition: layerAdminInfo,
    },
  });

  console.log(results);
Expand

Publish a vector tile layer

ArcGIS Onlinescripting APIs
  1. Go back to the item page page of the feature layer.

  2. On the right-side of the page, click Publish > Vector Tile layer.

  3. Click Select attributes and select UseType and Roll_LandV.

  4. At minimum, enter a Title and Tags for your vector tile layer. Click OK.

    Once you click OK, you will be directed to the item page page for the new vector tile layer. Wait for the the cache to build.

  5. In the item page, click Share > Everyone (public).

  1. Import libraries.
  2. Reference feature layer.
  3. Define publish parameters.
  4. Execute publish operation.
  5. Handle results.
ArcGIS REST JSArcGIS REST JSArcGIS Python API
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
  // execute publish operation
  const publishedService = await request(publishURL, {
    authentication: auth,
    params: {
      itemid: '<YOUR ITEM ID>',
      outputType: 'vectorTiles',
      filetype: 'featureService',
      publishParameters: vectorTileParams,
    },
  });

  // handle results
  console.log('New service created: ');
  publishedService.services.forEach((s) => {
    console.log(`\tid: ${s.serviceItemId} \n\turl:${s.serviceurl}`);
  });
Expand

View the vector tile layer

  1. In the item page, click Open in Map Viewer to view the vector tile layer.

Your vector tile layer should look something like this.

Find the URL endpoint and style definition

The item for a vector tile layer defines the service properties and its styles.

  1. In the item page, scroll down the page and click View to view the vector tile layer metadata and its service URL. To access the vector tile data in an application, use the URL+tile/{z}/{y}/{x}.pbf. For example:

    Use dark colors for code blocksCopy
     
    1
    https://vectortileservices3.arcgis.com/<YOUR_ORG>/arcgis/rest/services/<YOUR_VECTOR_TILE>/VectorTileServer/tile/{z}/{y}/{x}.pbf
  2. Go back to the item page. To view the style, click View style. The style will look something like this:

    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
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    {
      "version":8,
      "sprite":"../sprites/sprite",
      "glyphs":"../fonts/{fontstack}/{range}.pbf",
      "sources":{
         "esri":{
            "type":"vector",
            "url":"../../"
         }
      },
      "layers":[
         {
            "id":"Santa_Monica_Mountains_Parcels_Styled/Residential",
            "type":"fill",
            "source":"esri",
            "source-layer":"Santa_Monica_Mountains_Parcels_Styled",
            "filter":[
               "==",
               "_symbol",
               0
            ],
    }

With the vector tile layer published, you can now access the layer using the {z}/{y}/{x}.pbf path. Or, you can access the style with the service URL+root.json. For example:

Use dark colors for code blocksCopy
 
1
https://vectortileservices3.arcgis.com/<YOUR_ORG>/arcgis/rest/services/<YOUR_VECTOR_TILE>/VectorTileServer/resources/styles/root.json

What's Next?

Learn how to use additional tools, APIs, and location services in these tutorials:

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