Skip to content

Instantly share code, notes, and snippets.

@stiucsib86
Created August 4, 2013 13:31
Show Gist options
  • Save stiucsib86/6150321 to your computer and use it in GitHub Desktop.
Save stiucsib86/6150321 to your computer and use it in GitHub Desktop.
[Google Maps v3] Get Rectangle area with computeArea
var _computeRectangleArea = function(bounds) {
if (!bounds) {
return 0;
}
var sw = bounds.getSouthWest();
var ne = bounds.getNorthEast();
var southWest = new google.maps.LatLng(sw.lat(), sw.lng());
var northEast = new google.maps.LatLng(ne.lat(), ne.lng());
var southEast = new google.maps.LatLng(sw.lat(), ne.lng());
var northWest = new google.maps.LatLng(ne.lat(), sw.lng());
return google.maps.geometry.spherical.computeArea([northEast, northWest, southWest, southEast]) / (1000000);
};
@fcoramos
Copy link

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment