Note that there are some explanatory texts on larger screens.

plurals
  1. POGetting JSON for OSRM routing
    text
    copied!<p>I successfully implemented a routing system into my website using the cloudmade API. I also want to do the same with the OSRM routing system (<a href="https://github.com/DennisOSRM/Project-OSRM" rel="nofollow">https://github.com/DennisOSRM/Project-OSRM</a>) but I'm having some trouble getting the OSRM json output.</p> <p>Here are examples of retrieving json from the cloudmade API:</p> <p>Using $.ajax - <a href="http://jsfiddle.net/mayooresan/FhfVW/2/" rel="nofollow">http://jsfiddle.net/mayooresan/FhfVW/2/</a></p> <pre><code>$(function () { $("#getJSON").click(function () { var url = "http://routes.cloudmade.com/c6f2762bfe00414f822a9dec443569f5/api/0.3/51.500,0.100,51.500,0.1001/car.js"; $.ajax({ async: false, dataType: "jsonp", url: url, success: function (data) { test = data.route_geometry; alert(test); } }); }); }); </code></pre> <p>Using $.getJSON - <a href="http://jsfiddle.net/V3qgZ/72/" rel="nofollow">http://jsfiddle.net/V3qgZ/72/</a></p> <pre><code>$(function () { $("#getJSON").click(function () { $.getJSON("http://routes.cloudmade.com/c6f2762bfe00414f822a9dec443569f5/api/0.3/51.500,0.100,51.500,0.1001/car.js?callback=?", function (data) { var test = data.route_geometry; alert(test); }); }); }); </code></pre> <p>The server API for OSRM is located here: <a href="https://github.com/DennisOSRM/Project-OSRM/wiki/Server-api" rel="nofollow">https://github.com/DennisOSRM/Project-OSRM/wiki/Server-api</a> (The server location for queries is located at <a href="http://router.project-osrm.org" rel="nofollow">http://router.project-osrm.org</a>). </p> <p>Putting the url with the same coordinates used above (<a href="http://router.project-osrm.org/viaroute?loc=51.500,0.100&amp;loc=51.500,0.1001" rel="nofollow">http://router.project-osrm.org/viaroute?loc=51.500,0.100&amp;loc=51.500,0.1001</a>) into the browser retrieves a json file. But no matter what I have tried using this with $.getJSON or $.ajax - using callbacks, setting datatypes, I cannot get the json data and it is driving me nuts! And I'm sure it's possible because it is documented in the API.</p> <p>Any help is much much appreciated.</p> <p>Nick</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload