AnsweredAssumed Answered

Can't create a valid Web Map from a JSON definition using the Python API

Question asked by jbailey.spatialbridge on Nov 6, 2018

I want to create a new Web Map item using the Python API. I manually created a Web Map with the correct configuration, and then used

Item.get_data()

to get a JSON representation of the Web Map, which is as follows:

{
    "operationalLayers": [],
    "baseMap": {
        "baseMapLayers": [{
            "id": "CBMT_CBCT_GEOM_3857_8319",
            "layerType": "ArcGISTiledMapServiceLayer",
            "url": "http://geoappext.nrcan.gc.ca/arcgis/rest/services/BaseMaps/CBMT_CBCT_GEOM_3857/MapServer",
            "visibility": true,
            "opacity": 1,
            "title": "CBMT_CBCT_GEOM_3857"
        }, {
            "id": "CBMT_TXT_3857_1321",
            "layerType": "ArcGISTiledMapServiceLayer",
            "url": "http://geoappext.nrcan.gc.ca/arcgis/rest/services/BaseMaps/CBMT_TXT_3857/MapServer",
            "visibility": true,
            "opacity": 1,
            "title": "CBMT_TXT_3857",
            "showLegend": true
        }],
        "title": "The Canada Base Map - Transportation (CBMT)"
    },
    "spatialReference": {
        "wkid": 102100,
        "latestWkid": 3857
    },
    "authoringApp": "WebMapViewer",
    "authoringAppVersion": "10.6.1",
    "version": "2.11"
}

 

I then saved this to a JSON file, CBMT.json.

 

Next, I tried to create a new Web Map using this JSON as a template:

 

item_properties = {
    "type": "Web Map",
    "tags": "basemap",
    "access": "org"
}

cbmt = tc_gis.content.add(item_properties, "CBMT.json", folder = "Basemaps")

The portal item is created, however, the web map appears to not be valid. In Portal, clicking on the Settings tab on the Portal item hangs, as does trying to open the web map in the map viewer.

Outcomes