Enabling offline mode with arcgis api

03-22-2021 08:23 PM
New Contributor II


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",
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")

# 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")


print ("Done")


0 Kudos
4 Replies
New Contributor III

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.

0 Kudos
Occasional Contributor

@KarenRobine1 - Were you able to find a way to Enable/Disable the "Enable Offline Mode" parameter using the Python API?

0 Kudos
New Contributor II
I haven’t investigated it for a while. I think there might be a way by sharing the webmap ...
0 Kudos
New Contributor III

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?

0 Kudos