Hello,
I have a script that updates the vector basemap, what I would like for the script to do is enable offline mode after it has updated the vector basemap I have done a lot of searching and cant seem to find the code that would enable this. below is a copy of the script.
I imagine it would come in under this line # Replace Field Maps Basemap
# Name: CreateVectorTilePackage.py
# Description: Find all the maps in the project and
# create a vector tile package for each map
# import system modules
import os
import arcpy
#set environment settings
arcpy.env.overwriteOutput = True
# Share Field Maps Basemap package online
print("Starting Packaging Basemap")
TempHarvestBasemap = arcpy.SharePackage_management(r"L:\GIS\ArcGIS Pro Projects\Vector_Tiles\TempPackages\TEMPFieldMapsBasemap.vtpk", "AUSERNAME", "APASSWORD",
"Authoritive Field Collection Base Map", "Field, Vector Basemap", "Created from arcgis pro vector tiles",
"MYGROUPS", "ABC", "MYORGANIZATION", "True",
"Packages")
print("Uploaded TempFieldMapsBasemap")
# Login to AGOL
from arcgis.gis import GIS
gis = GIS("https://www.arcgis.com", "AUSERNAME", "APASSWORD")
print("Logged in")
# Update the Field Maps Base Map
# Search for a layer
print("searching for layer")
package = gis.content.search(query="title:TempFieldMapsBasemap",item_type="Vector Tile Layer" )[0]
# Replace Field Maps Basemap
print ("replacing field maps basemap")
gis.content.replace_service('503aacb9c3c146f0ba5d25847ebd6f87',package,"FieldMapsBaseREPLACE",True)
# Search for update layer
print ("searching for temporary layer")
package = gis.content.search(query="title: FieldMapsBaseREPLACE",item_type="Vector Tile Layer" )[0]
# Delete Update Layer
print("deleting temporary layer")
package.delete()
print ("Done")
Cheers
I'm trying to "Enable Offline Mode" for a map (I'm actually trying to disable Offline Mode). There's an Offline Map Area Manager in the Python API. https://developers.arcgis.com/python/api-reference/arcgis.mapping.html#offlinemapareamanager But it's not clear to me how to Enable or Disable Offline Mode (just like under Settings "Enable Offline Mode"). Not sure if you're asking a similar question or not.
@KarenRobine1 - Were you able to find a way to Enable/Disable the "Enable Offline Mode" parameter using the Python API?
My notes for this are a little fuzzy. I had done this in AGOL Assistant. But under typeKeywords, I added "Offline". I wonder if you can programmatically do this using the item Properties?
I posted a possible solution to this here - https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-change-web-map-quot-offline-mod...
Has anyone found a solution to the OP's issue which relates to Vector Tile Layers and not Web Maps? I'm encountering the same issue with trying to automate the refreshing of Vector Tile Services. My script uses the same methods as the OP to upload a new vtpk, publish a vector tile service from it and then replace the production service with the new service. When it does this, it looks like everything except 'offline' mode is maintained. The production service has 'offline' mode enabled, but after replacing it, the 'offline' mode is disabled.
I don't think the method for enabling offline mode on web maps via the typeKeywords will work for Vector Tile Services as 'Offline' isn't a listed keyword for this item type.
Check out this blog post Solved: Re: Enable Offline Mode - Tile Layer(hosted) - Esri Community.
I was having problems getting it working but I was trying to run it through a docker installation. I ran into this bug - BUG-000149882 Python API's VectorTileLayerManager.edit_tile_service export_tiles_allowed has No Effect when using Docker Image Installation. Depending on your setup the code I added in the attached post should work.
Unfortunately, not this didn't work for me. My Vector Tile Layer is in AGOL, and even though I'm logged in with the Admin account, I can't create the VectorTileLayerManager object. I suspect this is because the url for the service is not an admin url...but I don't know how to get an admin url...unless it's as simple as inserting 'admin' in the correct location in the path?
Here is a snippet I'm running in Jupyter:
vts = gis.content.get(item.id)
print(vts.type)
vtl = VectorTileLayer.fromitem(vts)
print(vtl)
for k in dir(vtl):
print(k)
vtl_manager = vtl.manager
Results:
Vector Tile Service <VectorTileLayer url:"https://tiles.arcgis.com/tiles/xxxxxxxxxxxx/arcgis/rest/services/Refresh_Test_VTP/VectorTileServer"> __class__ __delattr__ __dict__ __dir__ __doc__ __eq__ __format__ __ge__ __getattribute__ __gt__ __hash__ __init__ __init_subclass__ __le__ __lt__ __module__ __ne__ __new__ __reduce__ __reduce_ex__ __repr__ __setattr__ __sizeof__ __str__ __subclasshook__ __weakref__ _con _gis _hydrate _hydrated _invoke _lyr_dict _lyr_domains _lyr_json _refresh _time_filter _token _url filter fromitem info properties styles tile_fonts tile_sprite url vector_tile
--------------------------------------------------------------------------- AttributeError Traceback (most recent call last) <ipython-input-27-402e9dbb5c0b> in <module> 25 print(k) 26 ---> 27 vtl_manager = vtl.manager AttributeError: 'VectorTileLayer' object has no attribute 'manager'
I think I was running into a similar error as well and it had to do with the version of Python I was using.