Skip to content

Instantly share code, notes, and snippets.

@noushad-pp
Created January 24, 2018 16:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save noushad-pp/fdac7b1d7e4f18a5b5c5e4b08854008b to your computer and use it in GitHub Desktop.
Save noushad-pp/fdac7b1d7e4f18a5b5c5e4b08854008b to your computer and use it in GitHub Desktop.
calculate the bounds of a map manually given a center and a radius
// formula to find the South west and North East points from lat,lon between x kms in radius.
let center = {
lat: 73.1232145,
lng: 221.1234567
};
let radius = 10;
let lat_change = radius/111;
let lon_change = Math.abs(Math.cos(center.lat *(Math.PI/180)));
let sw_lat = center.lat - lat_change;
let sw_lon = center.lng - lon_change;
let ne_lat = center.lat + lat_change;
let ne_lon = center.lng + lon_change
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment