This section describes how to calculate the linear distance between two points based on their longitudes and latitudes.
Procedure
- Initialize the HWDistanceCalculator object through HWMapJsSDK.
- Call the computeDistanceBetween method through the HWDistanceCalculator object, and pass the longitudes and latitude of two points and (optional) sphere radius.
- View the return value, which is the linear distance between the two points, in meters.
Sample Code
var DistanceClass = new HWMapJsSDK.HWDistanceCalculator();
var fromPostion = {lng: 2.35, lat: 48.85};
var toPosition = {lng: 2.33, lat: 48.75};
var distance = DistanceClass.computeDistanceBetween(fromPostion, toPosition);