Route Via Intermediate Waypoint - 通过参数传递坐标列表

Route Via Intermediate Waypoint - Passing a list of coordinates in via parameter

我需要通过参数在中传递参数内的坐标列表,但我找不到方法。这是一个只有一对坐标(纬度,经度)的例子:

function calculateRoute (platform) {
  var router = platform.getRoutingService(null, 8),
    routeRequestParams = {
      routingMode: 'fast',
      transportMode: 'truck',
      origin: '36.87689,-2.44138',
      destination: '36.69630,-4.47968',
      via: '38.99112,-1.86902', //LIST HERE!!!
      return: 'polyline'
    };

  router.calculateRoute(
    routeRequestParams,
    onSuccessRoute,
    onError
  );
}

我希望得到的url是这样的:

https://router.hereapi.com/v8/routes?apikey=
{API_KEY}&routingMode=fast&transportMode=truck&origin=36.87689,-2.44138&via=38.99112,-1.86902&via=37.95862,-1.15538&destination=36.69630,-4.47968&return=polyline

如您所见,via 在 URL 中重复。

非常感谢!

不知道对你有没有帮助,但是

function calculateRouteFromAtoB (platform) {
  var router = platform.getRoutingService(),
      routeRequestParams = {
      mode: 'fastest;car',
      representation: 'display',
      routeattributes : 'waypoints,summary,shape,legs',
      maneuverattributes: 'direction,action',
      waypoint0: '55.7520,37.6175',
      waypoint1: '55.8941,37.4439',
      waypoint2: '55.7982,37.9680'
      };
  router.calculateRoute(
      routeRequestParams,
      onSuccess,
      onError
  );
}

适合我。

关于 Routing v8 API,JavaScript API(还)不支持多路由 waypoints,也就是说,它不支持传递列表via 参数的坐标。

所以最好的办法是直接以 Routing v8 REST API 为目标,就像关注一样,并从响应中构建折线:

# Note: line breaks and spaces are for readability only (they need to be removed)

https://router.hereapi.com/v8/routes?
  origin=52.550464,13.384223
  &transportMode=car
  &destination=52.477545,13.447395
  &via=52.529791,13.401389
  &via=52.513079,13.424392
  &via=52.487581,13.425079
  &apikey={YOUR_API_KEY}