<?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 Re: How to modify Text in Sketch Layer in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-modify-text-in-sketch-layer/m-p/1611199#M11349</link>
    <description>&lt;P&gt;Thank you for the detailed answer. This is amazing.&lt;BR /&gt;I am almost there.&lt;/P&gt;&lt;P&gt;- I fould f["symbol"]["text"] and modified.&lt;BR /&gt;- item.update() returned True.&lt;BR /&gt;- But the change does not happen online.&lt;/P&gt;&lt;P&gt;Is there any "commit" or "writeback" necessary?&lt;/P&gt;&lt;LI-CODE lang="python"&gt;    itemWebMap = gis.content.get(IdWebMapContacts)
    dataWebMap = itemWebMap.get_data()

    for layerOp in dataWebMap['operationalLayers']:
        if layerOp['title'] != NameSketch: continue

        for layerFeature in layerOp['featureCollection']['layers']:
            if layerFeature['layerDefinition']['name'] != 'Text': continue

            if len(layerFeature['featureSet']['features']) != 1:
                ErrorExit('There must be one feature')

            for feature in layerFeature['featureSet']['features']:
                feature['symbol']['text'] += '&amp;lt;&amp;lt;UPDATED TEXT&amp;gt;&amp;gt;'

    dataNew = {'text' : dataWebMap}
    result = itemWebMap.update(item_properties=dataNew)
    if not result:
        ErrorExit('Update failed')&lt;/LI-CODE&gt;</description>
    <pubDate>Fri, 02 May 2025 17:54:21 GMT</pubDate>
    <dc:creator>KazFukuoka</dc:creator>
    <dc:date>2025-05-02T17:54:21Z</dc:date>
    <item>
      <title>How to modify Text in Sketch Layer</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-modify-text-in-sketch-layer/m-p/1610240#M11342</link>
      <description>&lt;P&gt;There is a Web Map that has a Sketch Layer with a Text in it.&lt;BR /&gt;How can I modify the Text by using ArcGIS API for Python?&lt;/P&gt;</description>
      <pubDate>Wed, 30 Apr 2025 03:43:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-modify-text-in-sketch-layer/m-p/1610240#M11342</guid>
      <dc:creator>KazFukuoka</dc:creator>
      <dc:date>2025-04-30T03:43:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to modify Text in Sketch Layer</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-modify-text-in-sketch-layer/m-p/1610682#M11344</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/903874"&gt;@KazFukuoka&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;Here's how you can do it...&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from arcgis.gis import GIS

## access ArcGIS Online
agol = GIS("home")

## the name of the Sketch layer in the layer list
sketch_lyr_name = "Sketch"

## get the WebMap as an item object
item = agol.content.get("WM_ITEM_ID")

## get the WebMap JSON definition as a dictionary
item_data = item.get_data()

## for each layer in the operationalLayers
for lyr in item_data["operationalLayers"]:
    ## when we hit the Sketch layer of interest
    if lyr["title"] == sketch_lyr_name:
        ## iterate over the layers in the Sketch layer eg. Polygons, Polylines, Points, Text
        for sketch_lyr in lyr["featureCollection"]["layers"]:
            ## we are interested in the Text layer of the Sketch
            if sketch_lyr["layerDefinition"]["name"] == "Text":
                ## for each feature in the Text layer of the skatch
                ## at this point if there is only one text you could use
                ## indexing instead sketch_lyr["featureSet"]["features"][0]
                for f in sketch_lyr["featureSet"]["features"]:
                    #print(f["symbol"]["text"])
                    ## if the current text begins with what we are looking for
                    if f["symbol"]["text"].startswith("UNIQUE START OF TEXT"): # UPDATE CODE HERE
                        ## update the text
                        f["symbol"]["text"] = "UPDATED TEXT" # UPDATE CODE HERE

## update the WebMap Item definition
updated_properties = {"text" : item_data}
item.update(item_properties=updated_properties)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Update the text in lines 29 and 31.&lt;/P&gt;&lt;P&gt;Please let us know if this works for you.&lt;/P&gt;&lt;P&gt;All the best,&lt;/P&gt;&lt;P&gt;Glen&lt;/P&gt;</description>
      <pubDate>Thu, 01 May 2025 09:27:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-modify-text-in-sketch-layer/m-p/1610682#M11344</guid>
      <dc:creator>Clubdebambos</dc:creator>
      <dc:date>2025-05-01T09:27:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to modify Text in Sketch Layer</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-modify-text-in-sketch-layer/m-p/1611199#M11349</link>
      <description>&lt;P&gt;Thank you for the detailed answer. This is amazing.&lt;BR /&gt;I am almost there.&lt;/P&gt;&lt;P&gt;- I fould f["symbol"]["text"] and modified.&lt;BR /&gt;- item.update() returned True.&lt;BR /&gt;- But the change does not happen online.&lt;/P&gt;&lt;P&gt;Is there any "commit" or "writeback" necessary?&lt;/P&gt;&lt;LI-CODE lang="python"&gt;    itemWebMap = gis.content.get(IdWebMapContacts)
    dataWebMap = itemWebMap.get_data()

    for layerOp in dataWebMap['operationalLayers']:
        if layerOp['title'] != NameSketch: continue

        for layerFeature in layerOp['featureCollection']['layers']:
            if layerFeature['layerDefinition']['name'] != 'Text': continue

            if len(layerFeature['featureSet']['features']) != 1:
                ErrorExit('There must be one feature')

            for feature in layerFeature['featureSet']['features']:
                feature['symbol']['text'] += '&amp;lt;&amp;lt;UPDATED TEXT&amp;gt;&amp;gt;'

    dataNew = {'text' : dataWebMap}
    result = itemWebMap.update(item_properties=dataNew)
    if not result:
        ErrorExit('Update failed')&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 02 May 2025 17:54:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-modify-text-in-sketch-layer/m-p/1611199#M11349</guid>
      <dc:creator>KazFukuoka</dc:creator>
      <dc:date>2025-05-02T17:54:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to modify Text in Sketch Layer</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-modify-text-in-sketch-layer/m-p/1611339#M11351</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/903874"&gt;@KazFukuoka&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;Do not use &amp;lt;&amp;gt; in your testing text on line 14, it probably thinks this is a tag (html). It does not work with &amp;lt;&amp;gt; but I removed and worked just fine.&lt;/P&gt;</description>
      <pubDate>Sat, 03 May 2025 10:04:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-modify-text-in-sketch-layer/m-p/1611339#M11351</guid>
      <dc:creator>Clubdebambos</dc:creator>
      <dc:date>2025-05-03T10:04:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to modify Text in Sketch Layer</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-modify-text-in-sketch-layer/m-p/1611361#M11352</link>
      <description>&lt;P&gt;Wow, I never thought about it. Everything is working now.&lt;BR /&gt;Thanks a lot for the detailed info&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":grinning_face:"&gt;😀&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 03 May 2025 16:33:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-modify-text-in-sketch-layer/m-p/1611361#M11352</guid>
      <dc:creator>KazFukuoka</dc:creator>
      <dc:date>2025-05-03T16:33:15Z</dc:date>
    </item>
  </channel>
</rss>

