By default zoom to, setview functions show the center point of the map in the center point of div measured by pixel of browser. I want to show the center at slightly right when left panel is visible. In http://2gis.ru/ site, they used the similar function. How can I do this?


You will probably be interested in one of those plugins:

  • Leaflet-active-area

    This plugin allows you to use a smaller portion of the map as an active area. All positioning methods (setView, fitBounds, setZoom) will be applied on this portion instead of the all map.

  • Leaflet.ControlledBounds

    Inspired by Leaflet-active-area, automatically detects the largest area of the map not covered by any map controls and applies setView, fitBounds, setZoom, getBounds to that area.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.