<?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 Selected Features Extent in a Layer within a Map Service in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/zoom-to-selected-features-extent-in-a-layer-within/m-p/410305#M32352</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Shot in the dark, but did you try setting "False" to get the geometric extent instead of symbolized extent?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;d.extent = l.getExtent(False)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I doubt that would be an issue, but like I said, shot in the dark.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Another thing, will there always be a selection? There is another method to get an extent of selected features.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;d.extent = l.getSelectedExtent()&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You could also try getting just the layer you want instead of going through all of them recursively, &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;l = arcpy.mapping.ListLayers(mxd, "Rail Roads", d)[0]&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 24 Aug 2011 13:11:25 GMT</pubDate>
    <dc:creator>MathewCoyle</dc:creator>
    <dc:date>2011-08-24T13:11:25Z</dc:date>
    <item>
      <title>Zoom to Selected Features Extent in a Layer within a Map Service</title>
      <link>https://community.esri.com/t5/python-questions/zoom-to-selected-features-extent-in-a-layer-within/m-p/410300#M32347</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi, &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have a map document, and it has layers coming from non-cached map services. The map services can have features selected.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;How do I zoom to the selected features for a layer (i.e. a map service) in arcpy?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The script, map services and map document are all ArcGIS 10 SP2.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Aug 2011 02:21:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/zoom-to-selected-features-extent-in-a-layer-within/m-p/410300#M32347</guid>
      <dc:creator>HenryKo</dc:creator>
      <dc:date>2011-08-22T02:21:21Z</dc:date>
    </item>
    <item>
      <title>Re: Zoom to Selected Features Extent in a Layer within a Map Service</title>
      <link>https://community.esri.com/t5/python-questions/zoom-to-selected-features-extent-in-a-layer-within/m-p/410301#M32348</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;This can be done by using the Method of zoomToSelectedFeatures () for data frames or Layer.getSelectedExtent for layers.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;For more information, see this link on the data frame method: &lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/DataFrame/00s300000003000000/"&gt;http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/DataFrame/00s300000003000000/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;and this link for more on the layer method: &lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/Layer/00s300000008000000/"&gt;http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/Layer/00s300000008000000/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;There is a short sample and explanations that should help give you an idea of how each works.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Aug 2011 11:29:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/zoom-to-selected-features-extent-in-a-layer-within/m-p/410301#M32348</guid>
      <dc:creator>StephanieWendel</dc:creator>
      <dc:date>2011-08-22T11:29:10Z</dc:date>
    </item>
    <item>
      <title>Re: Zoom to Selected Features Extent in a Layer within a Map Service</title>
      <link>https://community.esri.com/t5/python-questions/zoom-to-selected-features-extent-in-a-layer-within/m-p/410302#M32349</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thank you for your reply.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I created a very simple MXD with a base map (a cached map service), and a non-cached map service (which it has a layer called "Rail Roads"). I ran the code below and it crashes. Is this a known issue?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;m = arcpy.mapping.MapDocument("test3.mxd")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;d = arcpy.mapping.ListDataFrames(m)[0]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;lyrs = arcpy.mapping.ListLayers(m, "", d)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;for l in lyrs:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print l.name&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (l.name == "Rail Roads"):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; d.extent = l.getExtent()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;d.zoomToSelectedFeatures()&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Aug 2011 07:48:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/zoom-to-selected-features-extent-in-a-layer-within/m-p/410302#M32349</guid>
      <dc:creator>HenryKo</dc:creator>
      <dc:date>2011-08-23T07:48:28Z</dc:date>
    </item>
    <item>
      <title>Re: Zoom to Selected Features Extent in a Layer within a Map Service</title>
      <link>https://community.esri.com/t5/python-questions/zoom-to-selected-features-extent-in-a-layer-within/m-p/410303#M32350</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Make sure in this line you use the full path the the map document: &lt;/SPAN&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;m = arcpy.mapping.MapDocument("test3.mxd")
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;For example: &lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;m = arcpy.mapping.MapDocument(r"C:\Data\MapDocs\test3.mxd")
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The way you have it right now, it is unsure of where to find that document.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 18:38:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/zoom-to-selected-features-extent-in-a-layer-within/m-p/410303#M32350</guid>
      <dc:creator>StephanieWendel</dc:creator>
      <dc:date>2021-12-11T18:38:25Z</dc:date>
    </item>
    <item>
      <title>Re: Zoom to Selected Features Extent in a Layer within a Map Service</title>
      <link>https://community.esri.com/t5/python-questions/zoom-to-selected-features-extent-in-a-layer-within/m-p/410304#M32351</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I tried it, still have the same results (i.e. the&amp;nbsp; l.getExtent() part crashes if the layer is part of a non-cached map service).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In fact, I tried it in the Python window within ArcMap with&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;m = arcpy.mapping.MapDocument("CURRENT")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;and it did not work.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Aug 2011 22:28:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/zoom-to-selected-features-extent-in-a-layer-within/m-p/410304#M32351</guid>
      <dc:creator>HenryKo</dc:creator>
      <dc:date>2011-08-23T22:28:06Z</dc:date>
    </item>
    <item>
      <title>Re: Zoom to Selected Features Extent in a Layer within a Map Service</title>
      <link>https://community.esri.com/t5/python-questions/zoom-to-selected-features-extent-in-a-layer-within/m-p/410305#M32352</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Shot in the dark, but did you try setting "False" to get the geometric extent instead of symbolized extent?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;d.extent = l.getExtent(False)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I doubt that would be an issue, but like I said, shot in the dark.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Another thing, will there always be a selection? There is another method to get an extent of selected features.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;d.extent = l.getSelectedExtent()&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You could also try getting just the layer you want instead of going through all of them recursively, &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;l = arcpy.mapping.ListLayers(mxd, "Rail Roads", d)[0]&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 Aug 2011 13:11:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/zoom-to-selected-features-extent-in-a-layer-within/m-p/410305#M32352</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2011-08-24T13:11:25Z</dc:date>
    </item>
  </channel>
</rss>

