How to find distance between to points (long,lat) in arcGis Javascript 3.16?

1840
5
06-14-2017 03:02 AM
FancyAugustin
New Contributor II

I want to find radius of circle,i got x min and x max,

My logic is to find difference and divide that by two to get radius?

Can i know how to find distance between to coordinates?

0 Kudos
5 Replies
MirHashmi
Occasional Contributor

Hi. This question should have been posted here in Javascript api forum.  However, in order to find distance between two coordinates in Api 3.16, a function called as distance could be used from Geometry Service. 

0 Kudos
FancyAugustin
New Contributor II

Thanks for your reply,

I am new to arcgis api,Could you please tell me how can i get Geometry Service.Is this any paid service? If not how it is used for finding distance?

0 Kudos
Nicholas-Furness
Esri Regular Contributor

There is a free Geometry Service, but in many cases now you do not need it since the 3.x geometryEngine and 4.x geometryEngine can do much of the work in the browser. It's quicker that way and doesn't require a network request.

If you still need functionality of the GeometryService, you can find a reference to a hosted GeometryService in the documentation for the GeometryService task (3.x, 4.x). However, I recommend using the geometryEngine where possible.

P.S. I'll see if we can get this thread moved to the JS API forum.

ChrisCatania
Esri Community Team

Hi Fancy - Thanks for asking your questions and welcome to the GeoNet community! I wanted to let you know that we're moving your question to the ArcGIS API for JavaScript space so our Esri and user subject matter experts can further help answer this and future questions.  So you're aware on how and where to post your questions, here's a few quick tips and reminders:

  • First, use the GeoNet search (top right corner by your profile icon) to search and see if your question has already by asked/answered previously.

 

Thanks again for contributing and I hope this helps and let us know if you have any questions.

Esri Community Strategist
ThomasSolow
Occasional Contributor III

You could find the difference between xmin and xmax and divide by 2.  If you convert xmin and xmax to web mercator, this will the radius in meters.  This will be the planar distance.

If you want to find the geodesic distance, you could create a polyline with two points and use geometryEngine.length(<polyline geometry>).