I'd like to restrict the panning of my leaflet map in Drupal.
The Leaflet documentation mentions the maxBounds option
And I'd like to know the best way to implement it for my map.
Drupal Answers is a question and answer site for Drupal developers and administrators. It only takes a minute to sign up.Sign up to join this community
Got it working. Override the leaflet.drupal.js file as follows. See the leaflet markercluster module for how to override in an 'As You Like it kind of way.' in a custom module. Pretty useful.
// instantiate our new map var lMap = new L.Map(this.mapId, settings); //note, the comma (NOT A semi-colon) at the end of the next line - this is important. lMap.bounds = , // Now set your maxbounds, see the leaflet documentation for reference. lMap.setMaxBounds([ [40.712, -74.227], [40.774, -74.125] ]);