Select to view content in your preferred language

Enabling offline mode with arcgis api

2473
10
03-22-2021 08:23 PM
RoryBennison
Occasional Contributor

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

0 Kudos
10 Replies
Dan_Joyce_OE
Occasional Contributor

It's got me beat...will revert to an alternative approach.

Python 3.7.11 [MSC v.1927 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import arcgis
>>> arcgis.__version__
'1.9.1'
>>> for i in dir(arcgis.mapping):
...   print(i)
...
BuildingLayer
FormCollection
FormElement
FormExpressionInfo
FormFieldElement
FormGroupElement
FormInfo
IntegratedMeshLayer
MapFeatureLayer
MapImageLayer
MapImageLayerManager
MapRasterLayer
MapServiceLayer
MapTable
Object3DLayer
OfflineMapAreaManager
PackagingJob
Point3DLayer
PointCloudLayer
SceneLayer
VectorTileLayer
WebMap
WebScene
__all__
__builtins__
__cached__
__doc__
__file__
__loader__
__name__
__package__
__path__
__spec__
_basemap_definitions
_msl
_scenelyrs
_types
_utils
create_symbol
display_colormaps
export_map
forms
generate_renderer
get_layout_templates
renderer
show_styles
symbol

 

0 Kudos