Get distance between two points using cloudmade

In my application I wanted to find distance between several points (latitude & longitude) which I had plotted on my leaflet map.

After searching for some time I found that coludmade provides service for finding distance & time between points.

Lets See how can we do this:

Bellow is my javascript

<script type="text/javascript">
var points = [];
function getDistanceTime()
		points = [
		    [51.49346, -0.11518],
		    [51.50949, -0.1363]
	 var addScriptString = ""+points[0][0] +","+points[0][1]+","+points[1][0]+","+points[1][1]+"/car/shortest.js?units=km";

            async: false,
            dataType: "jsonp",
            url: addScriptString,
            success: function (response) {
	 var distanceKms = Math.round(response.route_summary.total_distance * 100.0 / 1000) / 100;
     var timeMin = Math.round(response.route_summary.total_time * 100.0 / 60) / 100;
     alert("Distance : "+ distanceKms +" & Time : "+ timeMin);

In getDistanceTime() function I am creating url string for service & calling it using ajax.

<input type="button" value="Get Shortest Distance" id="btnDis" onclick="getDistanceTime()" />

On click of this button service will be called & in response we will get shortest distance between two points.

Demo :

Here I have found shortest distance in kms traveling by “car”.We can also find traveling by “foot” or “bicycle” also.We can also find distance between two points via come mid points

Demo :

More Details of this service can be found on