<?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: What do the elements of  &amp;quot;.listMaps&amp;quot; mean ? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/what-do-the-elements-of-quot-listmaps-quot-mean/m-p/1368818#M69621</link>
    <description>&lt;P&gt;list all maps that contain the name&lt;/P&gt;&lt;P&gt;"Yosemite National Park")&lt;/P&gt;&lt;P&gt;and since you may have more than one and a list of maps is returned, just return the first&lt;/P&gt;&lt;P&gt;[0]&lt;/P&gt;&lt;P&gt;(python is 0-based, so 0 is the index of the first element in a list)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 11 Jan 2024 11:11:11 GMT</pubDate>
    <dc:creator>DanPatterson</dc:creator>
    <dc:date>2024-01-11T11:11:11Z</dc:date>
    <item>
      <title>What do the elements of  ".listMaps" mean ?</title>
      <link>https://community.esri.com/t5/python-questions/what-do-the-elements-of-quot-listmaps-quot-mean/m-p/1368780#M69617</link>
      <description>&lt;P&gt;I'm new to Python. Could someone help me ?&lt;BR /&gt;&lt;BR /&gt;The following text was taken from the ArcGIS Pro help page.&lt;BR /&gt;What do the contents of the () and [] in the second line of the code mean ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class=""&gt;&lt;P&gt;&lt;FONT color="#008080"&gt;This sample demonstrates how to reference a layer's label classes using&amp;nbsp;&lt;SPAN class=""&gt;ArcGIS Pro&lt;/SPAN&gt;.&lt;/FONT&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;PRE&gt;&lt;FONT color="#008080"&gt;p = arcpy.mp.ArcGISProject(&lt;SPAN class=""&gt;"CURRENT"&lt;/SPAN&gt;)
m = p.listMaps(&lt;SPAN class=""&gt;"Yosemite National Park"&lt;/SPAN&gt;)[&lt;SPAN class=""&gt;0&lt;/SPAN&gt;]
&lt;SPAN class=""&gt;for&lt;/SPAN&gt; lyr &lt;SPAN class=""&gt;in&lt;/SPAN&gt; m.listLayers():
    &lt;SPAN class=""&gt;if&lt;/SPAN&gt; lyr.supports(&lt;SPAN class=""&gt;"SHOWLABELS"&lt;/SPAN&gt;):
       lblClasses = lyr.listLabelClasses()&lt;/FONT&gt;&lt;/PRE&gt;&lt;P&gt;&lt;FONT color="#008080"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 11 Jan 2024 08:15:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/what-do-the-elements-of-quot-listmaps-quot-mean/m-p/1368780#M69617</guid>
      <dc:creator>Rema</dc:creator>
      <dc:date>2024-01-11T08:15:59Z</dc:date>
    </item>
    <item>
      <title>Re: What do the elements of  ".listMaps" mean ?</title>
      <link>https://community.esri.com/t5/python-questions/what-do-the-elements-of-quot-listmaps-quot-mean/m-p/1368818#M69621</link>
      <description>&lt;P&gt;list all maps that contain the name&lt;/P&gt;&lt;P&gt;"Yosemite National Park")&lt;/P&gt;&lt;P&gt;and since you may have more than one and a list of maps is returned, just return the first&lt;/P&gt;&lt;P&gt;[0]&lt;/P&gt;&lt;P&gt;(python is 0-based, so 0 is the index of the first element in a list)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jan 2024 11:11:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/what-do-the-elements-of-quot-listmaps-quot-mean/m-p/1368818#M69621</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2024-01-11T11:11:11Z</dc:date>
    </item>
    <item>
      <title>Re: What do the elements of  ".listMaps" mean ?</title>
      <link>https://community.esri.com/t5/python-questions/what-do-the-elements-of-quot-listmaps-quot-mean/m-p/1368819#M69622</link>
      <description>&lt;P&gt;Hello Rema&lt;/P&gt;&lt;P&gt;The code basically returns a Map in your "Current" ArcGIS Pro (the ArcGIS Pro Project which you are working with) project called "Yosemite National Park".&lt;/P&gt;&lt;P&gt;The second line of code does the following:&lt;/P&gt;&lt;P&gt;- p is a variable which holds a reference to the ArcGIS Pro Project.&lt;/P&gt;&lt;P&gt;- listMaps() is a method on the current project object stored in p.&lt;/P&gt;&lt;P&gt;- listMaps() has a single argument which is a wildcard. This allows you to find all maps based upon a name. Normally the wildcard is followed by an *. In this case there is no asterisk which means you want to find those maps which are explicitly called "Yosemite National Park".&amp;nbsp;&lt;/P&gt;&lt;P&gt;- listMaps() returns a Python List object of ArcGIS Pro Map objects (the help for the method tells you this).&lt;/P&gt;&lt;P&gt;- Lists are made up of items and are zero-indexed, so the first item in the list is at index position 0. You access items in the list using the [] notation; as a 0 is in the [] brackets you are accessing the 1st Map in the list.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So the line of code says..... "get me ALL the maps in the current project called "Yosemite National Park" and store in a list , and then get me the 1st Map in the list and store it in a variable called 'm'.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope that makes sense!?&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jan 2024 11:15:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/what-do-the-elements-of-quot-listmaps-quot-mean/m-p/1368819#M69622</guid>
      <dc:creator>EdM</dc:creator>
      <dc:date>2024-01-11T11:15:11Z</dc:date>
    </item>
    <item>
      <title>Re: What do the elements of  ".listMaps" mean ?</title>
      <link>https://community.esri.com/t5/python-questions/what-do-the-elements-of-quot-listmaps-quot-mean/m-p/1370071#M69648</link>
      <description>&lt;P&gt;Thanks for your reply, EdM.&lt;BR /&gt;I got what the arguments means now. But, if the map which I found by ".listMaps()" had several layers, how can I know each layer's index?&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jan 2024 04:41:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/what-do-the-elements-of-quot-listmaps-quot-mean/m-p/1370071#M69648</guid>
      <dc:creator>Rema</dc:creator>
      <dc:date>2024-01-15T04:41:54Z</dc:date>
    </item>
    <item>
      <title>Re: What do the elements of  ".listMaps" mean ?</title>
      <link>https://community.esri.com/t5/python-questions/what-do-the-elements-of-quot-listmaps-quot-mean/m-p/1370202#M69653</link>
      <description>&lt;P&gt;There are several ways you could determine the index, but the first question is: "What purpose will that index solve?"&lt;/P&gt;&lt;P&gt;If you just want the index of every layer, as you pass it in the loop:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;p = arcpy.mp.ArcGISProject("CURRENT")
