Skip to content

MapContent class move() method does not move a layer into a GroupLayer and errors #2513

@Clubdebambos

Description

@Clubdebambos

Describe the bug
The Map class content property is a MapContent object that has a move() method as per documentation here to move a layer into an existing GroupLayer’s list of layers. However, this has never worked since its introduction in version 2.4.0.

To Reproduce
Steps to reproduce the behavior:

Have a WebMap where the top layer is a group layer and the bottom is a normal layer. Or alter the indexes below to suit.

from arcgis.gis import GIS
from arcgis.map import Map

## Access AGOL
agol = GIS("home")

## Access the WebMap Item
wm_item = agol.content.get("WM_ITEM_ID")

## Create a Map object from WebMap Item
webmap = Map(wm_item)

## Get the GroupLayer object
gl = webmap.content.layers[1]

## move to group
webmap.content.move(
    index=0,
    group=gl
)

## update the webmap
webmap.update()

error:

Traceback (most recent call last):
  File "<module1>", line 17, in <module>
  File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\site-packages\arcgis\map\map_widget.py", line 2794, in move
    group._layer.layers.append(pydantic_layer)
    ^^^^^^^^^^^^
AttributeError: 'GroupLayer' object has no attribute '_layer'. Did you mean: 'layers'?

Screenshots
N/A

Expected behavior
The script runs without error and the layer is moved into the group layer. Although it is not clear if the layer will be added to the top or bottom of the layers in the group layer.

Platform (please complete the following information):

  • OS: Windows 11
  • Browser: Chrome/Edge
  • Python API Version: 2.4.0, 2.4.2, 2.4.3

Additional context
Add any other context about the problem here, attachments etc.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions