Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
draw point in some distance betwen two geo points lat/lon
_calculateOffset: function(bearing_angle, radius){
//Calculate destination point based on bearing and distance
var d2r = L.LatLng.DEG_TO_RAD; //simple convert do radians
var r2d= L.LatLng.RAD_TO_DEG; //simple convert to degrees
var radius = radius/1500;
var lat = * d2r;
var lng = this._latlng.lng * d2r;
var angle = bearing_angle * d2r;
var R = 6372.795477598;
var distance = (radius/R);
var lat2 = Math.asin( Math.sin(lat)*Math.cos(distance) +
Math.cos(lat)*Math.sin(distance) * Math.cos(angle));
var lon2 = lng + Math.atan2(Math.sin(angle)*Math.sin(distance)*Math.cos(lat),
return new L.latLng(lat2 * r2d,lon2 * r2d);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment