3

我可以在api.map.baidu上计算方向(json):http ://api.map.baidu.com/direction?destination=39.988710,116.432340&origin=39.940488,116.355425&mode=driving&coord_type=wgs84

如何在https://map.baidu.com/上形成相似的 url 以在地图上显示相同的方向

在此处输入图像描述

我想在我的应用程序中生成在map.baidu.com上加载路线的 url ,但很难猜测 url,因为我找到的网站和文档都是中文的。

4

2 回答 2

5

通过反复试验,我能够让它使用以下模式:

http://api.map.baidu.com/direction?origin=latlng:39.940488,116.355425|name:origin&destination=latlng:39.988710,116.432340|name:destination&mode=driving&region=none&output=html

它与您所拥有的差异包括:

  • 为每组坐标加上前缀latlng:
  • 附加|name:(point name)到每组坐标,这里不放东西是行不通的
  • 提供output=html参数
于 2019-02-05T20:38:22.827 回答
0

这是来自百度地图的API文档https://lbsyun.baidu.com/index.php?title=uri/api/web#service-page-anchor5

2.2.3 公交、自驾、步行路线规划

服务地址

http://api.map.baidu.com/direction //PC&Webapp service address

例子

http://api.map.baidu.com/direction?origin=latlng:34.264642646862,108.95108518068|name:My home&destination=Great Wild Goose Pagoda&mode=driving&region=Xi'an&output=html&src=webapp.baidu.openAPIdemo

//Call up Baidu PC or Web map to show the driving directions of "Xi'an" from (lat: 34.264642646862, lng: 108.95108518068) "My home" to "Dayan Tower".
于 2020-07-10T09:21:35.883 回答