Question

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.

Was it helpful?

Solution

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:

  • origin The starting location.
  • destination The destination.
  • sensor Is the request for a device that can sense location?

And the parameters for a German search (optional):

  • region=de Give Google Maps an idea of where in the world to search by passing in the German top level domain code.
  • language=de Tell Google Maps to return directions in German (See available languages)

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:

  • wayPoint.1 The starting location.
  • wayPoint.2 The destination (Note how you can easily add more waypoints).
  • key Insert your Bing Map API key here.

Optional Params:

  • culture=de-DE The culture parameter gives Bing an idea of where to search and what to return.

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top