Index: /Users/italo/Sites/hostgator_italomairo.com/geoblogcms/sites/all/modules/leaflet_markercluster/leaflet_markercluster.drupal.js
index dd5d7d8..a75c52b 100644
--- a/sites/all/modules/leaflet_markercluster/leaflet_markercluster.drupal.js
+++ b/sites/all/modules/leaflet_markercluster/leaflet_markercluster.drupal.js
@@ -11,6 +11,14 @@
     attach: function(context, settings) {
 
       $(settings.leaflet).each(function () {
+        
+        /** 
+        * Process the Leaflet Map just IF there is the Map Container rendered in the page Dom
+        * This condition is needed if some map is exposed in some page region's block, region that is not renderd for some particular rule in the specific page (i.e. with context module rule).
+        * Without this rule a javascript error (console.log) might be thrown that would stop the overall javascript further processing ... 
+        **/
+        if (L.DomUtil.get(this.mapId)) {
+          
         // bail if the map already exists
         var container = L.DomUtil.get(this.mapId);
         if (container._leaflet) {
@@ -145,7 +153,14 @@
         else {
           Drupal.leaflet.fitbounds(lMap);
         }
-
+          
+        /**
+        *Associate the initial center and zoom level properties to the built lMap,
+        *needed to interact with the Leaflet map from outside and after it is loaded (i.e. to reset the lMap initial state, after some pan/zoom actions)
+        **/
+        lMap.center = lMap.getCenter();
+        lMap.zoom = lMap.getZoom();
+        
         // add attribution
         if (this.map.settings.attributionControl && this.map.attribution) {
           lMap.attributionControl.setPrefix(this.map.attribution.prefix);
@@ -154,9 +169,30 @@
 
         // add the leaflet map to our settings object to make it accessible
         this.lMap = lMap;
+        this.lMap.features = this.features;
+            
+        // allow other modules to get access to the map object using jQuery's trigger method
+        $(document).trigger('leaflet.map', [this.map, lMap]);
+            
         // Destroy features so that an AJAX reload does not get parts of the old set.
         // Required when the View has "Use AJAX" set to Yes.
         this.features = null;
+          
+        /**
+        * Reset also the map.center property and map.settings.zoom, so that an AJAX reload does not get parts of the old set (when the View has "Use AJAX" set to Yes),
+        * when the lMap is set to fit markers' bounds
+        * If this is not done might happpen that an AJAX reload that returns just one marker would set these properties to not null (the unique marker'ones),
+        * and a further Ajax reload (of more than one marker) would not throw the "fit to bounds" condition (see previous if, else if, else condtion ),
+        * as the this.map.center or the this.map.settings.zoom will be set to not null
+        **/
+        this.map.center = null;
+        this.map.settings.zoom = null;
+        
+        //Resets the bounds array, ready again to be used for next map's features
+        Drupal.leaflet.bounds = [];
+          
+        }
+        
       });
 
       function leaflet_create_feature(feature) {
@@ -197,5 +233,151 @@
 
     }
   }
+  
+
+/*
+ * We copy the following part of the JS (global variables and functions ...) defined in leaflet module (leaflet.drupal.js), that would not be called otherwise
+ * 
+ */
+Drupal.leaflet = {
+
+    bounds: [],
+
+    create_layer: function (layer, key) {
+      var map_layer = new L.TileLayer(layer.urlTemplate);
+      map_layer._leaflet_id = key;
+
+      if (layer.options) {
+        for (var option in layer.options) {
+          map_layer.options[option] = layer.options[option];
+        }
+      }
+
+      // layers served from TileStream need this correction in the y coordinates
+      // TODO: Need to explore this more and find a more elegant solution
+      if (layer.type == 'tilestream') {
+        map_layer.getTileUrl = function (tilePoint) {
+          this._adjustTilePoint(tilePoint);
+          var zoom = this._getZoomForUrl();
+          return L.Util.template(this._url, L.Util.extend({
+            s: this._getSubdomain(tilePoint),
+            z: zoom,
+            x: tilePoint.x,
+            y: Math.pow(2, zoom) - tilePoint.y - 1
+          }, this.options));
+        }
+      }
+      return map_layer;
+    },
+
+    create_point: function(marker) {
+      //console.log(marker); //Debug
+      var latLng = new L.LatLng(marker.lat, marker.lon);
+      this.bounds.push(latLng);
+      var lMarker;
+
+      if (marker.icon) {
+        var icon = new L.Icon({iconUrl: marker.icon.iconUrl});
+
+        // override applicable marker defaults
+        if (marker.icon.iconSize) {
+          icon.options.iconSize = new L.Point(parseInt(marker.icon.iconSize.x), parseInt(marker.icon.iconSize.y));
+        }
+        if (marker.icon.iconAnchor) {
+          icon.options.iconAnchor = new L.Point(parseFloat(marker.icon.iconAnchor.x), parseFloat(marker.icon.iconAnchor.y));
+        }
+        if (marker.icon.popupAnchor) {
+          icon.options.popupAnchor = new L.Point(parseFloat(marker.icon.popupAnchor.x), parseFloat(marker.icon.popupAnchor.y));
+        }
+        if (marker.icon.shadowUrl !== undefined) {
+          icon.options.shadowUrl = marker.icon.shadowUrl;
+        }
+        if (marker.icon.shadowSize) {
+          icon.options.shadowSize = new L.Point(parseInt(marker.icon.shadowSize.x), parseInt(marker.icon.shadowSize.y));
+        }
+        if (marker.icon.shadowAnchor) {
+          icon.options.shadowAnchor = new L.Point(parseInt(marker.icon.shadowAnchor.x), parseInt(marker.icon.shadowAnchor.y));
+        }
+
+        lMarker = new L.Marker(latLng, {icon:icon});
+      }
+      else {
+        lMarker = new L.Marker(latLng);
+      }
+      return lMarker;
+    },
+
+    create_linestring: function(polyline) {
+      var latlngs = [];
+      for (var i = 0; i < polyline.points.length; i++) {
+        var latlng = new L.LatLng(polyline.points[i].lat, polyline.points[i].lon);
+        latlngs.push(latlng);
+        this.bounds.push(latlng);
+      }
+      return new L.Polyline(latlngs);
+    },
+
+    create_polygon: function(polygon) {
+      var latlngs = [];
+      for (var i = 0; i < polygon.points.length; i++) {
+        var latlng = new L.LatLng(polygon.points[i].lat, polygon.points[i].lon);
+        latlngs.push(latlng);
+        this.bounds.push(latlng);
+      }
+      return new L.Polygon(latlngs);
+    },
+
+    create_multipoly: function(multipoly) {
+      var polygons = [];
+      for (var x = 0; x < multipoly.component.length; x++) {
+        var latlngs = [];
+        var polygon = multipoly.component[x];
+        for (var i = 0; i < polygon.points.length; i++) {
+          var latlng = new L.LatLng(polygon.points[i].lat, polygon.points[i].lon);
+          latlngs.push(latlng);
+          this.bounds.push(latlng);
+        }
+        polygons.push(latlngs);
+      }
+      if (multipoly.multipolyline) {
+        return new L.MultiPolyline(polygons);
+      }
+      else {
+        return new L.MultiPolygon(polygons);
+      }
+    },
+
+    create_json: function(json) {
+      lJSON = new L.GeoJSON();
+
+      lJSON.on('featureparse', function (e) {
+        e.layer.bindPopup(e.properties.popup);
+
+        for (var layer_id in e.layer._layers) {
+          for (var i in e.layer._layers[layer_id]._latlngs) {
+            Drupal.leaflet.bounds.push(e.layer._layers[layer_id]._latlngs[i]);
+          }
+        }
+
+        if (e.properties.style) {
+          e.layer.setStyle(e.properties.style);
+        }
+
+        if (e.properties.leaflet_id) {
+          e.layer._leaflet_id = e.properties.leaflet_id;
+        }
+      });
+
+      lJSON.addData(json);
+      return lJSON;
+    },
+
+    fitbounds: function(lMap) {
+      if (this.bounds.length > 0) {
+        lMap.fitBounds(new L.LatLngBounds(this.bounds));
+      }
+    }
+
+  }
 
 })(jQuery);
