How do I get a bounding box from a single Cartesian coordinate?

I am trying to get bounding box coordinates in javascript from just one coordinate (latitude, longitude), then I could use it as a viewbox in OSN Nominatin API .

For a red dot, how to get green dots for any region / country on the planet ? (For example, the difference is 0.15):

enter image description here

for (x,y) will be: (x-2,y+2), (x+2,y-2)?


function get_bounce(lat, lng) { // y,x
    // x-0.15,y+0.15
    //          x,y
    //               x+0.15,y-0.15
    var lng1 = lng - 0.15;
    var lat1 = lat + 0.15;
    var lng2 = lng + 0.15;
    var lat2 = lat - 0.15;
    return [lat1,lng1,lat2,lng2];
}

      

Thanks in advance!

+3


source to share





All Articles