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.
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.
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]
]);