# Distance shown

Map Top achievements Rank 1
Richard asked on 21 Jan 2014, 07:26 PM
Is there a way to find out the scale of the map? For instance how many miles across the map as shown.

Thanks.

## 2 Answers, 1 is accepted

0
Accepted T. Tsonev
Telerik team answered on 22 Jan 2014, 02:27 PM
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
0 Richard
Top achievements Rank 1
answered on 22 Jan 2014, 03:07 PM
That is awesome. Thanks that was more than I expected. Also showed me a few things on I didn't know about Kendo Map.

Rich.
Tags
Map Richard
Top achievements Rank 1    Rank 1