HI Rik …
As explained here (https://drupal.org/node/2038649) I had to manage (and solve) the marker clustering with more than one map shown in the same page (with ip_geoloc module).
It seems the matter is related with the Drupal.behaviors namespace used in the "leaflet_markercluster.drupal.js" hat is the same of the one used in the master file "leaflet.drupal.js" (of the Laflet Module).
Everythings works (quite ok) if we change that namespace to something else, and the best way might be to use the module name namespace, thus: "Drupal.behaviors.leaflet_markecluster".
In this way my two markeclustered maps works ok in the same page … as shown in the attached screenshot.
I attach the diff file, that I hope will be implemented soon in the next dev, if any counter indication on that.
The same diff file contains same code add on yet asked in this issue: https://drupal.org/node/2005334 to implement the Leaflet Markecluster map interaction from outside itself … (and that I hope will be implemented too)
all this overridden by the following comment: https://drupal.org/node/2038659#comment-7634543
This seems to fix this issues too: https://drupal.org/node/1845356
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | n_markerclusters.jpg | 329.94 KB | itamair |
| #3 | leaflet_markercluster.drupal.js_.zip | 3.59 KB | itamair |
| leaflet_markercluster_drupal.diff | 1.83 KB | itamair | |
| parallel_marker_clustering.jpg | 325.47 KB | itamair |
Comments
Comment #1
rdeboerHi Italo,
Great work!
Looks like it's the way to a solution!
Rik
Comment #2
itamair commentedIn my (although limited) experience, seems it is always better (we ought) not to duplicate Drupal.behavors namespaces …
they will mess/exclude each other, as should be once and unique … I guess
Comment #2.0
itamair commentedupdate
Comment #3
itamair commentedWait ! Stop ! … Sorry, but I was singing "victory!" too soon … as the above solution would stop the markeclustering in one single exposed map, and anyway no guarantee the proper simultaneous marker clustering of multiple maps in every context.
I went deeper this and realized that it is a matter of js files (behaviors) ordering in uploading during each page load.
(sometimes the map is anyway initialized by the "leaflet.drupal.js", so the "leaflet_markercluster.drupal.js" code is not executed after the following:
as that check returns TRUE … so no clustering.
Anyway I found the following solution …
If the markeclustering is ON, the "leaflet.drupal.js" shouldn't be executed/added at all, in favor of the "leaflet_markercluster.drupal.js", that might have/keep the same "Drupal.behaviors.leaflet" namespace, integrate the clustering code, but bringing in itself also the "leaflet.drupal.js" code that creates the features … (the one at the bottom of Drupal.leaflet = { … ) and that so far is not.
I attach here the new "leaflet_markercluster.drupal.js" (zipped) file that works now for me, perfectly, in every page, as shown in the attached screnshot.
All this works ok, at the condition that the Leaflet marker_clustering implementing module would do an if condition to load (drupal_add_js) the "leaflet_markercluster.drupal.js" file in place of the "leaflet.drupal.js" (and not one after the other).
For instance for what concerns the IP Geolocation Views & Maps module, what advised/requested in this issue should be implemented: https://drupal.org/node/2039309
Comment #4
itamair commentedhttps://drupal.org/node/2056557
Comment #4.0
itamair commentedupdate
Comment #5
rdeboerThere have been many changes to Leaflet and Leaflet MarkerCluser (to synchronize with these changes), so I guess this patch is now out of date?
Comment #6
rdeboer