<?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: Get Extent from a GraphicsLayer in ArcGIS Runtime SDK for Android Questions</title>
    <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/get-extent-from-a-graphicslayer/m-p/88631#M667</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;What I've done to accomplish this is build an envelope and merge the extent of each graphic into the envelope.&amp;nbsp; Here's how:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
Envelope env = new Envelope();
Envelope NewEnv = new Envelope();
&amp;nbsp;&amp;nbsp;&amp;nbsp; for (int i:graphicsLayer.getGraphicIDs()){
 Polygon p = (Polygon) graphicsLayer.getGraphic(i).getGeometry();
 p.queryEnvelope(env);
 NewEnv.merge(env);
&amp;nbsp;&amp;nbsp; } 

 MapView.setExtent(NewEnv);
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 10 Dec 2021 23:23:41 GMT</pubDate>
    <dc:creator>deleted-user-ATjHIWsdQYmT</dc:creator>
    <dc:date>2021-12-10T23:23:41Z</dc:date>
    <item>
      <title>Get Extent from a GraphicsLayer</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/get-extent-from-a-graphicslayer/m-p/88630#M666</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi everybody!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; I'm trying to get the extent (as a Geometry object) from a graphics layer in which i have added several polylines,&amp;nbsp; and set the map's extent with this polygon, this way:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Polygon poligonoRutas = graphicsLayerLines.getExtent();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(poligonoRutas != null){&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; map.setExtent(poligonoRutas);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; I've checked that the polygon returned has vertices, i get no error but it seems that the extent is not working. I've also tried to get the fullExtent form the graphics layer but the envelope object returned is null (i don't know the reason, because the graphics layer has several polylines). Do you know what i'm doing wrong?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank's in advance!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 Jun 2012 09:29:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/get-extent-from-a-graphicslayer/m-p/88630#M666</guid>
      <dc:creator>JesusSanchez</dc:creator>
      <dc:date>2012-06-19T09:29:46Z</dc:date>
    </item>
    <item>
      <title>Re: Get Extent from a GraphicsLayer</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/get-extent-from-a-graphicslayer/m-p/88631#M667</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;What I've done to accomplish this is build an envelope and merge the extent of each graphic into the envelope.&amp;nbsp; Here's how:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
Envelope env = new Envelope();
Envelope NewEnv = new Envelope();
&amp;nbsp;&amp;nbsp;&amp;nbsp; for (int i:graphicsLayer.getGraphicIDs()){
 Polygon p = (Polygon) graphicsLayer.getGraphic(i).getGeometry();
 p.queryEnvelope(env);
 NewEnv.merge(env);
&amp;nbsp;&amp;nbsp; } 

 MapView.setExtent(NewEnv);
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 23:23:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/get-extent-from-a-graphicslayer/m-p/88631#M667</guid>
      <dc:creator>deleted-user-ATjHIWsdQYmT</dc:creator>
      <dc:date>2021-12-10T23:23:41Z</dc:date>
    </item>
    <item>
      <title>Re: Get Extent from a GraphicsLayer</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/get-extent-from-a-graphicslayer/m-p/88632#M668</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thank's andrewb! It was a great solution. I made a cast to Polyline instead Polygon for each graphic, but it's working great. I have been trying one more thing, now i have two graphics layer, one for lines and the other one for points. I've tried this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Envelope env = new Envelope();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Envelope NewEnv = new Envelope();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for (int i:graphicsLayerLines.getGraphicIDs()){&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Polyline p = (Polyline)graphicsLayerLines.getGraphic(i).getGeometry();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; p.queryEnvelope(env);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for (int i:graphicsLayerPoints.getGraphicIDs()){&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Point p = (Point)graphicsLayerPoints.getGraphic(i).getGeometry();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; p.queryEnvelope(env);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; NewEnv.merge(env);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; map.setExtent(NewEnv);&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This is making an extent to the last point, but i want an extent to an envelope which contains all the lines and all the points. Any idea how to do it?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Jun 2012 07:22:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/get-extent-from-a-graphicslayer/m-p/88632#M668</guid>
      <dc:creator>JesusSanchez</dc:creator>
      <dc:date>2012-06-20T07:22:29Z</dc:date>
    </item>
    <item>
      <title>Re: Get Extent from a GraphicsLayer</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/get-extent-from-a-graphicslayer/m-p/88633#M669</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;That's because you are setting the Envelope to the extent of the last point in your iteration.&amp;nbsp; Try this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;Envelope env = new Envelope(); Envelope NewEnv = new Envelope(); for (int i:graphicsLayerLines.getGraphicIDs()){ Polyline p = (Polyline)graphicsLayerLines.getGraphic(i).getGeometry(); &amp;nbsp;&amp;nbsp;&amp;nbsp; p.queryEnvelope(env); &amp;nbsp;&amp;nbsp;&amp;nbsp; NewEnv.merge(env); } for (int i:graphicsLayerPoints.getGraphicIDs()){ &amp;nbsp; Point p = (Point)graphicsLayerPoints.getGraphic(i).getGeometry(); &amp;nbsp; p.queryEnvelope(env); &amp;nbsp; NewEnv.merge(env); }&amp;nbsp; map.setExtent(NewEnv);&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Jun 2012 11:09:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/get-extent-from-a-graphicslayer/m-p/88633#M669</guid>
      <dc:creator>deleted-user-ATjHIWsdQYmT</dc:creator>
      <dc:date>2012-06-20T11:09:15Z</dc:date>
    </item>
    <item>
      <title>Re: Get Extent from a GraphicsLayer</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/get-extent-from-a-graphicslayer/m-p/88634#M670</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;That's right, andrewb. I made an stupid mistake, thanks for your help.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Jun 2012 11:34:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/get-extent-from-a-graphicslayer/m-p/88634#M670</guid>
      <dc:creator>JesusSanchez</dc:creator>
      <dc:date>2012-06-20T11:34:43Z</dc:date>
    </item>
  </channel>
</rss>

