I have a leaflet map on an HTML page. When the page is scrolled so that any part of the map is outside of the viewport and I click the zoom buttons, the map jumps so that it's completely visible in the viewport. If the whole map doesn't fit, then the top of the map becomes aligned with the top of the viewport and the bottom just hangs off the end.
This is annoying, because then the zoom button which the user just pressed is no longer under the cursor and they have to go find it again.
I have tried both the built-in zoom bar and a custom one where I use map.setZoom()
and the behaviour is consistent. However, the sample maps on https://leafletjs.com don't do this, so I'm at a loss.
My map is quite simple:
var home = {center: L.LatLng(51.499725, -0.124695), zoom: 11};
var mymap = L.map('map').setView(home.center, home.zoom);
This question sounds similar to what I'm seeing, but is more complex than my situation. And anyway, there's no solution.
Edit: Here is the html and CSS, but it couldn't be more basic.
map.html
<div class="container mx-sm-3">
<div class="row">
<div class="col">
<div id="map"></div>
</div>
</div>
</div>
map.css
#map {
height: 570px;
width: 700px;
}