ArcGIS Blog

Mapping

ArcGIS Pro

A new class in arcpy.sharing for vector tile layers with associated feature layers

By Jonah Lay

With the release of ArcGIS Pro 3.5, we’re introducing VectorTileSharingDraft, a new class in the arcpy.sharing module that brings a new level of support for sharing vector tile layers with associated web feature layers using Python. This article covers the basics of the VectorTileSharingDraft class and how it allows you to automate sharing vector tile layers with associated web feature layers to ArcGIS Online and ArcGIS Enterprise.

Vector tile layers continue to prove invaluable in their ability to visualize vector data across a range of scales and display resolutions. They can be customized and restyled for a variety of uses. Vector tile layers can have an associated web feature layer, which supports querying, editing, filtering, and pop-ups. With an associated feature layer, you can also rebuild the vector tile cache to incorporate edits made to the feature layer.

Previously, publishing vector tile layers with associated web feature layers was only possible using the ArcGIS Pro user interface. The VectorTileSharingDraft class allows you to automate the same workflow with Python, streamlining your sharing process and helping you efficiently maintain your web apps.

Share a vector tile layer with an associated web feature layer with ArcGIS Pro or Python
With the VectorTileSharingDraft class, you can use Python to share layers in your ArcGIS Pro project as vector tile layers with associated web layers to a portal.

Here’s how it works…

Like other sharing classes such as FeatureSharingDraftMapImageSharingDraft, and SceneLayerSharingDraft, the VectorTileSharingDraft is created using the Map object’s getWebLayerSharingDraft method:

getWebLayerSharingDraft(server_type, service_type, service_name, {layers_and_tables})

To create a sharing draft for a vector tile layer, specify the following parameters:

  • server_type—Set HOSTING_SERVER if you want the vector tile layer to copy all data; an associated web feature layer is included. Set FEDERATED_SERVER if you want the vector tile layer to reference registered data; an associated map image layer and web feature layer are included.
  • service_type—Set VECTOR_TILE.
  • layers_and_tables—This is an optional parameter. If used, it should be a list of layers, with at least one 2D point, line, or polygon layer. Use the listMapsfunction from the ArcGISProject object and the listLayers method on the Map class to reference the layer in the map you want to publish. If the parameter is not used, all supported layers in the map will be included when the VectorTileSharingDraft object is published.

Once the VectorTileSharingDraft object is configured, you can set service level properties on the vector tile layer and associated web layers. For example, you can define the tiling scheme and the number of tiles that can be downloaded in a single request for offline use. You can also configure editing, synchronization, and querying capabilities on the associated web feature layer. For a complete list of configurable properties, see Properties.

Next, you can optionally use the new analyzeForSharing method to analyze the VectorTileSharingDraft object and review any errors and warnings.

Finally, publish the vector tile layer and any associated web layers using the Publish function:

Publish(object, {item_id})

You can use the optional item_id parameter to specify item IDs for the vector tile layer and associated web layers. The parameter is honored for vector tile layers and web feature layers when sharing to ArcGIS Enterprise 10.8.1 or later. For map image layers, the parameter is honored when sharing to ArcGIS Enterprise 11.2 or later.

The item_id parameter must be structured as a dictionary:

{
"vector_tile_layer_id":"f62ad2a55deb4c9fa4f2faaf2fea96db",
"web_feature_layer_id":"a31dc5cb6c8f425fb9c67e8801e48735",
"map_image_layer_id":"54727ad350f74b7abfa84e1fc122c071"
}

As shown in the example above, the IDs must be available and contain 32 alphanumeric values ranging from the letters a to f and numbers 0 to 9. An item ID will be automatically created if no ID is specified.

Once the vector tile layer and associated web layers are published to ArcGIS Online or ArcGIS Enterprise, caching starts on the server. Once caching is successful, you are ready to use the vector tile layer in your web map.

We are excited for you to try out this new arcpy.sharing class. For in-depth information on the content covered in this article, including sample codes, see the VectorTileSharingDraft ArcGIS Pro help topic.

For information on automating sharing web layers (including sharing vector tile packages) and the other classes available in the arcpy.sharing module, see the following ArcGIS Pro help topics:

For further information, visit the ArcGIS Pro page or the What’s New documentation and post your questions in the ArcGIS Pro board in Esri Community.

Share this article

Subscribe
Notify of
0 Comments
Oldest
Newest
Inline Feedbacks
View all comments