var distParams = new esri.tasks.DistanceParameters(); distParams.distanceUnit = esri.tasks.GeometryService.UNIT_STATUTE_MILE; distParams.geometry1 = pointA; //<--- your Point A geometry distParams.geometry2 = pointB; //<--- your Point B geometry distParams.geodesic = true;
geometryService.distance(distParams, function(distance) { // Do what you want with the result. }); });
Alex,I think if you take a close look at the first page swingley pointed out (http://help.arcgis.com/en/webapi/javascript/arcgis/help/jssamples_start.htm#jssamples/util_distance.html), you'll see some code that shows how to set up the parameters for a call to the GeometryService's distance task. It shows how to add geometries from an array. In your case, you'd add your two known points: var distParams = new esri.tasks.DistanceParameters(); distParams.distanceUnit = esri.tasks.GeometryService.UNIT_STATUTE_MILE; distParams.geometry1 = pointA; //<--- your Point A geometry distParams.geometry2 = pointB; //<--- your Point B geometry distParams.geodesic = true; The sample code on the page shows how to call GeometryService.distance and work with its results. The section where it says function(distance){..}) catches the data returned by GeometryService.distance in the parameter distance. geometryService.distance(distParams, function(distance) { // Do what you want with the result. }); }); Hope that helps,Tim
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.