(This issue specific for the Leaflet MarkerCluster Module corresponds to this: https://drupal.org/node/2040627/edit, that targets the same issue on the Leaflet Module).

When I expose more than one map with features in the page, and the zoom view is setted to fit the features bounds, well, the last loaded map get the bounds of the previous one (if wider than its features bounds) … as the Drupal.leaflet.bounds array is always pushed in with all the features of (all) the page maps.

So it might happen what is shown in my attached screenshot, with 3 maps loaded and the widest as the first …

Everything is fixed if we reset/empty the Drupal.leaflet.bounds array after the Drupal.leaflet.fitbounds(lMap); has run on each map, like with the following added code in the leaflet.drupal.js file


// fit to bounds
else {
Drupal.leaflet.fitbounds(lMap);
+ Drupal.leaflet.bounds = []; //Resets the bounds array, ready again to be used for next map's features
}

The second screenshot shows that now every things works ok.

I attach also the new "leaflet_markercluster.drupal.js" (zipped) file I am using now (it's ok),
and I hope will be implemented soon in the next module release.

Comments

itamair’s picture

Relating with the correspondent Leaflet Module issue and its last evolution https://drupal.org/node/2040627#comment-7673527
thanks to thedavidmeister (https://drupal.org/user/657782) in deep testing,

I found that a better place to do this is (seems to be) just right after each map features are destroyed for the same purposes,
and I mean with this code diff (from the actual dev version of leaflet_markercluster.drupal.js file):


        // 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;

+        //Resets the bounds array, ready again to be used for next map's features
+        Drupal.leaflet.bounds = []; 
+    

Attached a new screenshot and the new leaflet_markercluster.drupal.js (zipped) file with this last emending and that works for me now …

itamair’s picture

dasjo’s picture

here's my version, based on #2048805: Incorrect centering when displaying multiple Leaflet maps on the same page

better of course would be to not duplicate all js in markercluster

rdeboer’s picture

Status: Needs review » Fixed

Just saw this after fixing #2144935: Broken with latest Leaflet Dev Version?.
Turns out that itamair's and dasjo's fix from #3 is already incorporate with #2144935: Broken with latest Leaflet Dev Version?.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.