clone_items() with item_mapping misses basemap layers

Open
#2,491 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
65/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
python
Domain
api

Research direction

Start at the Python API's content.clone_items entry point and trace how item_mapping is applied to Web Map JSON, comparing operationalLayers with baseMap.baseMapLayers. Reproduce the example with source and target item IDs, then verify that every matching baseMap itemId is replaced in the cloned Web Map data.

Written by the indexing model from the issue text.

Description

bug

Describe the bug
When using clone_items with item_mapping on a Web Map with a custom basemap, it fails to update mapped items in the baseMap definition of the clone.

To Reproduce
Create a Web Map that contains a Tile Layer (hosted)/Map Service, and uses the same Tile Layer (hosted)/Map Service as its basemap. Ensure the Tile Layer (hosted)/Map Service is available on both the source and target GIS. Define the mapping of the item IDs from the source and target GIS in item_mapping when calling clone_Items.

For example:

cloned_items = target_gis.content.clone_items(
    items=[source_gis.content.get('web_map_item_id)],
    search_existing_items=False,
    item_mapping = {
        'tile_layer_item_id_on_source_gis': 'tile_layer_item_id_on_target_gis'
    }
)

clone_items does properly apply the item_mapping to the operationalLayers in the Web Map, but does not for the baseMap.

For example, the original Web Map's JSON Data definition contains:

    "operationalLayers": [
        {
            "id": "19d6daf5cc8-layer-216",
            "title": "ESGR 1998 GIS as layer",
            "url": "https://tiles.arcgis.com/tiles/4ezfu5dIwH83BUNL/arcgis/rest/services/ESGR_1998_GIS/MapServer",
            "itemId": "71c5068e7f2c47559ee645f10c712fed",
            "layerType": "ArcGISTiledMapServiceLayer"
        }
    ],
    "baseMap": {
        "baseMapLayers": [
            {
                "id": "19d6d80b60a-layer-56",
                "title": "ESGR 1998 GIS",
                "url": "https://tiles.arcgis.com/tiles/4ezfu5dIwH83BUNL/arcgis/rest/services/ESGR_1998_GIS/MapServer",
                "itemId": "71c5068e7f2c47559ee645f10c712fed",
                "layerType": "ArcGISTiledMapServiceLayer"
            }
        ],
        "title": "ESGR Basemap"
    },

While the cloned Web Map's JSON Data definition shows the item_mapping was successfully applied for occurrences under opeartionalLayers, it was not successful applied under baseMap:

    "operationalLayers": [
        {
            "id": "19d6daf5cc8-layer-216",
            "title": "ESGR 1998 GIS as layer",
            "url": "https://tiles.arcgis.com/tiles/ne8azYNvwFhMEpfh/arcgis/rest/services/ESGR_1998_DELETE/MapServer",
            "itemId": "e5deef62dd514c61b62b8b78790016db",
            "layerType": "ArcGISTiledMapServiceLayer"
        }
    ],
    "baseMap": {
        "baseMapLayers": [
            {
                "id": "19d6d80b60a-layer-56",
                "title": "ESGR 1998 GIS",
                "url": "https://tiles.arcgis.com/tiles/4ezfu5dIwH83BUNL/arcgis/rest/services/ESGR_1998_GIS/MapServer",
                "itemId": "71c5068e7f2c47559ee645f10c712fed",
                "layerType": "ArcGISTiledMapServiceLayer"
            }
        ],
        "title": "ESGR Basemap"
    },

Note that in this example, the Tile Layer (hosted)/Map Service was published on the target GIS with a different title, "ESGR 1998 DELETE", while the on the source GIS it is titled, "ESGR 1998".

Expected behavior
When using item_mapping, the expectation is that it will address all references to an item. So for a Web Map, it should also update items under baseMap, and not just operationalLayers.

Platform (please complete the following information):

  • OS: Windows
  • Browser: Chrome
  • Python API Version: 2.4.3
Dominant language
Python
Stars
2.2k
Forks
1.1k
Avg merge
2h 40m
Merged PRs (30d)
2

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Esri/arcgis-python-api

All issues in Esri/arcgis-python-api

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.