如何在MapquestApi中请求带有航点(多个位置)的方向?

时间:2012-11-29 18:02:19

标签: google-maps map mapquest

我使用谷歌地图并做了类似的事情,我只需要添加参数WayPoints:

http://maps.googleapis.com/maps/api/directions/xml?origin=18.4543467001058,-69.9294914999045&destination=18.4804850999499,-69.932457299903&sensor=false&alternatives=true&航点= 18.4543467001058,-69.9294914999045 | 18.4543467001058,-69.9294914999045 | 18.4779706000118,-69.9026079000905 | 18.4794135999982,-69.8832237999886 |

但现在我想使用MapQuest,我无法弄清楚如何去做。

我尝试在Location参数中添加它们,但它不起作用:

http://open.mapquestapi.com/directions/v0/route?callback=renderAdvancedNarrative&outFormat=xml&routeType=shortest&timeType=1&narrativeType=html&enhancedNarrative=false&shapeFormat=raw&generalize=200&locale=en_US&unit=k&from=18.4574500999879,-69.9374951999635&to=18.4739507000195,-69.9658190000337&drivingStyle=2&highwayEfficiency=21.0&位置= 18.4574500999879,-69.9374951999635 | 18.4574500999879,-69.9374951999635 | 18.4574500999879,-69.9374951999635 | 18.4641813000198,-69.937076299917 | 18.4801647000131,-69.9080942999572 | 18.4934515000205,-69.9272894002497 |

你能帮我解决这个问题吗?

1 个答案:

答案 0 :(得分:2)

使用MapQuest Open Directions API时,您需要沿着这样的路线指定多个停靠点,没有管道 - 并使用“& to = ...”在& from =和之间添加多个停靠点最终目的地:

http://open.mapquestapi.com/directions/v1/route?key=YOUR-KEY-HERE&outFormat=xml&routeType=shortest&enhancedNarrative=false&locale=en_US&unit=m&drivingStyle=2&highwayEfficiency=21.0&from=39.750560,-104.999388&to=39.745940,-104.985805&to=39.734952,-104.989947

API还接受JSON和XML输入以及键/值对。

不要忘记注册免费的应用程序密钥!