rectangles by area in square meters

366 views
Skip to first unread message

Aigars V

unread,
Jun 7, 2011, 11:45:00 AM6/7/11
to google-map...@googlegroups.com
 Hi.

I have data about  areas in square meters. I want to show this data on the map as moveable rectangles (all four edges  in the same length) .
Which is the best way to do that ? Is there something similar to circle's radius for rectangles (edge length, area  ...) ?

Rossko

unread,
Jun 7, 2011, 1:10:05 PM6/7/11
to Google Maps JavaScript API v3
> I have data about  areas in square meters. I want to show this data on the
> map as moveable rectangles (all four edges  in the same length) .

Isn't that a square?

> Which is the best way to do that ?

It's schoolbook geometry. For a given area, find the square root,
that gives the length of your sides.
To plot it on a map, you'd need some idea of where to put it.
Maybe you know the centre : then you can calculate the length of a
half-diagonal of your square. Then plot 4 points as a polygon at that
distance from your centre in NE SE SW NW directions, using the formula
for "Destination point given distance and bearing from start point"
formula at
http://www.movable-type.co.uk/scripts/latlong.html

Don't forget the visible distortion the map projection may cause for
large shapes.

> Is there something similar to circle's
> radius for rectangles (edge length, area  ...) ?

Don't think so

Esa

unread,
Jun 7, 2011, 4:18:35 PM6/7/11
to Google Maps JavaScript API v3

On Jun 7, 6:45 pm, Aigars V <aiga...@gmail.com> wrote:

> Is there something similar to circle's
> radius for rectangles (edge length, area  ...) ?


Well, you can use an instance of Circle as a tool to make the maths
for you.

1] Set a Circle with a desired center LatLng and radius in meters.
2] Get its bounds by getBounds() method
3] Construct a Rectangle using the bounds

var radius = Math.sqrt(yourArea) / 2;
var circle = new google.maps.Circle({center: yourPoint, radius:
radius});
var bounds = circle.getBounds();
var square = new google.maps.Rectangle({bounds: bounds, map:map});
Reply all
Reply to author
Forward
0 new messages