Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

google maps. how to create a LatLngBounds rectangle (square) given coords of a central point

I have a point (X,Y) and I want to create a square , Google maps LatLngBounds object so to make geocode requests bias only into this LatLngBound region.

How can I create such a LatLngBounds square with center the given point? I have to find the NE and SW point. But how can I find it given a distance d and a point (x,y)?

Thanks

like image 274
maiky Avatar asked Apr 19 '11 11:04

maiky


1 Answers

You can also getBounds from a radius defined as a circle and leave the trig to google.

new google.maps.Circle({center: latLng, radius: radius}).getBounds();

like image 91
wprater Avatar answered Sep 27 '22 23:09

wprater