You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

HERE Routing API:如何在路径请求中规避多个多边形禁行区域?

如何在HERE Routing API v8请求中添加多个多边形禁行区域?

我看到过一篇文章提到路径请求最多可添加20个多边形禁行区域,单个多边形的请求能正常返回结果:

GET https://router.hereapi.com/v8/routes?origin=33.751305,-118.188812&destination=34.092232,-117.435051&transportMode=car&avoid[areas]=polygon:34.073334,-118.027496;33.888504,-117.813255;33.895847,-118.220070&apiKey={YOUR API KEY}

但我不知道怎么发起包含多个多边形的请求,试了几种方法都失败了:

  • 用分号分隔两个多边形,触发请求格式错误:
    GET https://router.hereapi.com/v8/routes?origin=33.751305,-118.188812&destination=34.092232,-117.435051&transportMode=car&avoid[areas]=polygon:34.073334,-118.027496;33.888504,-117.813255;33.895847,-118.220070;polygon:54.073334,-118.027496;53.888504,-117.813255;53.895847,-118.220070&apiKey={YOUR API KEY}
    
  • 用感叹号分隔两个多边形,触发请求格式错误:
    GET https://router.hereapi.com/v8/routes?origin=33.751305,-118.188812&destination=34.092232,-117.435051&transportMode=car&avoid[areas]=polygon:34.073334,-118.027496;33.888504,-117.813255;33.895847,-118.220070!polygon:54.073334,-118.027496;53.888504,-117.813255;53.895847,-118.220070&apiKey={YOUR API KEY}
    
  • 添加多个avoid[areas]参数,响应提示不支持多个该参数:
    GET https://router.hereapi.com/v8/routes?origin=33.751305,-118.188812&destination=34.092232,-117.435051&transportMode=car&avoid[areas]=polygon:34.073334,-118.027496;33.888504,-117.813255;33.895847,-118.220070&avoid[areas]=polygon:54.073334,-118.027496;53.888504,-117.813255;53.895847,-118.220070&apiKey={YOUR API KEY}
    

解决方案

在同一个avoid[areas]参数中,用**竖线|**分隔多个多边形即可,每个多边形保持polygon:开头、顶点用分号分隔的格式。示例请求如下:

GET https://router.hereapi.com/v8/routes?origin=33.751305,-118.188812&destination=34.092232,-117.435051&transportMode=car&avoid[areas]=polygon:34.073334,-118.027496;33.888504,-117.813255;33.895847,-118.220070|polygon:54.073334,-118.027496;53.888504,-117.813255;53.895847,-118.220070&apiKey={YOUR API KEY}

注意事项

  • 多边形顶点需按顺序定义(顺时针/逆时针均可),保证多边形闭合
  • 最多支持20个多边形,超出会返回参数错误
  • 若顶点数量较多,建议对URL做URL编码,避免特殊字符导致请求异常

内容的提问来源于stack exchange,提问作者Addict of Rice

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.26 03:15:00