<?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: Graphics Layer getting bounds or center of all graphics in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/graphics-layer-getting-bounds-or-center-of-all/m-p/1045768#M72450</link>
    <description>&lt;P&gt;Hi Mitchell112,&lt;/P&gt;&lt;P&gt;The fullExtent property of GraphicsLayer represents the entire earth, with the intersection of the equator and the prime meridian as the center(0,0).&lt;/P&gt;&lt;P&gt;If you are getting the extents of a graphic layer to submit to the view for zooming, the view does this for you from the layre's graphics:&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;view.goTo(graphicsLayer.graphics.toArray());&lt;/P&gt;&lt;P&gt;However, if you want these values for other purposes, a simple way is this. (There is, probably, a utility to get extents of an array of geometries, but this works just fine):&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //First, and obviously you want your layer to have all of its graphics, an empty layer wont work.&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;graphicsLayer.graphics.push(...myArrayOfGraphics);//the ellipse (...) iterates the push method.&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// Start with the first graphic and iterate the layer's graphics to build extent&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;let extent = graphicsLayer.graphics.getItemAt(0).geometry.extent;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; graphicsLayer.graphics.forEach((graphic)=&amp;gt;{&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; let gextent = graphic.geometry.extent;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if(!gextent.equals(extent)){//this should only skip the first one&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;extent = extent.union(gextent);&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; });&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; let center = exent.center;// The center of the layer's extent.&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; //extent, above will be the entire extent of the layer's graphics.&lt;/P&gt;</description>
    <pubDate>Sun, 11 Apr 2021 15:14:56 GMT</pubDate>
    <dc:creator>EugeneStaten</dc:creator>
    <dc:date>2021-04-11T15:14:56Z</dc:date>
    <item>
      <title>Graphics Layer getting bounds or center of all graphics</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/graphics-layer-getting-bounds-or-center-of-all/m-p/1045641#M72445</link>
      <description>&lt;P&gt;When using a graphics layer how can you get the center of all graphics? I looked into fullExtent, but the values are always 0 and not what you would expect them to be. Is there some kind of tool I'm not finding in the documentation that I can use?&lt;/P&gt;</description>
      <pubDate>Sat, 10 Apr 2021 13:36:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/graphics-layer-getting-bounds-or-center-of-all/m-p/1045641#M72445</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-04-10T13:36:55Z</dc:date>
    </item>
    <item>
      <title>Re: Graphics Layer getting bounds or center of all graphics</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/graphics-layer-getting-bounds-or-center-of-all/m-p/1045768#M72450</link>
      <description>&lt;P&gt;Hi Mitchell112,&lt;/P&gt;&lt;P&gt;The fullExtent property of GraphicsLayer represents the entire earth, with the intersection of the equator and the prime meridian as the center(0,0).&lt;/P&gt;&lt;P&gt;If you are getting the extents of a graphic layer to submit to the view for zooming, the view does this for you from the layre's graphics:&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;view.goTo(graphicsLayer.graphics.toArray());&lt;/P&gt;&lt;P&gt;However, if you want these values for other purposes, a simple way is this. (There is, probably, a utility to get extents of an array of geometries, but this works just fine):&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //First, and obviously you want your layer to have all of its graphics, an empty layer wont work.&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;graphicsLayer.graphics.push(...myArrayOfGraphics);//the ellipse (...) iterates the push method.&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// Start with the first graphic and iterate the layer's graphics to build extent&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;let extent = graphicsLayer.graphics.getItemAt(0).geometry.extent;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; graphicsLayer.graphics.forEach((graphic)=&amp;gt;{&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; let gextent = graphic.geometry.extent;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if(!gextent.equals(extent)){//this should only skip the first one&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;extent = extent.union(gextent);&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; });&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; let center = exent.center;// The center of the layer's extent.&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; //extent, above will be the entire extent of the layer's graphics.&lt;/P&gt;</description>
      <pubDate>Sun, 11 Apr 2021 15:14:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/graphics-layer-getting-bounds-or-center-of-all/m-p/1045768#M72450</guid>
      <dc:creator>EugeneStaten</dc:creator>
      <dc:date>2021-04-11T15:14:56Z</dc:date>
    </item>
  </channel>
</rss>

