I have recently upgraded ArcGIS API for python from 2.3.0 to 2.4.0 and found out that Map.content.update_layer() doesn't work with the old labeling_info json. There's no error while running the code, but it just doesn't do anything at all to web map. Here is the code for 2.3.0:
target_map_item = gis.content.get(target_map_id)
webmap = WebMap(target_map_item)
labeling_info = [
{
"labelExpression": "[owner]",
"labelExpressionInfo": {
"expression": "$feature[\"owner\"]"
},
"labelPlacement": "esriServerPolygonPlacementAlwaysHorizontal",
"maxScale": 0,
"minScale": 10000,
"repeatLabel": true,
"symbol": {
"type": "esriTS",
"color": [
255,
255,
255,
255
],
"font": {
"family": "Arial",
"size": 11
},
"horizontalAlignment": "center",
"kerning": true,
"haloColor": [
0,
0,
0,
255
],
"haloSize": 1,
"rotated": false,
"text": "",
"verticalAlignment": "baseline",
"xoffset": 0,
"yoffset": 0,
"angle": 0
},
"where": "area>= 10"
}
]
lyr = webmap.layers[0]
lyr['layerDefinition']['drawingInfo']['labelingInfo'] = labeling_info
webmap.update()And here is the new code for 2.4.0:
wmap_item = gis.content.get(wmap_item_id)
wmap = Map(wmap_item)
wmap.content.update_layer(index = 0,labeling_info=labeling_info)
wmap.update()
Does anyone have the same problem? Can anyone help me with this?
Very appreciate!