From 68e9b33e0c1c6b6ecdcba0b7c75dffa50618b01a Mon Sep 17 00:00:00 2001 From: Silvio Date: Tue, 9 Apr 2013 12:30:54 -0300 Subject: Adding google.maps.Polygon.prototype.getBounds --- gmap_arcgis.js | 30 ++++++++++++++++++++++++++++-- 1 file 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()); -- cgit v1.2.3