This patch to the LeafLet module provides support to some of the features related to Markers and Popups from JS Leaflet library.

In particular, it adds to the Leaflet display formatter UI the following features:

  • Display the location popups:
    • when locations are single-clicked (default).
    • when locations are doubled-clicked.
    • when mouse is over the locations (without clicking).
    • when the user right-clicks on the marker (useful for emulating a context-menu).
  • Select if the map will not do panning animation to fit the opened popup.
  • Select the presense of a close button in the popup.
  • 'riseOnHover' markers: the markers will get on top of others when you hover the mouse over it.

(Note: double-click option does not work 100% properly)

The new available options are shown in the attached screen.
leaflet-new-options-for-popups-and-markers.jpg

Leaflet library offers still more options and events available for Markers and Popups ( see http://leafletjs.com/reference.html#marker and http://leafletjs.com/reference.html#popup ). This patch prepares the code for easily accommodate them. But before adding more options, I would like to validated the approach adopted by this patch, since it modifies a little the current flow for handling markers and popups.

Changes in the creation and binding of Popups

Originally, leaflet.drupal.js does not create Popups objects independently, but it does always using bindPopup method. Leaflet library currently support and encourage the use of the Popup object, created by the L.popup() factory method. A initial work to independently handle the Popups has been recently committed to the dev version (#1608700: Support adding popups in map features ). This patch follows that approach, and it replaces the bindPopup method of creating Popups by the more flexible L.Popup().

In this way the customization of the options for the Popups elements are done in only one place, and also it will make easy to use contrib plugins that replace the Popup object by customized ones. It is only my personal opinion, I am obviously open to receive any feedback/suggestion by the module maintainers.

Leaflet Views sub-module

Changes has been incorporated also to the Leaflet Views sub-module.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

interdruper’s picture

interdruper’s picture

Status: Active » Needs review
kirke_89’s picture

I thank you very much for this patch, unfortunately it's not quite working with my view. I do get to see the different settings etc. in my view, but my map is no longer showing. I'm using the 7.x-1.1 version, should I just instal the dev version instead? Or do you have an other solution?

rosemaryreilman’s picture

Worked beautifully for me. Thanks for the patch. Using leaflet 7.x-1.1 and leaflet_more_maps 7.x-1.13

DrCord’s picture

This looks like great features to add to me, unfortunately it breaks leaflet integration with the ip_geoloc module :( popups no longer work at all once it is applied.

abs’s picture

I was still able to use patch with minor fiddling for leaflet 7.x-1.4 and leaflet_more_maps 7.x-1.7. Implementation of riseOnHover is very handy. Any plans to commit this functionality to the main branch?

itamair’s picture

Tnx and sorry ... It seems that I am the only active maintainer for the Leaflet module, but actually I am taking care of the 8.x branch,
and not able to follow, fix bugs and face features requests, and even review functionalities.
Actually I don't even have a Drupal 7 playground (and don't have time to set it up) to test them.
Evan I am not able to grant new maintainer privileges.

So ... I would be able just to commit new patches to dev, and just if they are 99% tested and reviewed by you external contributors,
and that cleanly apply to the 7.x-1.x-dev of the moment
.
So do that, and eventually under your responsibility ask me to commit to dev if really needed (will try to do that in my spare time).