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 latA = rad(a.lat);
var latB = rad(b.lat);
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);