[GIS] How to keep leaflet tooltips within visible map view

extentsleaflet

I have a map with panning and zooming disabled, creating a bounding box. This map has a geojson layer with features and tooltips displaying underlying data.

The issue is when the user mouses over features on the outer edges of the visible map area, the tooltips are outside of the div view. Because there's no panning enabled, the user is SOL to see the tip.

How can I keep the tips within the visible map view bound by extents?

Best Answer

Take a look at the keepView option of the Popup layer. My guess is when you set it to true instead of the default false it will keep the tooltip/popup visible within the current map extent.

However if you can post the code you're working on in a fiddle, it would be helpful to test whether my assumption is correct.