目录

Calculating the Distance

This section describes how to calculate the linear distance between two points based on their longitudes and latitudes.

Procedure

  1. Initialize the HWDistanceCalculator object through HWMapJsSDK.
  2. Call the computeDistanceBetween method through the HWDistanceCalculator object, and pass the longitudes and latitude of two points and (optional) sphere radius.
  3. 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);