Reputation: 1
I'm trying to setup up a basic OSRM / openlayers map.
I have been able to create an openlayers app with a map and some data. I have also compiled my own version of the OSRM server and tested it to return data.
I would now like to use it. And having searched around I see people asking complicated questions, but nowhere is there a basic example of how to use it. I have seen some of the websites that use it, but they usually minimize/obfuscate the code and it's difficult to get a basic idea of whats happening there.
The two main things I would like to do are:
Return a bike/walk route form the OSRM server, from what I understand the server only does car routes but in almost every live site I see they have walk and bike paths. How is this accomplished.
This should have been one probably. I need the most basic example of how to call the server function and then display it on the map.
I know I can create the URL call that's not a problem but it returns a .json file which I'm having trouble loading into my app. Apparently it accepts the the callback parameter but I'm not 100% sure what to do with it. Also the data comes back as an encoded and I'm having trouble with understanding the encoded polyline isssues.
So what I would like here is a basic example or a link to an existing one that does:
Upvotes: 0
Views: 4134
Reputation: 1833
If you want to provide a web-interface for a OSRM based routing service I would strongly suggest using a (customized) Project-OSRM-Web (the "official" UI found at http://osrm.at), or at least using the code as a reference of how to use the API.
routing profiles
You can customize what kind of routing OSRM does by specifying a speed-profile. Several example profiles can be found in the source code. As far as I know car and bicycle profiles are very well maintained.
OSRM doesn't support multiple routing profiles directly. If you want to provide multiple profiles, you have to run multiple instances of OSRM in parallel. OSRM-Web does support multiple servers.
Server API
Information about how to call the OSRM server API can be found on the OSRM-wiki. The route output format for example is encoded in the Encoded Polyline Algorithm Format.
Upvotes: 1