V-Leaflet - Possible to set max bounds?

I’m currently using Leaflet to show a map on my application. I want to limit the area/map view somehow, by setting maximum bounds. What I mean is when the user tries to zoom out from a certain bound I set, the user should get an error or let the map zoom back to default setCenter which I provide. For example, the user should only be able to see the United Kingdom, no more than that. If he tries to zoom out of the limited area (UK), it should just bounce back to certain position I provide.

I checked LEaflets default website, and they use a method called setMaxBounds. However, I could not find this on Vaadin V-Leaflet add-on. Is it something I have to develope myself (I dont think I have the skills), or is it hidden?

Short: I want to restrict the map view to given bounds (by setting northeast and southwest position). Is this possible in V-Leaflet?

I don’t know if there is a way to do it without modyfing the add-on’s code but you could get the sources from
here
and then add a way to call the setMaxBounds method from the server side (using rpc or shared state).
This
might be one of the most interesting class for you. When you’re done you could even contribute the code back to the add-on so that everyone can use setMaxBounds. Or you could ask the author to implement this feature but this might take a while.

Hi,

Somebody else also asked that a while ago, so this certainly should be implemented. I created a ticket for it:

https://github.com/mstahv/v-leaflet/issues/42

I’d be great if somebody can contribute it, should be rather straightforward task once you get the development environment set up. I can also take a look at this next time I work on this add-on.

cheers,
matti