<?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: listMaps() returns empty list when the project has a map in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/listmaps-returns-empty-list-when-the-project-has-a/m-p/1302036#M68015</link>
    <description>&lt;P&gt;No, the map is called Map (but I tried that as well and didn't even get an empty list).&amp;nbsp; I also left it blank.&amp;nbsp; There seems to be no documentation for what to put in the parenthesis, I'm just going by examples.&lt;/P&gt;</description>
    <pubDate>Thu, 22 Jun 2023 15:02:38 GMT</pubDate>
    <dc:creator>AngelaSchirck</dc:creator>
    <dc:date>2023-06-22T15:02:38Z</dc:date>
    <item>
      <title>listMaps() returns empty list when the project has a map</title>
      <link>https://community.esri.com/t5/python-questions/listmaps-returns-empty-list-when-the-project-has-a/m-p/1302024#M68012</link>
      <description>&lt;P&gt;Hey all,&lt;/P&gt;&lt;P&gt;I'm trying to create a script and am stuck at a very SIMPLE step.&amp;nbsp; In the code below the listMaps() function is returning an empty list so I'm getting an index out of range error.&amp;nbsp; This project DOES have one map in it, any ideas why it's not "seeing" it? (All necessary packages are imported in the project).&lt;/P&gt;&lt;P&gt;When I print aprx I get:&amp;nbsp;&amp;lt;arcpy._mp.ArcGISProject object at 0x0000021769973640&amp;gt;&lt;/P&gt;&lt;P&gt;When I delete the index [0] from m and print m it shows [ ] (empty list)&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;```&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;def &lt;/SPAN&gt;&lt;SPAN&gt;sdDraft&lt;/SPAN&gt;(&lt;SPAN&gt;outdir&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;sde_path&lt;/SPAN&gt;):  &lt;SPAN&gt;## Output directory (project_path in main).&lt;BR /&gt;&lt;/SPAN&gt;    project_name = os.path.join(&lt;SPAN&gt;outdir&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;'Enterprise.aprx'&lt;/SPAN&gt;)  &lt;SPAN&gt;## Change as needed&lt;BR /&gt;&lt;/SPAN&gt;    service_name = &lt;SPAN&gt;'CensusTest'  &lt;/SPAN&gt;&lt;SPAN&gt;## Change as needed&lt;BR /&gt;&lt;/SPAN&gt;    sddraft_filename = service_name + &lt;SPAN&gt;'.sddraft'&lt;BR /&gt;&lt;/SPAN&gt;    sddraft_output_filename = os.path.join(&lt;SPAN&gt;outdir&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;sddraft_filename)&lt;BR /&gt;    sd_filename = service_name + &lt;SPAN&gt;'.sd'&lt;BR /&gt;&lt;/SPAN&gt;    sd_output_filename = os.path.join(&lt;SPAN&gt;outdir&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;sd_filename)&lt;BR /&gt;&lt;BR /&gt;    &lt;SPAN&gt;# Layer(s) to publish&lt;BR /&gt;&lt;/SPAN&gt;    aprx = arcpy.mp.ArcGISProject(project_name)&lt;BR /&gt;    m = aprx.listMaps(&lt;SPAN&gt;'Enterprise'&lt;/SPAN&gt;)[&lt;SPAN&gt;0&lt;/SPAN&gt;]  &lt;SPAN&gt;## Change as needed&lt;BR /&gt;&lt;/SPAN&gt;    &lt;SPAN&gt;print&lt;/SPAN&gt;(m)&lt;BR /&gt;```&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Jun 2023 14:44:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/listmaps-returns-empty-list-when-the-project-has-a/m-p/1302024#M68012</guid>
      <dc:creator>AngelaSchirck</dc:creator>
      <dc:date>2023-06-22T14:44:42Z</dc:date>
    </item>
    <item>
      <title>Re: listMaps() returns empty list when the project has a map</title>
      <link>https://community.esri.com/t5/python-questions/listmaps-returns-empty-list-when-the-project-has-a/m-p/1302028#M68014</link>
      <description>&lt;P&gt;You're explicitly checking for a map named "Enterprise". Is that the name of your map?&lt;/P&gt;</description>
      <pubDate>Thu, 22 Jun 2023 14:49:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/listmaps-returns-empty-list-when-the-project-has-a/m-p/1302028#M68014</guid>
      <dc:creator>AlfredBaldenweck</dc:creator>
      <dc:date>2023-06-22T14:49:04Z</dc:date>
    </item>
    <item>
      <title>Re: listMaps() returns empty list when the project has a map</title>
      <link>https://community.esri.com/t5/python-questions/listmaps-returns-empty-list-when-the-project-has-a/m-p/1302036#M68015</link>
      <description>&lt;P&gt;No, the map is called Map (but I tried that as well and didn't even get an empty list).&amp;nbsp; I also left it blank.&amp;nbsp; There seems to be no documentation for what to put in the parenthesis, I'm just going by examples.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Jun 2023 15:02:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/listmaps-returns-empty-list-when-the-project-has-a/m-p/1302036#M68015</guid>
      <dc:creator>AngelaSchirck</dc:creator>
      <dc:date>2023-06-22T15:02:38Z</dc:date>
    </item>
    <item>
      <title>Re: listMaps() returns empty list when the project has a map</title>
      <link>https://community.esri.com/t5/python-questions/listmaps-returns-empty-list-when-the-project-has-a/m-p/1302039#M68016</link>
      <description>&lt;P&gt;Hmmm, well I changed it to "Map" again and this time it didn't give an error. However, if it were left blank would it not just list all maps in the project?&lt;/P&gt;</description>
      <pubDate>Thu, 22 Jun 2023 15:10:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/listmaps-returns-empty-list-when-the-project-has-a/m-p/1302039#M68016</guid>
      <dc:creator>AngelaSchirck</dc:creator>
      <dc:date>2023-06-22T15:10:20Z</dc:date>
    </item>
    <item>
      <title>Re: listMaps() returns empty list when the project has a map</title>
      <link>https://community.esri.com/t5/python-questions/listmaps-returns-empty-list-when-the-project-has-a/m-p/1302046#M68017</link>
      <description>&lt;P&gt;Yes.&lt;/P&gt;&lt;P&gt;What .listMaps() does is return a list of all maps. Adding the [0] afterwards returns the first item in the list.&lt;/P&gt;&lt;P&gt;So when you call .listMaps("Map"), it returns a list with only one item, ["Map]".&amp;nbsp;&lt;/P&gt;&lt;P&gt;.listMaps("Map")[0] returns the first item in the list of only one item.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Jun 2023 15:22:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/listmaps-returns-empty-list-when-the-project-has-a/m-p/1302046#M68017</guid>
      <dc:creator>AlfredBaldenweck</dc:creator>
      <dc:date>2023-06-22T15:22:50Z</dc:date>
    </item>
    <item>
      <title>Re: listMaps() returns empty list when the project has a map</title>
      <link>https://community.esri.com/t5/python-questions/listmaps-returns-empty-list-when-the-project-has-a/m-p/1311008#M68238</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/616122"&gt;@AngelaSchirck&lt;/a&gt;,&lt;BR /&gt;&lt;BR /&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/458875"&gt;@AlfredBaldenweck&lt;/a&gt;&amp;nbsp;is correct.&amp;nbsp; The parameter you are passing into listMaps is what ESRI calls the wildcard, although it behaves more like a regex match, seeking that exact name, except if you pass the star wildcard (see image below).&amp;nbsp; You are correct, if the wildcard is left empty, you should get a full list of all your maps.&amp;nbsp; If you are not getting a list of your maps, then something is wrong with your code (wrong path?).&amp;nbsp; Here are a few examples of how one could use the wildcard.&amp;nbsp; Notice, list maps returns maps objects, if you want names, you need to reach into the name property.&amp;nbsp; I created a list of names below using a list comprehension on the name property.&amp;nbsp; Also, notice, as&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/458875"&gt;@AlfredBaldenweck&lt;/a&gt;&amp;nbsp;mentioned, the index ([0]) is just for accessing single maps (or slicing [1:3] multiple).&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="TylerT_0-1690209940697.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/76106i439176578DBE8850/image-size/medium?v=v2&amp;amp;px=400" role="button" title="TylerT_0-1690209940697.png" alt="TylerT_0-1690209940697.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;A word of caution...ArcGIS Pro allows same name maps as seen above.&amp;nbsp; The user will have to use manual conventions to avoid this ambiguity if trying to access maps from listMaps().&lt;BR /&gt;&lt;BR /&gt;HTH.&lt;/P&gt;&lt;P&gt;Tyler&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jul 2023 14:49:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/listmaps-returns-empty-list-when-the-project-has-a/m-p/1311008#M68238</guid>
      <dc:creator>TylerT</dc:creator>
      <dc:date>2023-07-24T14:49:53Z</dc:date>
    </item>
  </channel>
</rss>

