aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gmap_arcgis.js30
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());