Area of a Rectangle

1,400 views
Skip to first unread message

Anthony D

unread,
Jun 12, 2012, 6:16:36 PM6/12/12
to Google Maps JavaScript API v3
Good Evening

What's the best way to calculate the area of a rectangle created with
the Google map api Drawing Manager?

http://www.yarvolgar.com/shapes/editShapes.html

geoco...@gmail.com

unread,
Jun 14, 2012, 1:09:13 AM6/14/12
to Google Maps JavaScript API v3
On Jun 12, 3:16 pm, Anthony D <derbaha.dh...@gmail.com> wrote:
> Good Evening
>
> What's the best way to calculate the area of a rectangle created with
> the Google map api Drawing Manager?

A rectangle is a four sided polygon. You should be able to do it the
same way as you do it for polygons. You will need to calculate the
path (the four corners).

-- Larry

>
> http://www.yarvolgar.com/shapes/editShapes.html

Rossko

unread,
Jun 14, 2012, 5:01:06 AM6/14/12
to Google Maps JavaScript API v3
If the rectangle is large, you may need to account for the curvature
of the earth - do you want the area of the surface or the imaginary
plane rectangle?

Anthony D

unread,
Jun 14, 2012, 2:33:16 PM6/14/12
to google-map...@googlegroups.com
Based upon the method used in my site to calculate polygons using the geometry library: 

 polygonArea = google.maps.geometry.spherical.computeArea(mapPolygon.getPath());

There is no "getPath()" method for the google.maps.Rectangle class to find the path of the rectangle drawn with the Drawing Manager.

Barry Hunter

unread,
Jun 14, 2012, 2:44:50 PM6/14/12
to google-map...@googlegroups.com
>
> There is no "getPath()" method for the google.maps.Rectangle class to find
> the path of the rectangle drawn with the Drawing Manager.

No. But pretty trival it make one yourself.

Get the bounds, from that get coordinates of opposing corners. Use
them to build a new circular path.
Reply all
Reply to author
Forward
0 new messages