diff options
author | Silvio <silvio@socioambiental.org> | 2013-04-09 12:30:54 -0300 |
---|---|---|
committer | Silvio <silvio@socioambiental.org> | 2013-04-09 12:30:54 -0300 |
commit | 68e9b33e0c1c6b6ecdcba0b7c75dffa50618b01a (patch) | |
tree | 93dd3d2e13c914df87e4828f1456a79320a72950 | |
parent | 030f80018bb8d904cbe871209bc26e6f341a1c70 (diff) | |
download | gmap_arcgis_js-68e9b33e0c1c6b6ecdcba0b7c75dffa50618b01a.tar.gz gmap_arcgis_js-68e9b33e0c1c6b6ecdcba0b7c75dffa50618b01a.tar.bz2 |
Adding google.maps.Polygon.prototype.getBounds
-rw-r--r-- | gmap_arcgis.js | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/gmap_arcgis.js b/gmap_arcgis.js index a2c8b53..77e0465 100644 --- a/gmap_arcgis.js +++ b/gmap_arcgis.js @@ -1,5 +1,31 @@ -// $Id$ +/** + * Extend Google Maps API. + */ +google.setOnLoadCallback(function() { + // See https://code.google.com/p/google-maps-extensions/source/browse/google.maps.Polygon.getBounds.js + if (!google.maps.Polygon.prototype.getBounds) { + + google.maps.Polygon.prototype.getBounds = function(latLng) { + + var bounds = new google.maps.LatLngBounds(); + var paths = this.getPaths(); + var path; + + for (var p = 0; p < paths.getLength(); p++) { + path = paths.getAt(p); + for (var i = 0; i < path.getLength(); i++) { + bounds.extend(path.getAt(i)); + } + } + + return bounds; + } + } +}); +/** + * Gmap ArcGIS wrapper. + */ function gmapArcgis(config) { return { // Storable properties @@ -385,7 +411,7 @@ function gmapArcgis(config) { * @see http://stackoverflow.com/questions/9837017/equivalent-of-getboundszoomlevel-in-gmaps-api-3 */ getZoomByBounds: function(bounds) { - var map = this.map(); + var map = this.map; var MAX_ZOOM = map.mapTypes.get(map.getMapTypeId()).maxZoom || 21; var MIN_ZOOM = map.mapTypes.get(map.getMapTypeId()).minZoom || 0; var ne = map.getProjection().fromLatLngToPoint(bounds.getNorthEast()); |