Leaflet views: how to zoom on the marker while clicking on it in order to get the popup I am using the module Leaflet and its sub-module "Leaflet views"" in order to get a map displaying markers based on taxonomy terms.

I am able to show a popup displaying the term page while I click on a marker.

Now, my actual requirement is when I click on the marker, the map is zoomed on the clicked marker (zoom of maximum 3 levels) and just after the popup is displayed. So, my map behavior on the marker click event contains two steps: zooming and popup opening.

How can I hook the module in order to enrich my views?
Install and enable jQuery update. Set the jQuery version to >= 1.7.

Create a module, then create a zoom.js JavaScript file and paste this:

(function ($) {
  Drupal.behaviors.MYMODULE = {
    attach: function (context, settings) {
      $(document).bind('leaflet.feature', function(e, lFeature, feature) {
        lFeature.on('click', function(e) {
          var lMap = Drupal.settings.leaflet[0].lMap;
          lMap.setView(e.latlng,8);
        })
      });

    }
  }
})(jQuery);


Use your module name instead of MYMODULE

Then use drupal_add_js() in your module to include zoom.js. Note the weight option:

  drupal_add_js(drupal_get_path('module', 'MYMODULE') .'/zoom.js',array('group' =&gt; JS_DEFAULT, 'weight' =&gt; -5));