In googlemaps api v2 I have one marker on map and i need to calculate a bounding box around this one. How would I get a bonding box of 5 by 5 kilometers of which this marker is the center?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I’m not sure that such a functionality is provided by google map, but math will help you to survive 😉 Calculate distance, bearing and more between Latitude/Longitude points is a great reference to different calculations with geographic data. Open that page, and go to “Destination point given distance and bearing from start point” part, there are formulas, as well as online calculator, so you can check them (as well as you can see points on the map). Formula has few parameters:
to find bound you need to find coordinates of south, north, east and west rectangle sides, so everything you will change in parameters is angle, and in your case it will be 0, 90, 180 and 270 grads. Formulas:
Well, specifying angle = 0 you find north, PI/2 – east, PI – south, 3*PI/2 – west (angles should be passed in radians).
ADD-ON: just looked at the source code of that page, because when I enter in online form bearing = 0, distance = 2 then I see map with two points and according to the map scale the distance between them is really 2km. Well, you can use this library under a simple attribution license, without any warranty express or implied, just include it
Function you need is:
and when I enter in online form bearing = 0, distance = 2, this method is executed with arguments
latLonCalc.destinationPoint( 0, "2" );try it, otherwise give me input parameters so I could check what’s wrong
UPDATE2 that library works with grads,and converts them to radians for calculations and then back to grads. Just performed simple test:
so the distance between entry point and final destination is a bit more than 1 minute;
it was round calculation, which tells me that final point is not far away then entry point, and distance should be 2km 😉