# Distance shown

##### Richard
22 posts
Member since:
Feb 2012

Posted 21 Jan 2014 Link to this post

Is there a way to find out the scale of the map? For instance how many miles across the map as shown.

Thanks.
##### Richard
22 posts
Member since:
Feb 2012

Posted 22 Jan 2014 Link to this post

Hello,

The map extent() method gives us the outermost north-west and south-east locations. This can be used to calculate the total distance and map scale (if the screen dpi is known).
This functionality will be readily available in future versions, but for now we need to make the calculations manually:

function distance(a, b) {
// See:
// http://en.wikipedia.org/wiki/Haversine_formula
// http://www.movable-type.co.uk/scripts/latlong.html

var R = 6371; // km
var dLat = rad(b.lat - a.lat);
var dLon = rad(b.lng - a.lng);

var h = Math.sin(dLat/2) * Math.sin(dLat/2) +
Math.sin(dLon/2) * Math.sin(dLon/2) * Math.cos(latA) * Math.cos(latB);
var c = 2 * Math.atan2(Math.sqrt(h), Math.sqrt(1-h));
var d = R * c;

return d;
}

function printScale(map) {
var map = \$("#map").data("kendoMap");
var extent = map.extent();
var nw = extent.nw;
var ne = new Location(nw.lat, extent.se.lng);

\$("#status").html(kendo.format("E-W: {0:N0} m", distance(nw, ne)));
}

Live demo

I hope this helps.

Regards,
T. Tsonev
Telerik