Created
October 21, 2015 07:08
-
-
Save camille-hdl/82cb776ce98e81fbc713 to your computer and use it in GitHub Desktop.
Google maps API : get polygon bounds
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
/** | |
* Recupere les limites d'un polygone | |
* | |
* @method getPolygonBounds | |
* @param {Object} polygon un `polygon` gmap | |
* @return {Object} bounds | |
*/ | |
getPolygonBounds: function(polygon) { | |
var paths = polygon.getPaths(); | |
var bounds = new google.maps.LatLngBounds(); | |
paths.forEach(function(path) { | |
var ar = path.getArray(); | |
for(var i = 0, l = ar.length;i < l; i++) { | |
bounds.extend(ar[i]); | |
} | |
}); | |
return bounds; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment