3

I can calculate directions (json) on api.map.baidu with: http://api.map.baidu.com/direction?destination=39.988710,116.432340&origin=39.940488,116.355425&mode=driving&coord_type=wgs84

How to form similar url to display same directions over map on https://map.baidu.com/

enter image description here

I would like to generate urls in my app which load directions on map.baidu.com, but it is hard to guess url because website and documentation I found is on Chinese.

watbywbarif
  • 6,487
  • 8
  • 50
  • 64
  • 1
    I don't believe this can be done. If you use map.baidu.com to lookup directions, the url never changes. Which means the entire state of the app is held on the root url `/`. – Dylan Jan 31 '19 at 16:34
  • I have noticed that, but this does not guarantee that parameters in url are not used when provided. Although it makes is less likely :( – watbywbarif Feb 01 '19 at 09:56

2 Answers2

5

Through trial and error, I was able to get it to work with the following pattern:

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

The differences between it and what you had include:

  • Prefixing each set of coordinates with latlng:
  • Appending |name:(point name) to each set of coordinates, it will not work without putting something here
  • Providing the output=html parameter
cody
  • 11,045
  • 3
  • 21
  • 36
0

Here is the API document from baidu map https://lbsyun.baidu.com/index.php?title=uri/api/web#service-page-anchor5

2.2.3 Bus, driving and walking route planning

Service address

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

Examples

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".