Here Maps Routing API V8 - 多个路径点

2024-01-16

我对 Here Maps Routing API v8 非常陌生。

我已经尝试过这里提供的示例:https://developer.here.com/documentation/maps/3.1.15.1/dev_guide/topics/routing.html https://developer.here.com/documentation/maps/3.1.15.1/dev_guide/topics/routing.html

我使用的路由参数如下所示:

var routingParameters = {
  'routingMode': 'fast',
  'transportMode': 'car',
  'origin': '50.1120,8.6834',
  'destination': '52.5309,13.3846',
  'return': 'polyline'
};

现在我想在路由参数中添加多个航路点,并且我尝试了以下格式:

'via' : ['50.1234,8.7654', '51.2234,9.1123']

但是当我在路由参数中使用上述行时,请求失败。

您能否建议具有多个航点的请求的正确格式?


检查您正在使用的 HERE Maps JS API 的版本。从版本 3.1.19.0 开始支持此功能。

因此,计算具有多个航点的路线的方法是:

// departure point (origin)
var start = '52.550464,13.384223';

// collection of waypoints
var waypoints = [
  '52.529791,13.401389'
  '52.513079,13.424392'
  '52.487581,13.425079'
];

// end point (destination)
var end = '52.477545,13.447395'

// routing parameters
var routingParameters = {
  'origin': start,
  'destination': end,
  'via': new H.service.Url.MultiValueQueryParameter( waypoints ),

  'routingMode': 'fast',
  'transportMode': 'car',

  'return': 'polyline'
};

// Get an instance of the routing service version 8:
var router = platform.getRoutingService(null, 8);

// Call `calculateRoute` with the routing parameters,
// the success callback and an error callback function
// The implementation of the two callback functions is left out for brevity
// see documentation link below for callback examples
router.calculateRoute(routingParameters, onResultCallback, onErrorCallback)

使用 HERE Maps JS API 计算路线:文档 https://developer.here.com/documentation/maps/3.1.22.0/dev_guide/topics/routing.html

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Here Maps Routing API V8 - 多个路径点 的相关文章

随机推荐