<?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: Zoom To Selection in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/zoom-to-selection/m-p/1410830#M70354</link>
    <description>&lt;P&gt;Hmmm interesting&lt;/P&gt;&lt;P&gt;So I have a map (it is a map view as it is open) called &lt;STRONG&gt;Validation&lt;/STRONG&gt; and it has some selected point features in it:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="EdMorris_0-1713353380422.png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/101193i73B6EED649E42A34/image-size/large?v=v2&amp;amp;px=999" role="button" title="EdMorris_0-1713353380422.png" alt="EdMorris_0-1713353380422.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I also have a layout called &lt;STRONG&gt;Crimes_Layout&lt;/STRONG&gt;. This layout has a single Map Frame. That &lt;EM&gt;map frame&lt;/EM&gt; is looking at the &lt;STRONG&gt;Validation&lt;/STRONG&gt;&amp;nbsp;map (notice the same selected features in the layout...):&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="EdMorris_1-1713353555680.png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/101194i210A5FD6A3DA2B5D/image-size/large?v=v2&amp;amp;px=999" role="button" title="EdMorris_1-1713353555680.png" alt="EdMorris_1-1713353555680.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;When I click on my layout and I then run the code in my notebook, which&amp;nbsp;I supplied previously, the map inside of the map frame (which is inside of my layout) zooms to the extent of the selected features in my map:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="EdMorris_2-1713353648007.png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/101195i7CF9DC55FA968157/image-size/large?v=v2&amp;amp;px=999" role="button" title="EdMorris_2-1713353648007.png" alt="EdMorris_2-1713353648007.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I think the order in which you click on the layout tab and then the notebook is important.&lt;/P&gt;&lt;P&gt;Also to get this work on your machine just try to keep it simple to begin with. Understand the workflow which is required to get the map in the layout to zoom to the extent of the selected features...&lt;/P&gt;&lt;P&gt;I hope this works for you.&lt;/P&gt;&lt;P&gt;Many thanks ed&lt;/P&gt;</description>
    <pubDate>Wed, 17 Apr 2024 11:39:24 GMT</pubDate>
    <dc:creator>EdMorris</dc:creator>
    <dc:date>2024-04-17T11:39:24Z</dc:date>
    <item>
      <title>Zoom To Selection</title>
      <link>https://community.esri.com/t5/python-questions/zoom-to-selection/m-p/1410770#M70350</link>
      <description>&lt;P&gt;Can someone please help in figuring out 'Zoom to selection' based on Map, Using Layout Im able to achieve it through camera, but in map there are no methods for it, i tried this,&amp;nbsp;&lt;/P&gt;&lt;P&gt;lyr = aprxmap.listLayers()[0]&lt;BR /&gt;lyt = aprx.listLayouts("Layout")[0]&lt;BR /&gt;mf = lyt.listElements("mapframe_element")[0]&lt;/P&gt;&lt;P&gt;ext = mf.getLayerExtent(lyr,True,True)&lt;BR /&gt;mf.camera.setExtent(ext)&lt;BR /&gt;mapView.panToExtent(ext)&lt;/P&gt;</description>
      <pubDate>Wed, 17 Apr 2024 07:10:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/zoom-to-selection/m-p/1410770#M70350</guid>
      <dc:creator>umar_iasf</dc:creator>
      <dc:date>2024-04-17T07:10:15Z</dc:date>
    </item>
    <item>
      <title>Re: Zoom To Selection</title>
      <link>https://community.esri.com/t5/python-questions/zoom-to-selection/m-p/1410804#M70352</link>
      <description>&lt;P&gt;Hi&lt;BR /&gt;All you have to do is (assuming you are running your code in an ArcGIS NoteBook or Python Window in ArcGIS Pro):&lt;/P&gt;&lt;P&gt;1: Make sure you have a map open.&lt;/P&gt;&lt;P&gt;2: Make sure you have some selected features in the map:&lt;/P&gt;&lt;P&gt;3: Write the following code&lt;/P&gt;&lt;LI-CODE lang="python"&gt;proj = arcpy.mp.ArcGISProject("CURRENT")

