AnsweredAssumed Answered

GetCentroid of selected feature layer, scale-dependent issue, Javascript API

Question asked by sernst on Jun 20, 2015
Latest reply on Jun 24, 2015 by sernst

I've written some code based on this ESRI sample:  Feature Layer with Selection

 

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.

 

Here's the function that runs after the user has already selected their property boundaries (wired to a button click):

Capture.JPG

 

And here's the issue...depending on my zoom-level at the time of selection, I get vastly different results.

 

When selecting parcels while zoomed-out, centroids look correct, but selection graphics become triangles:

OddGeometry1.JPG

 

Mid-zoom selection produces these results, which appear correctly:

OddGeometry2.JPG

 

When selecting while zoomed-in closely, I get wildly inaccurate centroids.

OddGeometry3.JPG

 

It's obvious that I have something wrong, but I'm not sure what...  I'm new at JavaScript, so I'm guessing that I haven't accounted for something in the way the graphics work.

 

Any help would be much appreciated!

 

Message was edited by: Shawna Ernst Added attachment with the full code (service names removed).

Attachments

Outcomes