ol-ext
Version:
A set of cool extensions for OpenLayers (ol) in node modules structure
17 lines (13 loc) • 427 B
JavaScript
/* global ol */
/* Create ol.sphere for backward compatibility with ol < 5.0
* To use with Openlayers package
*/
if (window.ol && !ol.sphere) {
ol.sphere = {};
ol.sphere.getDistance = function (c1, c2, radius) {
var sphere = new ol.Sphere(radius || 6371008.8);
return sphere.haversineDistance(c1, c2);
}
ol.sphere.getArea = ol.Sphere.getArea;
ol.sphere.getLength = ol.Sphere.getLength;
}