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):
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:
Mid-zoom selection produces these results, which appear correctly:
When selecting while zoomed-in closely, I get wildly inaccurate centroids.
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).