<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Unable to manipulate and update json of web map in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/unable-to-manipulate-and-update-json-of-web-map/m-p/1088352#M6477</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I am trying to remove a set of layers from a web map and add them back later. Since the layers consist of a mix of feature services and image services, I feel the easiest way to do this would be by manipulation the json of the web map. When I use AGOL assisstant, I am able to achieve the above, however when I try to do the same using ArcGIS Python API, it does not work.&lt;/P&gt;&lt;P&gt;I am using the code below to achieve the above, though post executing the update command I get 'True', the layers are not removed from the web map. I have also attached screenshot for reference&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;web_map = source.content.get(itemid)
data = web_map.get_data()
rem_j = []
for i in data['operationalLayers']:
    if i['url'].find('mygishub') == -1:
        rem_j.append(i)
        data['operationalLayers'].remove(i)
web_map.update(item_properties=data)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MariamJamilah_0-1628766891461.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/20706i00F10A8662BC3EC0/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MariamJamilah_0-1628766891461.png" alt="MariamJamilah_0-1628766891461.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have also tried to achieve the same by using the WebMap object, but it still does not work. Have attached screenshot and code for reference.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;web_map = source.content.get(itemid)
web_map_obj = WebMap(web_map)
rem_j = []
for i in web_map_obj.layers:
    if i['url'].find('mygishub') == -1:
        rem_j.append(i)
        web_map_obj.layers.remove(i)
web_map_obj.update()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MariamJamilah_1-1628767162559.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/20707i371EA21DEB2C4BE9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MariamJamilah_1-1628767162559.png" alt="MariamJamilah_1-1628767162559.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note: I have not used the add_layer and remove_layer methods here. I am aware that the remove layer method accepts a layer object (i.e., webmap.layers[id]), this approach works for removing layers but when it comes to adding a mixture of feature services and image services as layers using their urls, I have to find the type of service and then create a FeatureLayer or ImageryLayer object accordingly for each url and finally add them to the webmap, which I feel is not very efficient as I have a large number of layers.&lt;/P&gt;</description>
    <pubDate>Thu, 12 Aug 2021 11:31:08 GMT</pubDate>
    <dc:creator>MariamJamilah</dc:creator>
    <dc:date>2021-08-12T11:31:08Z</dc:date>
    <item>
      <title>Unable to manipulate and update json of web map</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/unable-to-manipulate-and-update-json-of-web-map/m-p/1088352#M6477</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I am trying to remove a set of layers from a web map and add them back later. Since the layers consist of a mix of feature services and image services, I feel the easiest way to do this would be by manipulation the json of the web map. When I use AGOL assisstant, I am able to achieve the above, however when I try to do the same using ArcGIS Python API, it does not work.&lt;/P&gt;&lt;P&gt;I am using the code below to achieve the above, though post executing the update command I get 'True', the layers are not removed from the web map. I have also attached screenshot for reference&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;web_map = source.content.get(itemid)
data = web_map.get_data()
rem_j = []
for i in data['operationalLayers']:
    if i['url'].find('mygishub') == -1:
        rem_j.append(i)
        data['operationalLayers'].remove(i)
web_map.update(item_properties=data)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MariamJamilah_0-1628766891461.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/20706i00F10A8662BC3EC0/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MariamJamilah_0-1628766891461.png" alt="MariamJamilah_0-1628766891461.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have also tried to achieve the same by using the WebMap object, but it still does not work. Have attached screenshot and code for reference.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;web_map = source.content.get(itemid)
web_map_obj = WebMap(web_map)
rem_j = []
for i in web_map_obj.layers:
    if i['url'].find('mygishub') == -1:
        rem_j.append(i)
        web_map_obj.layers.remove(i)
web_map_obj.update()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MariamJamilah_1-1628767162559.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/20707i371EA21DEB2C4BE9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MariamJamilah_1-1628767162559.png" alt="MariamJamilah_1-1628767162559.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note: I have not used the add_layer and remove_layer methods here. I am aware that the remove layer method accepts a layer object (i.e., webmap.layers[id]), this approach works for removing layers but when it comes to adding a mixture of feature services and image services as layers using their urls, I have to find the type of service and then create a FeatureLayer or ImageryLayer object accordingly for each url and finally add them to the webmap, which I feel is not very efficient as I have a large number of layers.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Aug 2021 11:31:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/unable-to-manipulate-and-update-json-of-web-map/m-p/1088352#M6477</guid>
      <dc:creator>MariamJamilah</dc:creator>
      <dc:date>2021-08-12T11:31:08Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to manipulate and update json of web map</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/unable-to-manipulate-and-update-json-of-web-map/m-p/1088377#M6478</link>
      <description>&lt;P&gt;Maybe the right methode it is remove_layer().&lt;/P&gt;&lt;P&gt;Otherwise, when I want update webmap properties with python, I work on json.&lt;/P&gt;&lt;P&gt;Eg. I use this code :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;itemWebmap.update(item_properties={'text':new_data})&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;where new_data is my webmap properties json with new properties.&lt;/P&gt;&lt;P&gt;If it's OK, this request return TRUE.&lt;/P&gt;&lt;P&gt;You can find more informations here : &lt;A href="http:// https://developers.arcgis.com/python/sample-notebooks/using-and-updating-gis-content/" target="_self"&gt;https://developers.arcgis.com/python/sample-notebooks/using-and-updating-gis-content/&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Aug 2021 13:11:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/unable-to-manipulate-and-update-json-of-web-map/m-p/1088377#M6478</guid>
      <dc:creator>GaetanPRU</dc:creator>
      <dc:date>2021-08-12T13:11:46Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to manipulate and update json of web map</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/unable-to-manipulate-and-update-json-of-web-map/m-p/1242233#M8179</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;P&gt;You can use &lt;STRONG&gt;get_data&lt;/STRONG&gt; to return the current json on an item, then edit the json and use &lt;STRONG&gt;update&lt;/STRONG&gt; as shown above. Worked for me!&lt;/P&gt;&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Sun, 18 Dec 2022 10:15:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/unable-to-manipulate-and-update-json-of-web-map/m-p/1242233#M8179</guid>
      <dc:creator>sofoo</dc:creator>
      <dc:date>2022-12-18T10:15:41Z</dc:date>
    </item>
  </channel>
</rss>

