<?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: GetCentroid of selected feature layer, scale-dependent issue, Javascript API in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/getcentroid-of-selected-feature-layer-scale/m-p/511920#M47701</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sure, Robert.&amp;nbsp; I appreciate you taking a look.&amp;nbsp; I just attached it to my original post.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 22 Jun 2015 14:31:42 GMT</pubDate>
    <dc:creator>ShawnaErnst</dc:creator>
    <dc:date>2015-06-22T14:31:42Z</dc:date>
    <item>
      <title>GetCentroid of selected feature layer, scale-dependent issue, Javascript API</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/getcentroid-of-selected-feature-layer-scale/m-p/511918#M47699</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've written some code based on this ESRI sample:&amp;nbsp; &lt;A href="https://developers.arcgis.com/javascript/jssamples/fl_selectfeatures.html"&gt;Feature Layer with Selection&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My goal is to have the user select property boundaries (parcels) on the map, use the selected features to get the centroid of each property, and then send those centroids through to the Directions widget.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here's the function that runs after the user has already selected their property boundaries (wired to a button click):&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="111937" alt="Capture.JPG" class="image-4 jive-image" src="https://community.esri.com/legacyfs/online/111937_Capture.JPG" style="width: 620px; height: 251px;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And here's the issue...depending on my zoom-level at the time of selection, I get vastly different results.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When selecting parcels while zoomed-out, centroids look correct, but selection graphics become triangles:&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="111841" alt="OddGeometry1.JPG" class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/111841_OddGeometry1.JPG" style="height: auto;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mid-zoom selection produces these results, which appear correctly:&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="111935" alt="OddGeometry2.JPG" class="image-2 jive-image" src="https://community.esri.com/legacyfs/online/111935_OddGeometry2.JPG" style="height: auto;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When selecting while zoomed-in closely, I get wildly inaccurate centroids.&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="111936" alt="OddGeometry3.JPG" class="image-3 jive-image" src="https://community.esri.com/legacyfs/online/111936_OddGeometry3.JPG" style="height: auto;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It's obvious that I have something wrong, but I'm not sure what...&amp;nbsp; I'm new at JavaScript, so I'm guessing that I haven't accounted for something in the way the graphics work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help would be much appreciated!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: Shawna Ernst&#xD;
