如何计算X城市到Y城市的路线? #地图
您如何计算两个城市之间的路线(对于汽车)?我只需要德国的主要城市。
输入:起始城市和结束城市
输出:起始城市,城市1,城市2,...,结束城市
当我查看Google地图时,我发现此处的信息。所以这是有据可查的。 我发现有一些限制:每天 2500 个调用。您需要显示图形。那很糟糕。
但是当我查看 openstreetmap 或 bing 地图时,我找不到相关信息。你能帮我一下吗?还有类似的服务吗?
更新:我用 Java 创建了自己的自定义路由引擎。尽管这里的这个单一要求并不是主要原因。
How would you calculate the route between two cities (for cars)? I only need the major cities in Germany.
Input: Start-city and end-city
Output: Start-city, city1, city2, ..., End-city
When I'm looking into Google Maps I found the infos here. So it's well documented.
I see some limitation: 2500 calls per day. You need to display the graphics. That's bad.
But when I'm looking at openstreetmap or bing maps I cannot find the relevant information. Could you help me here? And are there similar services?
Update: I've create my own custom routing engine in Java. Although this single requirement here wasn't the main reason.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我使用过 Google 和 Bing 地图 API。由于没有更多细节或要求,我只能提供一般信息。
Google 路线 API
Bing 路线计算
根据一些快速研究,我不相信 Open Street Map 具有本机方向 API。对于其他开放街道地图解决方案,请查看他们的 wiki(“您的”具体可能是兴趣)。
Google Directions API
对于 Google Directions API,两个德国城市之间的路线请求示例如下:http://maps.googleapis.com/maps/api/directions/json?region=de& language=de&origin=Berlin&destination=Hamburg&sensor=false
分解参数必需:
以及德语搜索的参数(可选):
根据需要修改此模板请求。
编辑
Bing 路由示例
Bing 要求您获取 API 密钥才能处理任何数据。
Bing 两个德国城市之间的路线请求示例:http://dev.virtualearth.net/REST/v1/Routes?wayPoint.1=柏林&waypoint.2=汉堡&culture=de-DE&key=YOUR_KEY_HERE< /a>
必需参数:
可选参数:
使用条款
按照 Google 和 Bing 地图 API 使用条款中,您必须显示一个图像,让用户知道您正在使用地图服务。
I have used both the Google and Bing Maps APIs. Without more details or requirements, I can only provide general information.
Google Directions API
Bing Route Calculation
Just from some quick research, I do not believe Open Street Map has a native directions API. For other Open Street Map solutions, look on their wiki ("YOURS" specifically may be of interest).
Google Directions API
For the Google Directions API, a sample request for directions between two German cities would look like : http://maps.googleapis.com/maps/api/directions/json?region=de&language=de&origin=Berlin&destination=Hamburg&sensor=false
Breaking down the parameters required:
And the parameters for a German search (optional):
Modify this template request as required.
edit
Bing Routing Example
Bing requires you to get an API key to work with any data.
A sample request for Bing for the routes between two german cities: http://dev.virtualearth.net/REST/v1/Routes?wayPoint.1=Berlin&waypoint.2=Hamburg&culture=de-DE&key=YOUR_KEY_HERE
Required Params:
Optional Params:
Terms of Use
Per the Google and Bing Maps API terms of use, you must display an image that lets users know you are using the mapping service.