<?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 layer on the map view arcpy.mp in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/zoom-to-layer-on-the-map-view-arcpy-mp/m-p/1063810#M61275</link>
    <description>&lt;P&gt;I have a similar scenario; I have a python script that automatically creates maps from a template in ArcGIS Pro. There are 3 maps and 2 layouts in the ArcGIS Pro project. I can easily get the layouts to zoom to the new extent of the layers, but (as stated above) there is no functionality to zoom to the layers on the &lt;STRONG&gt;Map View&lt;/STRONG&gt;, only the Map Frame within the layout.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Kaz_0-1622579396039.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/14749iCCA65433D8BFB22B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Kaz_0-1622579396039.png" alt="Kaz_0-1622579396039.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My output looks a bit strange because the 2 layouts are centered on the data but the 3 maps are set to the template's extent (which doesn't show any data). The user could always open the project, right click on a layer from the content pane, and choose "zoom to layer" but that feels a bit redundant.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could you explain the work around you mentioned above? Or maybe there is a better work around for my use case?&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 01 Jun 2021 20:31:19 GMT</pubDate>
    <dc:creator>Kaz</dc:creator>
    <dc:date>2021-06-01T20:31:19Z</dc:date>
    <item>
      <title>Zoom to layer on the map view arcpy.mp</title>
      <link>https://community.esri.com/t5/python-questions/zoom-to-layer-on-the-map-view-arcpy-mp/m-p/1046096#M60748</link>
      <description>&lt;P&gt;I am attempting to zoom to layer on the map view NOT the layout view. I am aware that I can zoom to a layer using the code below&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;cam&amp;nbsp;=&amp;nbsp;c_project.activeView.camera&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;ext&amp;nbsp;=&amp;nbsp;arcpy.Describe(layer).extent&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;cam.setExtent(ext)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;c_project.save()&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;My issue is that&amp;nbsp;c_project.activeView returns None because the project is not yet open.&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/1134"&gt;@JeffBarrette&lt;/a&gt;&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/1135"&gt;@JeffMoulds&lt;/a&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 12 Apr 2021 21:38:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/zoom-to-layer-on-the-map-view-arcpy-mp/m-p/1046096#M60748</guid>
      <dc:creator>MarvisKisakye1</dc:creator>
      <dc:date>2021-04-12T21:38:16Z</dc:date>
    </item>
    <item>
      <title>Re: Zoom to layer on the map view arcpy.mp</title>
      <link>https://community.esri.com/t5/python-questions/zoom-to-layer-on-the-map-view-arcpy-mp/m-p/1046130#M60750</link>
      <description>&lt;P&gt;Marvis, this is a known limitation with ActiveMap and ActiveView and is documented under ArcGISProject.&lt;/P&gt;&lt;P&gt;&lt;I&gt;"The activeMap property will return the map associated with either an active map view or the active map frame on an active layout view. The activeView property will either return a MapView object if a map view is active or it will return a Layout object if a layout view is active. Both of these properties are intended for scripts to be executed in the application, such as scripts run in the Python pane or those associated with a script tool. If no views are active, both properties will return None. These properties will always return a None value when a script is run outside of the application, because views are only relevant when the application is open. The MapView returned from the activeView property is the only way to change the extent associated with a map view. There are multiple functions available on the MapView class that allow you to change the extent, such as, the camera property, panToExtent, ZoomToAllLayers, and ZoomToBookmarks."&lt;/I&gt;&lt;/P&gt;&lt;P&gt;Jeff - arcpy.mp and Layout teams&lt;/P&gt;</description>
      <pubDate>Mon, 12 Apr 2021 22:04:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/zoom-to-layer-on-the-map-view-arcpy-mp/m-p/1046130#M60750</guid>
      <dc:creator>JeffBarrette</dc:creator>
      <dc:date>2021-04-12T22:04:51Z</dc:date>
    </item>
    <item>
      <title>Re: Zoom to layer on the map view arcpy.mp</title>
      <link>https://community.esri.com/t5/python-questions/zoom-to-layer-on-the-map-view-arcpy-mp/m-p/1046462#M60767</link>
      <description>&lt;P&gt;Well that's a bummer. All my work is performed in an external script that on completion, opens up ArcGIS Pro. It would be nice to have the project open up zoomed to the extent of the data in the map view.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Apr 2021 17:11:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/zoom-to-layer-on-the-map-view-arcpy-mp/m-p/1046462#M60767</guid>
      <dc:creator>MarvisKisakye1</dc:creator>
      <dc:date>2021-04-13T17:11:35Z</dc:date>
    </item>
    <item>
      <title>Re: Zoom to layer on the map view arcpy.mp</title>
      <link>https://community.esri.com/t5/python-questions/zoom-to-layer-on-the-map-view-arcpy-mp/m-p/1046618#M60772</link>
      <description>&lt;P&gt;It would definitely be helpful if MapViews could be managed outside of the application. But MapViews only exist in the application AND you can have many map views of the same map so without a management system or some unique name to find the specific map view of interest, its not possible. And if the app is not opened, there definitely isn't the notion of an active map view.&amp;nbsp;&lt;/P&gt;&lt;P&gt;One possible work around is to create a map frame that is the same size of a layout.&amp;nbsp; You can do everything you need to do against a map frame out of process (or outside the application).&lt;/P&gt;&lt;P&gt;Jeff - arcpy.mp and Layout teams&lt;/P&gt;</description>
      <pubDate>Thu, 03 Jun 2021 22:43:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/zoom-to-layer-on-the-map-view-arcpy-mp/m-p/1046618#M60772</guid>
      <dc:creator>JeffBarrette</dc:creator>
      <dc:date>2021-06-03T22:43:40Z</dc:date>
    </item>
    <item>
      <title>Re: Zoom to layer on the map view arcpy.mp</title>
      <link>https://community.esri.com/t5/python-questions/zoom-to-layer-on-the-map-view-arcpy-mp/m-p/1063810#M61275</link>
      <description>&lt;P&gt;I have a similar scenario; I have a python script that automatically creates maps from a template in ArcGIS Pro. There are 3 maps and 2 layouts in the ArcGIS Pro project. I can easily get the layouts to zoom to the new extent of the layers, but (as stated above) there is no functionality to zoom to the layers on the &lt;STRONG&gt;Map View&lt;/STRONG&gt;, only the Map Frame within the layout.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Kaz_0-1622579396039.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/14749iCCA65433D8BFB22B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Kaz_0-1622579396039.png" alt="Kaz_0-1622579396039.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My output looks a bit strange because the 2 layouts are centered on the data but the 3 maps are set to the template's extent (which doesn't show any data). The user could always open the project, right click on a layer from the content pane, and choose "zoom to layer" but that feels a bit redundant.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could you explain the work around you mentioned above? Or maybe there is a better work around for my use case?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Jun 2021 20:31:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/zoom-to-layer-on-the-map-view-arcpy-mp/m-p/1063810#M61275</guid>
      <dc:creator>Kaz</dc:creator>
      <dc:date>2021-06-01T20:31:19Z</dc:date>
    </item>
    <item>
      <title>Re: Zoom to layer on the map view arcpy.mp</title>
      <link>https://community.esri.com/t5/python-questions/zoom-to-layer-on-the-map-view-arcpy-mp/m-p/1064911#M61294</link>
      <description>&lt;P&gt;You can use arcpy.mp to change the extent of an active map view BUT only using scripts run inside the application and only against the active view.&amp;nbsp; Check out the MapView class:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/mapping/mapview-class.htm" target="_blank"&gt;https://pro.arcgis.com/en/pro-app/latest/arcpy/mapping/mapview-class.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;We do hope in the near term that we will be able to set the active view (vs only working with the current active view).&amp;nbsp; This will have its limitations as well.&amp;nbsp; The idea is you would call something like OpenMapView and it would simply open a new view, with the default extent, and it would become active.&amp;nbsp; Again, the limitation exists because we can't distinguish multiple map views pointing to the same map.&lt;/P&gt;</description>
      <pubDate>Thu, 03 Jun 2021 22:50:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/zoom-to-layer-on-the-map-view-arcpy-mp/m-p/1064911#M61294</guid>
      <dc:creator>JeffBarrette</dc:creator>
      <dc:date>2021-06-03T22:50:00Z</dc:date>
    </item>
    <item>
      <title>Re: Zoom to layer on the map view arcpy.mp</title>
      <link>https://community.esri.com/t5/python-questions/zoom-to-layer-on-the-map-view-arcpy-mp/m-p/1145997#M63827</link>
      <description>&lt;P&gt;What do you mean by "scripts run inside the application"? Doesn't this mean a script in a Python window or in a Python notebook opened within an ArcGIS Pro project? aprx.activeView always returns None.&lt;/P&gt;&lt;P&gt;Or maybe the question should be, how to make a map active? When I open a new map project,&amp;nbsp; aprx.activeView always returns None even in this case with only one possible View.&lt;/P&gt;&lt;P&gt;Put more explicitly, the first code sample at the end of &lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/mapping/mapview-class.htm" target="_blank" rel="noopener"&gt;https://pro.arcgis.com/en/pro-app/latest/arcpy/mapping/mapview-class.htm&lt;/A&gt; always fails.&lt;/P&gt;&lt;P&gt;-- Andy&lt;/P&gt;</description>
      <pubDate>Sun, 20 Feb 2022 22:11:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/zoom-to-layer-on-the-map-view-arcpy-mp/m-p/1145997#M63827</guid>
      <dc:creator>AndyAnderson</dc:creator>
      <dc:date>2022-02-20T22:11:43Z</dc:date>
    </item>
    <item>
      <title>Re: Zoom to layer on the map view arcpy.mp</title>
      <link>https://community.esri.com/t5/python-questions/zoom-to-layer-on-the-map-view-arcpy-mp/m-p/1147618#M63870</link>
      <description>&lt;P&gt;First, we fixed an issue in 3.0 concerning Notebooks.&amp;nbsp; Notebooks are a View so if you tried getting the activeView, None would be returned because a Notebook is NOT a mapview or layout view.&amp;nbsp; At 3.0 Notebooks can appropriately reference the (previously) ActiveView.&lt;/P&gt;&lt;P&gt;Second, also at 3.0 we introduced new functions to OpenViews (e.g., Map/Layout.OpenView()) and Project.CloseViews().&amp;nbsp; This allows you to active a view for a specific Map or Layout and modify the extent the way you want it.&amp;nbsp; Also, we have the ability to closeviews to remove any unwanted clutter.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;NOTE - again, any API functions concerning Views in Pro MUST be executed within the application (PyWIn, NoteBooks, ScriptTools).&amp;nbsp; These functions are ignored outside the application using stand alone scripts.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Jeff - arcpy.mp and Layout teams.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Feb 2022 17:39:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/zoom-to-layer-on-the-map-view-arcpy-mp/m-p/1147618#M63870</guid>
      <dc:creator>JeffBarrette</dc:creator>
      <dc:date>2022-02-24T17:39:17Z</dc:date>
    </item>
    <item>
      <title>Re: Zoom to layer on the map view arcpy.mp</title>
      <link>https://community.esri.com/t5/python-questions/zoom-to-layer-on-the-map-view-arcpy-mp/m-p/1148337#M63886</link>
      <description>&lt;P&gt;That's great to hear that this will be fixed in 3. Do you know when that will be released?&lt;/P&gt;&lt;P&gt;The new functions look useful. However, I'd like to recommend that you also implement a new method arcpy.listViews() that would return all of the view types you mention, which would allow me to search different views for their names and types. This would be more generally useful than knowing just the active view.&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;-- Andy&lt;/P&gt;</description>
      <pubDate>Sun, 27 Feb 2022 14:13:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/zoom-to-layer-on-the-map-view-arcpy-mp/m-p/1148337#M63886</guid>
      <dc:creator>AndyAnderson</dc:creator>
      <dc:date>2022-02-27T14:13:08Z</dc:date>
    </item>
    <item>
      <title>Re: Zoom to layer on the map view arcpy.mp</title>
      <link>https://community.esri.com/t5/python-questions/zoom-to-layer-on-the-map-view-arcpy-mp/m-p/1148619#M63891</link>
      <description>&lt;P&gt;3.0 is planned to be available by the User Conference in July.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Concerning ListViews() this really isn't possible because views are NOT uniquely named.&amp;nbsp; You can open a map view for the same map many times and every view can have a different extent.&amp;nbsp; How would you know which one you wanted.&amp;nbsp; I personally would like to see view with unique names so we could manage views&amp;nbsp; better.&lt;/P&gt;&lt;P&gt;Jeff - arcpy.mp and Layout teams.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Feb 2022 16:01:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/zoom-to-layer-on-the-map-view-arcpy-mp/m-p/1148619#M63891</guid>
      <dc:creator>JeffBarrette</dc:creator>
      <dc:date>2022-02-28T16:01:49Z</dc:date>
    </item>
    <item>
      <title>Re: Zoom to layer on the map view arcpy.mp</title>
      <link>https://community.esri.com/t5/python-questions/zoom-to-layer-on-the-map-view-arcpy-mp/m-p/1148690#M63892</link>
      <description>&lt;P&gt;Ah, yes, Views have no names. But if that continues there could still be types, and the MapViews also provide links to their own Cameras, which do have extents, and links to their own Maps, which do have names, and these could be used to distinguish the different MapViews. But here are three additional ways one could tell them apart:&lt;/P&gt;&lt;P&gt;1) Assign the activeView to a variable before switching to a new one.&lt;/P&gt;&lt;P&gt;2) Ensure that the proposed listViews() method returns indexed Views in temporal order, and assign them to distinguishable variables; the latest would always be listViews()[-1].&lt;/P&gt;&lt;P&gt;3) When I tell a map to open a new MapView, assign that reference to a variable.&lt;/P&gt;&lt;P&gt;Just some thoughts!&lt;/P&gt;&lt;P&gt;— Andy&lt;/P&gt;</description>
      <pubDate>Mon, 28 Feb 2022 17:51:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/zoom-to-layer-on-the-map-view-arcpy-mp/m-p/1148690#M63892</guid>
      <dc:creator>AndyAnderson</dc:creator>
      <dc:date>2022-02-28T17:51:03Z</dc:date>
    </item>
    <item>
      <title>Re: Zoom to layer on the map view arcpy.mp</title>
      <link>https://community.esri.com/t5/python-questions/zoom-to-layer-on-the-map-view-arcpy-mp/m-p/1148871#M63894</link>
      <description>&lt;P&gt;Andy, I'm not sure I understand your points or perhaps our 3.0 release will have your solution.&amp;nbsp; At 3.0 we can currently differential between these view types: Map, Layout and Other (where Other = table, report, model builder, etc).&lt;/P&gt;&lt;P&gt;But if you have a single "MapA" and have 3 views of it open, I'm not sure how you can distinguish one from the other.&amp;nbsp; They all have the same name and same Map property.&amp;nbsp; Yes, the extents MIGHT be different and you can interrogate the camera but how realistic is that?&lt;/P&gt;&lt;P&gt;This is where OpenView() and CloseViews() work well together. If you want to specify a specific Map or Layout View, you can first call CloseViews (with an option to close all or just maps or just layouts) and then call Layout or MapA.OpenView() and set your camera info accordingly.&lt;/P&gt;&lt;P&gt;I hope this makes sense.&amp;nbsp; Are you going to the Developer Summit?&amp;nbsp; I'd be happy to talk to you there.&lt;/P&gt;&lt;P&gt;Jeff&lt;/P&gt;</description>
      <pubDate>Mon, 28 Feb 2022 23:40:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/zoom-to-layer-on-the-map-view-arcpy-mp/m-p/1148871#M63894</guid>
      <dc:creator>JeffBarrette</dc:creator>
      <dc:date>2022-02-28T23:40:49Z</dc:date>
    </item>
    <item>
      <title>Re: Zoom to layer on the map view arcpy.mp</title>
      <link>https://community.esri.com/t5/python-questions/zoom-to-layer-on-the-map-view-arcpy-mp/m-p/1148909#M63895</link>
      <description>&lt;P&gt;MapViews are often opened manually, not always by script. So there needs to be a way for a script to find them and work with them. Really, this is just a generalization of listLayouts.&lt;/P&gt;&lt;P&gt;Sadly, I cannot attend the DevSummit. Too busy teaching GIS Programming &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;— &amp;nbsp;Andy&lt;/P&gt;</description>
      <pubDate>Tue, 01 Mar 2022 01:54:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/zoom-to-layer-on-the-map-view-arcpy-mp/m-p/1148909#M63895</guid>
      <dc:creator>AndyAnderson</dc:creator>
      <dc:date>2022-03-01T01:54:31Z</dc:date>
    </item>
    <item>
      <title>Re: Zoom to layer on the map view arcpy.mp</title>
      <link>https://community.esri.com/t5/python-questions/zoom-to-layer-on-the-map-view-arcpy-mp/m-p/1203551#M65344</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/1134"&gt;@JeffBarrette&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;Thanks for posting in the forum and creating the What's New documents.&lt;BR /&gt;&lt;BR /&gt;I'm curious where the openView function is documented.&lt;/P&gt;</description>
      <pubDate>Tue, 16 Aug 2022 23:09:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/zoom-to-layer-on-the-map-view-arcpy-mp/m-p/1203551#M65344</guid>
      <dc:creator>PhilLarkin1</dc:creator>
      <dc:date>2022-08-16T23:09:59Z</dc:date>
    </item>
    <item>
      <title>Re: Zoom to layer on the map view arcpy.mp</title>
      <link>https://community.esri.com/t5/python-questions/zoom-to-layer-on-the-map-view-arcpy-mp/m-p/1203574#M65345</link>
      <description>&lt;P&gt;Map/Report/Layout.openView()&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Jeff - Layout and arcpy.mp teams&lt;/P&gt;</description>
      <pubDate>Tue, 16 Aug 2022 23:47:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/zoom-to-layer-on-the-map-view-arcpy-mp/m-p/1203574#M65345</guid>
      <dc:creator>JeffBarrette</dc:creator>
      <dc:date>2022-08-16T23:47:25Z</dc:date>
    </item>
  </channel>
</rss>

