サマリー
The VectorTileSharingDraft class allows you to create a sharing draft for a vector tile layer with an associated web feature layer. You can configure the VectorTileSharingDraft object for a vector tile layer that copies all data, or references registered data, to ArcGIS Enterprise 10.8.1 and later, or copies all data to ArcGIS Online.
To publish a vector tile layer cached locally in Python, use geoprocessing tools instead. For more information, see Publish web layers using packages.
説明
To create the VectorTileSharingDraft object, use the Map object's getWebLayerSharingDraft method and set the service_type parameter to VECTOR_TILE. To specify whether the vector tile layer copies all data or references registered data to ArcGIS Enterprise, set the server_type parameter to one of the following:
- HOSTING_SERVER—Copies all data; an associated web feature layer is included.
- FEDERATED_SERVER—References registered data; an associated map image layer and web feature layer are included.
Additionally, the layers_and_tables parameter of the getWebLayerSharingDraft method is optional. If used, it should be a list of layers, with at least one 2D point, line, or polygon layer. Use the listMaps function 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.
The VectorTileSharingDraft object can then be configured by setting service level properties. You can also set properties on the VectorTileSharingDraft object for the associated web feature layer and map image layer. If no value is specified for a property, the default value is used. Information about each property is provided in the Properties list below.
注意:
メタデータのプロパティ (credits、description、summary、tags、useLimitations) が設定されていないか空の文字列で構成されている場合、Web レイヤー アイテムは、共有されるものに応じてマップまたはレイヤーからメタデータを供給します。 Web レイヤーがメタデータを供給する方法については、「Web レイヤーのメタデータ」をご参照ください。
After the VectorTileSharingDraft object is configured, it can be analyzed for errors and warnings using the optional analyzeForSharing method, and published using the Publish function. The Publish function publishes the vector tile layer and any associated web layers to either ArcGIS Online or ArcGIS Enterprise, and starts caching on the server.
Code samples are available for the following:
プロパティ
プロパティ | 説明 | データ タイプ |
allowTrueCurvesUpdates (読み書き) | Specifies whether web clients will be allowed to update the true curve geometry of a feature with densified geometry. This property is only honored when editing is enabled and server_type is set to FEDERATED_SERVER. The default value is False. This is a web feature layer property. | Boolean |
allowUpdateWithoutMValues (読み書き) | Specifies whether geometry updates to m-enabled features are allowed without specifying an m-value. The default value is True. This is a web feature layer and map image layer property. | Boolean |
approvePublicDataCollection (読み書き) | Specifies whether public editing will be allowed on a web feature layer. The default value is False. | Boolean |
cache.configuration (読み書き) | The path and file name of a predefined tiling scheme .xml file generated by the Generate Map Server Cache Tiling Scheme tool. | String |
cache.exportTiles (読み書き) | Specifies whether clients will be allowed to download map tiles for offline use. The default value is False. | Boolean |
cache.exportTilesCount (読み書き) | The maximum number of tiles that can be downloaded in a single request. This property is only honored if the cache.exportTiles property is set to True. The default value is 100000. | Integer |
credits (読み書き) | The credits of the web layer. | String |
description (読み書き) | The description of the web layer. | String |
featureCapabilities (読み書き) | The enabled capabilities, separated by commas. The following capabilities are supported:
Query, Create, Update, Delete, and Editing are the defaults when the server_type property is set to FEDERATED_SERVER. This is a web feature layer and map image layer property. | String |
maxRecordCount (読み書き) | The maximum number of records that will be returned by the server during querying. The default value is 2000. This is a web feature layer and map image layer property. | Integer |
onlyAllowTrueCurveUpdatesByTrueCurveClients (読み書き) | Specifies whether only clients that support true curves, such as ArcGIS Pro, will be allowed to update true curve geometries. This property is only honored when editing is enabled, and server_type is set to FEDERATED_SERVER. The default value is False. This is a web feature layer property. | Boolean |
portalFolder (読み書き) | The name of the portal folder where the web layer will be published. The default folder is your root folder in My Content. | String |
preserveEditUsersAndTimestamps (読み書き) | Specifies whether editor tracking information will be preserved. The default value is False. This is a web feature layer property. | Boolean |
serviceName (読み書き) | The name of the web layer. This is the name people will see and use to identify the web layer. The name can only contain alphanumeric characters and underscores. No spaces or special characters are allowed. The name cannot be more than 120 characters. | String |
sharing.groups (読み書き) | The group names, separated by commas. | String |
sharing.sharingLevel (読み書き) | Specifies the sharing level of the web layer.
| String |
summary (読み書き) | The summary of the web layer. | String |
tags (読み書き) | The tags of the web layer. Multiple tags can be added or separated by a comma. | String |
timezone.DaylightSavingTime (読み書き) | Specifies whether the time zone accounts for daylight saving time. The default value is False. This is a web feature layer and map image layer property. | Boolean |
timezone.ID (読み書き) | The time zone in which date values are stored. The string value must match one of the official time zone IDs recognized by the Windows operating system. For a list of time zones, see Time zones in the Microsoft documentation. This is a web feature layer and map image layer property. | String |
timezone.preferredTimezoneID (読み書き) | The time zone ArcGIS Pro will use when displaying queries from the web feature layer. The string value must match one of the official time zone IDs recognized by the Windows operating system. For a list of time zones, see Time zones in the Microsoft documentation. This is a web feature layer and map image layer property. | String |
timezone.preferredTimezoneIDDaylightSavingTime (読み書き) | Specifies whether the preferred time zone accounts for daylight saving time. The default value is False. This is a web feature layer and map image layer property. | Boolean |
useCIMSymbols (読み書き) | Specifies whether Esri Cartographic Information Model (CIM) symbols, also known as ArcGIS Pro symbols, will be used. Set to False to use symbols that can be rendered by all clients. Set to True to use CIM symbols supported by newer clients such as ArcGIS API for JavaScript 4.x. This property is only honored if an associated feature layer is included, and the service definition is published to ArcGIS Online or ArcGIS Enterprise 11.3 or later. | Boolean |
useLimitations (読み書き) | The use limitations of the web layer. | String |
zDefault.enable (読み書き) | Specifies whether editors will be allowed to add or update features through clients that don't allow a z-value to be given. The default value is True. This is a web feature layer and map image layer property. | Boolean |
zDefault.value (読み書き) | The default z-value that will be used when inserting or updating features. This property is only honored if the zDefault.enable property is set to True. The default value is 0. This is a web feature layer and map image layer property. | Double |
方法の概要
方法 | 説明 |
analyzeForSharing () | The analyzeForSharing method analyzes the VectorTileSharingDraft object and returns errors, warnings, and messages. |
方法
analyzeForSharing ()
データ タイプ | 説明 |
Dictionary | A dictionary of errors and warnings. |
コードのサンプル
The following script creates a vector tile layer sharing draft for two layers in a map and sets metadata and folder properties. The vector tile layer is published to a folder in either ArcGIS Online or ArcGIS Enterprise and shared with everyone (public). Portal information is obtained from the SignInToPortal function.
import arcpy
# Sign in to portal
arcpy.SignInToPortal("https://www.arcgis.com", "MyUserName", "MyPassword")
# Reference layer to publish
aprx = arcpy.mp.ArcGISProject(r"C:\Project\World.aprx")
m = aprx.listMaps('World')[0]
lyrs = []
lyrs.append(m.listLayers('Cities')[0])
lyrs.append(m.listLayers('Counties')[0])
# Create VectorTileSharingDraft and set metadata and portal folder properties
server_type = "HOSTING_SERVER"
service_type = "VECTOR_TILE"
service_name = "VectorTileSharingDraftExample"
vector_draft = m.getWebLayerSharingDraft(server_type, service_type, service_name,
lyrs)
vector_draft.credits = "These are credits"
vector_draft.description = "This is description"
vector_draft.summary = "This is summary"
vector_draft.tags = "tag1, tag2"
vector_draft.useLimitations = "These are use limitations"
vector_draft.portalFolder = "my folder name"
vector_draft.sharing.sharingLevel = "EVERYONE"
vector_draft.sharing.groups = "" # Group names = "group1,group2"
# Share to portal
print("Start Publishing")
res = arcpy.sharing.Publish(vector_draft)
print(r"item_url: " + res["vector_tile_layer"]["item_url"])
print(r"rest_url: " + res["vector_tile_layer"]["rest_url"])
print(r"cache_job_id: " + res["vector_tile_layer"]["cache_job_id"])
print("Finish Publishing")
The following script creates a vector tile layer sharing draft. The sharing draft is analyzed. If analyzer 00231 is returned, the data store is registered using the arcgis.gis module in ArcGIS API for Python.
import arcpy
# Add a data store item on the portal and register it with a federated server
def register_datastore_item(portal_url, username, password, sde_conn_file,
data_store_name, federated_server_url):
from arcgis.gis import GIS
tags = "tag1, tag2"
description = "Data Store Item created from ArcGIS API for Python"
federated_server_url = federated_server_url.rstrip('/')
federated_server_adminurl = federated_server_url + "/admin"
# Connect to your portal using ArcGIS API for Python
gis = GIS(url=portal_url, username=username, password=password)
# Get federated server ID
server_list = gis.servers["servers"]
fedserver_dict = [srvr for srvr in server_list if srvr["url"] == federated_server_url][0]
fedserver_id = fedserver_dict["id"]
print("Server id: " + fedserver_id)
# Get federated server's DatastoreManager object
fedserver = [srvr for srvr in gis.admin.servers.list() if srvr.url == fedserver_dict["adminUrl"]+"/admin"][0]
fedserver_dsmgr = fedserver.datastores
# Create a connection string from .sde file connection
conn_file = sde_conn_file
conn_string = fedserver_dsmgr.generate_connection_string(conn_file)
print("Connection string generated")
# Create a dictionary for data store configuration
ds_config = {"type": "egdb",
"path": "/enterpriseDatabases/" + data_store_name,
"info": {"isManaged": "false",
"dataStoreConnectionType": "shared",
"connectionString": conn_string}
}
# Create a dictionary for the item properties
item_properties = {"title": data_store_name,
"type": "Data Store",
"tags": tags,
"snippet": description}
# Add the data store item to the portal
ds_item = gis.content.add(item_properties=item_properties,
text=ds_config)
print("Data store item added")
# Get portal data store
portal_ds = gis.datastore
# Validate the data store item, which can be connected before registering
validation_state = portal_ds.validate(server_id=fedserver_id,
item=ds_item)
print("Data store item validated")
# Register the database with the federated server
portal_ds.register(item=ds_item,
server_id=fedserver_id,
bind=False)
print("Data store item registered to server")
return True
if __name__ == "__main__":
portal_url = "https://organization.example.com/webadaptorname"
username = "MyUserName"
password = "MyPassword"
# Sign in to portal
arcpy.SignInToPortal(portal_url, username, password)
# Reference layer to publish
aprx = arcpy.mp.ArcGISProject(r"C:\Project\World.aprx")
m = aprx.listMaps('World')[0]
lyr = m.listLayers('Cities')
# Local variables
server_type = "FEDERATED_SERVER"
service_type = "VECTOR_TILE"
service_name = "VectorTileSharingDraftExample"
sde_conn_file = r"C:\Project\db_conn.sde"
data_store_name = "PortalDSItem"
# Create VectorTileSharingDraft for vector tile layer that references data
# in registered data store and set metadata, portal folder, and server
# folder properties.
vector_draft = m.getWebLayerSharingDraft(server_type, service_type,
service_name, lyr)
vector_draft.credits = "These are credits"
vector_draft.description = "This is description"
vector_draft.summary = "This is summary"
vector_draft.tags = "tag1, tag2"
vector_draft.useLimitations = "These are use limitations"
vector_draft.portalFolder = "my folder name"
vector_draft.serverFolder = "MyServerFolder"
vector_draft.sharing.sharingLevel = "EVERYONE"
vector_draft.sharing.groups = "" # Group names = "group1,group2"
print("Analyzing")
analyze_res = vector_draft.analyzeForSharing()
print(analyze_res)
register_error = [err for err in analyze_res["errors"] if err["code"] == "00231"]
# If data store is not registered
if register_error:
# Register data store
register_res = register_datastore_item(portal_url, username, password,
sde_conn_file, data_store_name,
"https://gisserver.example.com/webadaptorname")
if not register_res:
print("Unable to register the data store, skipping publish")
exit()
# Share to portal
print("Start Publishing")
res = arcpy.sharing.Publish(vector_draft)
print(r"item_url: " + res["vector_tile_layer"]["item_url"])
print(r"rest_url: " + res["vector_tile_layer"]["rest_url"])
print(r"cache_job_id: " + res["vector_tile_layer"]["cache_job_id"])
print("Finish Publishing")
The following script creates a vector tile layer sharing draft for a map and sets capabilities and time zone for the associated web feature layer. It then specifies item IDs for the vector tile layer and associated web layers. The vector tile layer is published to ArcGIS Enterprise. The data store must be registered on the server before the data can be referenced.
import arcpy
# Sign in to portal
arcpy.SignInToPortal("https://organization.example.com/webadaptorname",
"MyUserName", "MyPassword")
# Reference map to publish
aprx = arcpy.mp.ArcGISProject(r"C:\Project\World.aprx")
m = aprx.listMaps('World')[0]
# Create VectorTileSharingDraft and set feature capabilities and time zone
# properties
server_type = "FEDERATED_SERVER"
service_type = "VECTOR_TILE"
service_name = "VectorTileSharingDraftExample"
vector_draft = m.getWebLayerSharingDraft(server_type, service_type, service_name)
vector_draft.featureCapabilities = "Query,Create,Update"
vector_draft.timezone.ID = "Pacific Standard Time"
vector_draft.timezone.DaylightSavingTime = True
# Publish vector tile layer using the VectorTileSharingDraft object and specific
# item ID. The ID must be available and contain 32 alphanumeric values ranging
# from letters a to f and numbers 0 to 9.
item_id = {
"vector_tile_layer_id": "itemid1",
"web_feature_layer_id": "itemid2",
"map_image_layer_id": "itemid3"
}
# Share to portal
print("Start Publishing")
res = arcpy.sharing.Publish(vector_draft, item_id)
print(r"item_url: " + res["vector_tile_layer"]["item_url"])
print(r"rest_url: " + res["vector_tile_layer"]["rest_url"])
print(r"cache_job_id: " + res["vector_tile_layer"]["cache_job_id"])
print("Finish Publishing")