Created
December 1, 2017 22:52
-
-
Save digitalhydra/6577405afb5166e35ce6d3a7eb1ce996 to your computer and use it in GitHub Desktop.
get center of polygon in google maps
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 bounds = new google.maps.LatLngBounds(); | |
var i; | |
// The Bermuda Triangle | |
var polygonCoords = [ | |
new google.maps.LatLng(25.774252, -80.190262), | |
new google.maps.LatLng(18.466465, -66.118292), | |
new google.maps.LatLng(32.321384, -64.757370), | |
new google.maps.LatLng(25.774252, -80.190262) | |
]; | |
for (i = 0; i < polygonCoords.length; i++) { | |
bounds.extend(polygonCoords[i]); | |
} | |
// The Center of the Bermuda Triangle - (25.3939245, -72.473816) | |
console.log(bounds.getCenter()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment