Hi, I am use @arcgis/core package in Angular framework.
I want to calculate distance between 2 points by lat and lng of each point using this package.
I guess that i need something like described in this link. But i don't know how to convert this to the ESM approach.
I guess that i need to import the packages like below, but i don't know how to continue from there.
Any help will be appreciated.
Note that i have no need to draw Map. I need just the calculation.
You can use the geometry engine for this, no need to go to the service.
Here's a sample where it's dynamically imported and used.
https://github.com/odoe/nearby-app-vanilla/blob/main/src/app.ts#L50-L71
First of all, thank you very much for your response!
Actually, I need to calculate a distance of driving or walking (routing).
From what I understand, the distance function calculates Planar distance.
I'm sorry I didn't explain it in advance properly
After more searching, i find out this page witch seems to fit what i need.
I just don't understand what it is the:
portalItem: { id: "69569b47b1e445b8a42ec12feab41ce9" }
I try to replace this to list of stops (that this what i actually need) like this:
The portalItem id is the item in Portal for ArcGIS that is the routeLayer, which looks as though you can create it from stops.
// A minimum of two stops is required for routing.
const stops = [
new Stop({ geometry: { latitude: 32.180763, longitude: 34.929558 } }),
new Stop({ geometry: { latitude: 31.9339, longitude: 34.8878 } })
];
// Create route layer and assign the stops. Only solved routelayers will be rendered.
const routeLayer = new RouteLayer({
stops
});
Once you create the route layer, you need to call the solve method to get your route and features
https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-RouteLayer.html#solve
Then you can get the routeInfo and it will have a totalDistance value you can use