Created
August 4, 2013 13:31
-
-
Save stiucsib86/6150321 to your computer and use it in GitHub Desktop.
[Google Maps v3] Get Rectangle area with computeArea
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you.