Created
January 24, 2018 16:39
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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