mv = proj.activeView
mv.zoomToAllLayers(True)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You are working with a&amp;nbsp; MapView object which has a zoomToAllLayers() method. The boolean True argument says we want to use the selection of our layers.&lt;/P&gt;&lt;P&gt;I hope this helps&lt;/P&gt;&lt;P&gt;Many thanks ed&lt;/P&gt;</description>
      <pubDate>Wed, 17 Apr 2024 10:26:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/zoom-to-selection/m-p/1410804#M70352</guid>
      <dc:creator>EdMorris</dc:creator>
      <dc:date>2024-04-17T10:26:11Z</dc:date>
    </item>
    <item>
      <title>Re: Zoom To Selection</title>
      <link>https://community.esri.com/t5/python-questions/zoom-to-selection/m-p/1410806#M70353</link>
      <description>&lt;P&gt;Much appreciated&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/135968"&gt;@EdMorris&lt;/a&gt;&amp;nbsp; but zoomToAllLayers() refers to mapFrame object in documentation, when i use in mapView it gives no reference error,&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;AttributeError&lt;/SPAN&gt;: 'NoneType' object has no attribute 'zoomToAllLayers'&lt;/P&gt;</description>
      <pubDate>Wed, 17 Apr 2024 10:39:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/zoom-to-selection/m-p/1410806#M70353</guid>
      <dc:creator>umar_iasf</dc:creator>
      <dc:date>2024-04-17T10:39:11Z</dc:date>
    </item>
    <item>
      <title>Re: Zoom To Selection</title>
      <link>https://community.esri.com/t5/python-questions/zoom-to-selection/m-p/1410830#M70354</link>
      <description>&lt;P&gt;Hmmm interesting&lt;/P&gt;&lt;P&gt;So I have a map (it is a map view as it is open) called &lt;STRONG&gt;Validation&lt;/STRONG&gt; and it has some selected point features in it:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="EdMorris_0-1713353380422.png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/101193i73B6EED649E42A34/image-size/large?v=v2&amp;amp;px=999" role="button" title="EdMorris_0-1713353380422.png" alt="EdMorris_0-1713353380422.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I also have a layout called &lt;STRONG&gt;Crimes_Layout&lt;/STRONG&gt;. This layout has a single Map Frame. That &lt;EM&gt;map frame&lt;/EM&gt; is looking at the &lt;STRONG&gt;Validation&lt;/STRONG&gt;&amp;nbsp;map (notice the same selected features in the layout...):&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="EdMorris_1-1713353555680.png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/101194i210A5FD6A3DA2B5D/image-size/large?v=v2&amp;amp;px=999" role="button" title="EdMorris_1-1713353555680.png" alt="EdMorris_1-1713353555680.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;When I click on my layout and I then run the code in my notebook, which&amp;nbsp;I supplied previously, the map inside of the map frame (which is inside of my layout) zooms to the extent of the selected features in my map:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="EdMorris_2-1713353648007.png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/101195i7CF9DC55FA968157/image-size/large?v=v2&amp;amp;px=999" role="button" title="EdMorris_2-1713353648007.png" alt="EdMorris_2-1713353648007.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I think the order in which you click on the layout tab and then the notebook is important.&lt;/P&gt;&lt;P&gt;Also to get this work on your machine just try to keep it simple to begin with. Understand the workflow which is required to get the map in the layout to zoom to the extent of the selected features...&lt;/P&gt;&lt;P&gt;I hope this works for you.&lt;/P&gt;&lt;P&gt;Many thanks ed&lt;/P&gt;</description>
      <pubDate>Wed, 17 Apr 2024 11:39:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/zoom-to-selection/m-p/1410830#M70354</guid>
      <dc:creator>EdMorris</dc:creator>
      <dc:date>2024-04-17T11:39:24Z</dc:date>
    </item>
  </channel>
</rss>

