AnsweredAssumed Answered

How to Calculate Distance Between Two Give Points

Question asked by behClevest on Dec 12, 2017
Latest reply on Dec 12, 2017 by rscheitlin

Using ArcGIS API for JavaScript 3.22 and having two given Points as

 

var pt1 = new Point(-106.61, 35.1107, new SpatialReference({ wkid: 4326 }));
var pt2 = new Point(-108.61, 35.1107, new SpatialReference({ wkid: 4326 }));

can you please let me know how I can calculate the distance from `pt1 to `pt2`?

 

var map;
require([
"esri/map",
"esri/geometry/Point",
"esri/SpatialReference",
"esri/geometry/webMercatorUtils",
"dojo/domReady!"
], function(Map, Point, SpatialReference, webMercatorUtils) {
map = new Map("map", {
basemap: "topo",
center: [-106.61, 35.1107],
zoom: 8
});
geometryService = new esri.tasks.GeometryService("https://utility.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer");
var pt1 = new Point(-106.61, 35.1107, new SpatialReference({
wkid: 4326
}));
var pt2 = new Point(-108.61, 35.1107, new SpatialReference({
wkid: 4326
}));
});

Outcomes