此处映射路由API V8-多个航路点 [英] Here Maps Routing API V8 - mutiple waypoints

查看:71
本文介绍了此处映射路由API V8-多个航路点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am very new to the Here Maps Routing API v8.

我尝试了此处提供的示例: https://developer.here.com/documentation/maps/3.1.15.1/dev_guide/topics/routing.html

I have tried the example provided here: https://developer.here.com/documentation/maps/3.1.15.1/dev_guide/topics/routing.html

我使用了如下所示的routingParameters:

I have used the routingParameters as shown below:

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

现在,我想在routingParameters中添加多个航路点,并尝试使用以下格式:

Now I want to add multiple waypoints in the routingParameters and I tried the below format for the same:

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

但是当我在routingParameters中使用以上代码时,请求失败.

But the request is failing when I use the above line in the routingParameters.

能否请您提出带有多个航路点的请求的正确格式?

Can you please suggest the correct format of the request with multiple waypoints ?

推荐答案

通过将数组传递给via参数,您尝试的方法应该是传递多个航点的正确方法,但是似乎尚不支持.路由v8是最新的API,我遇到了同样的问题.

The way you tried, by passing an array to the via parameter, should be the proper way to pass multiple waypoints, however it appears not supported yet. Routing v8 is a recent API, I had the same issue.

同时,我建议直接调用Routing v8 REST API,并在响应中构建一条折线.

In the meantime I would advise to call the Routing v8 REST API directly, and build a polyline out of the response.

为了将多个航路点传递到Routing v8 REST API,您需要添加具有航路点的次数via={lat},{lng}次,如下所示:

In order to pass multiple waypoints to the Routing v8 REST API, you need to add as many times via={lat},{lng} as you have waypoints, like below:

# 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}

注意:有 一种将多个via传递给JS API的方法,但这很丑陋,并且在将来的发行版中可能会中断,因此我不建议这样做:) :

Note: there is one way to pass multiple via to the JS API, but that is ugly and it might break in future releases, so I would not advise it :) For the record:

var routingParameters = {
  'routingMode': 'fast',
  'transportMode': 'car',
  'origin': '50.1120,8.6834',
  'destination': '52.5309,13.3846',
  'via': '50.1234,8.7654&via=51.2234,9.1123',
  'return': 'polyline'
};

这篇关于此处映射路由API V8-多个航路点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