&#xD;
Added attachment with the full code (service names removed).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 21 Jun 2015 00:41:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/getcentroid-of-selected-feature-layer-scale/m-p/511918#M47699</guid>
      <dc:creator>ShawnaErnst</dc:creator>
      <dc:date>2015-06-21T00:41:17Z</dc:date>
    </item>
    <item>
      <title>Re: GetCentroid of selected feature layer, scale-dependent issue, Javascript API</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/getcentroid-of-selected-feature-layer-scale/m-p/511919#M47700</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Shawna,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; WOW, I have not seen such displacement errors before. Can you share all of your code for review?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Jun 2015 14:19:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/getcentroid-of-selected-feature-layer-scale/m-p/511919#M47700</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2015-06-22T14:19:32Z</dc:date>
    </item>
    <item>
      <title>Re: GetCentroid of selected feature layer, scale-dependent issue, Javascript API</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/getcentroid-of-selected-feature-layer-scale/m-p/511920#M47701</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sure, Robert.&amp;nbsp; I appreciate you taking a look.&amp;nbsp; I just attached it to my original post.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Jun 2015 14:31:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/getcentroid-of-selected-feature-layer-scale/m-p/511920#M47701</guid>
      <dc:creator>ShawnaErnst</dc:creator>
      <dc:date>2015-06-22T14:31:42Z</dc:date>
    </item>
    <item>
      <title>Re: GetCentroid of selected feature layer, scale-dependent issue, Javascript API</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/getcentroid-of-selected-feature-layer-scale/m-p/511921#M47702</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Shawna,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; I don't seem to have these issues when I swap out your URL for mine and use your exact code. Seems like you may be having map service issues.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Jun 2015 15:46:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/getcentroid-of-selected-feature-layer-scale/m-p/511921#M47702</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2015-06-22T15:46:12Z</dc:date>
    </item>
    <item>
      <title>Re: GetCentroid of selected feature layer, scale-dependent issue, Javascript API</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/getcentroid-of-selected-feature-layer-scale/m-p/511922#M47703</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Interesting.&amp;nbsp; Okay- I will play around with my map service.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It's running on 10.3 and set to Web Mercator to match the ESRI basemap. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Jun 2015 15:49:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/getcentroid-of-selected-feature-layer-scale/m-p/511922#M47703</guid>
      <dc:creator>ShawnaErnst</dc:creator>
      <dc:date>2015-06-22T15:49:18Z</dc:date>
    </item>
    <item>
      <title>Re: GetCentroid of selected feature layer, scale-dependent issue, Javascript API</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/getcentroid-of-selected-feature-layer-scale/m-p/511923#M47704</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've tried this with a 10.3 service, 10.0 service, and an AGOL-hosted feature layer - and I get the exact same issue with all my tests.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've also tried updating the maxAllowableOffset parameter in Javascript, updating the "Max number of records returned by the server" parameter on the map service, and using a completely different dataset - all tests produced the same result.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think I may open a support case. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Jun 2015 21:08:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/getcentroid-of-selected-feature-layer-scale/m-p/511923#M47704</guid>
      <dc:creator>ShawnaErnst</dc:creator>
      <dc:date>2015-06-22T21:08:38Z</dc:date>
    </item>
    <item>
      <title>Re: GetCentroid of selected feature layer, scale-dependent issue, Javascript API</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/getcentroid-of-selected-feature-layer-scale/m-p/511924#M47705</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Shawna,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; Yes my recommendation would be to call tech support.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Jun 2015 21:12:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/getcentroid-of-selected-feature-layer-scale/m-p/511924#M47705</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2015-06-22T21:12:24Z</dc:date>
    </item>
    <item>
      <title>Re: GetCentroid of selected feature layer, scale-dependent issue, Javascript API</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/getcentroid-of-selected-feature-layer-scale/m-p/511925#M47706</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What happens when you specify "autoGeneralize: false" when constructing the parcel featureLayer?..&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Jun 2015 21:22:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/getcentroid-of-selected-feature-layer-scale/m-p/511925#M47706</guid>
      <dc:creator>SteveCole</dc:creator>
      <dc:date>2015-06-22T21:22:14Z</dc:date>
    </item>
    <item>
      <title>Re: GetCentroid of selected feature layer, scale-dependent issue, Javascript API</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/getcentroid-of-selected-feature-layer-scale/m-p/511926#M47707</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Steve,&amp;nbsp; that makes it so my third picture (the zoomed-in selection), is what I get every single time.&amp;nbsp; So, I never get the centroids within the parcels, but it does help with the weird triangles from the first (zoomed-out) picture.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Jun 2015 21:29:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/getcentroid-of-selected-feature-layer-scale/m-p/511926#M47707</guid>
      <dc:creator>ShawnaErnst</dc:creator>
      <dc:date>2015-06-22T21:29:05Z</dc:date>
    </item>
    <item>
      <title>Re: GetCentroid of selected feature layer, scale-dependent issue, Javascript API</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/getcentroid-of-selected-feature-layer-scale/m-p/511927#M47708</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;For everyone following this...I submitted a support ticket to ESRI and they came back with the suggestion that I change&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;var parcelCentroid = graphic.geometry.getCentroid()&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;to:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;var parcelCentroid = graphic.geometry.getExtent().getCenter();&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;They gave the following reason:&amp;nbsp; "The geometries can be complex at times, may be self intersecting and essentially depends on the pointcollection and rings used to create the polygon. So generally the approach is to generalize or simplify the geometry. You could use the above line instead of getcentroid() method.&amp;nbsp; I have tested it on my end and is working for me."&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I didn't go with this approach initially because I was concerned that the center of the extent won't always be located within the polygon boundary.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I may end up creating parcel points and just selecting those.&amp;nbsp; I'd prefer to do it in code, but I want to make sure what I've got is accurate.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 Jun 2015 14:15:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/getcentroid-of-selected-feature-layer-scale/m-p/511927#M47708</guid>
      <dc:creator>ShawnaErnst</dc:creator>
      <dc:date>2015-06-24T14:15:31Z</dc:date>
    </item>
  </channel>
</rss>