m = p.listMaps("Yosemite National Park")[0]
layer_index = 0
for lyr in m.listLayers():
    print(layer_index)
    if lyr.supports("SHOWLABELS"):
       lblClasses = lyr.listLabelClasses()
    layer_index += 1&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Line 3 is the counter we're going to use to track what index we're on as we loop.&amp;nbsp; Line 5 could easily be replaced with whatever code you needed the index for.&lt;/P&gt;&lt;P&gt;Once we're done with that layer in the loop, though, we need to make sure to keep our counter updated, which is what Line 8 does.&amp;nbsp; I updated it at the end of the loop because we're talking about an index, and in Python indexes are almost always 0-based, like the list that Dan was talking about up above.&amp;nbsp; You can update counters anywhere you like, but if you update them too early, you'll start getting 1-based indexes, and some things might break, unless they're expecting that.&lt;/P&gt;&lt;P&gt;------&lt;/P&gt;&lt;P&gt;But for most things, you probably don't actually&amp;nbsp;&lt;U&gt;&lt;EM&gt;need&lt;/EM&gt;&lt;/U&gt; the index.&amp;nbsp; Take a look at the original code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;p = arcpy.mp.ArcGISProject("CURRENT")
m = p.listMaps("Yosemite National Park")[0]
for lyr in m.listLayers():
    if lyr.supports("SHOWLABELS"):
       lblClasses = lyr.listLabelClasses()&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;Lines 4 and 5 do a thing on the layer as it passes it in the loop, without needing to know what index it is.&amp;nbsp; When you do a &lt;STRONG&gt;for&lt;/STRONG&gt; loop on that list of layers, each round of the loop&amp;nbsp;&lt;EM&gt;is&lt;/EM&gt; the layer, so you can probably do whatever you need to do with that variable, "lyr".&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jan 2024 16:01:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/what-do-the-elements-of-quot-listmaps-quot-mean/m-p/1370202#M69653</guid>
      <dc:creator>MErikReedAugusta</dc:creator>
      <dc:date>2024-01-15T16:01:13Z</dc:date>
    </item>
    <item>
      <title>Re: What do the elements of  ".listMaps" mean ?</title>
      <link>https://community.esri.com/t5/python-questions/what-do-the-elements-of-quot-listmaps-quot-mean/m-p/1370431#M69661</link>
      <description>&lt;P&gt;Hi Rema&lt;/P&gt;&lt;P&gt;Have a look at&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/569244"&gt;@MErikReedAugusta&lt;/a&gt;&amp;nbsp;reply. It is a good answer to your question.&lt;/P&gt;&lt;P&gt;Have fun! - ed&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jan 2024 12:45:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/what-do-the-elements-of-quot-listmaps-quot-mean/m-p/1370431#M69661</guid>
      <dc:creator>EdM</dc:creator>
      <dc:date>2024-01-16T12:45:23Z</dc:date>
    </item>
  </channel>
</rss>

