尝试将 waypoints 与 JavaScript API 一起使用

Trying to use waypoints with JavaScript API

我是 MapHere 的新手,我看到在 REST API 方面我可以指定 waipoints 但我不能用 JavaScript,我尝试了一些参数,比如 'via' 但是只承认一分:

var routingParameters = {
  'routingMode': 'fast',
  'transportMode': 'car',
  // The start point of the route:
  'origin': '36.8414197,-2.4628135',
  'via': '37.9923795,-1.1305431',
  // The end point of the route:
  'destination': '40.4167047,-3.7035825',
  // Include the route shape in the response
  'return': 'polyline'
};

我在 javascript 网站的主页上看到了一个示例,但我不能使用 waypoints:

var router = platform.getRoutingService(),
  routeRequestParams = {
    mode: 'fastest;car',
    representation: 'display',
    routeattributes: 'waypoints,summary,shape,legs',
    maneuverattributes: 'direction,action',
    waypoint0: '52.5160,13.3779', // Brandenburg Gate
    waypoint1: '52.5206,13.3862'  // Friedrichstraße Railway Station
};

抛出以下错误:

{"title":"Malformed request","status":400,"code":"E605001","cause":"Error while parsing request: 'origin' parameter is required\n","action":"","correlationId":"1c7bd525-b8af-4989-83a9-ab07f26a8c33"}

那么,我该如何发送使用请求waypoints?

编辑

我看到了问题,当 .js 创建 url 编码第二个 &via=

https://router.hereapi.com/v8/routes?xnlp=CL_JSMv3.1.18.1&apikey=***&routingMode=fast&transportMode=car&origin=50.1120%2C8.6834&destination=52.5309%2C13.3846&via=50.1234%2C8.7654%26via%3D51.2234%2C9.1123&return=polyline

如果我解码 & 并且 = 工作完美

https://router.hereapi.com/v8/routes?xnlp=CL_JSMv3.1.18.1&apikey=***&routingMode=fast&transportMode=car&origin=50.1120%2C8.6834&destination=52.5309%2C13.3846&via=50.1234%2C8.7654&via=51.2234%2C9.1123&return=polyline

JavaScript API 尚不支持(自库版本 3.1.18.1 起)支持传递多个 waypoints,这意味着将点数组传递给 via范围。解决这种缺乏支持的最好办法是直接使用 Routing REST API:

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}