
Research
Security News
The Growing Risk of Malicious Browser Extensions
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.
leaflet-sidebar
Advanced tools
A responsive sidebar plugin for Leaflet, a JS library for interactive maps.
Please also have a look at sidebar-v2, the tabbed successor of this library.
Examples are available in the examples
folder and on Github Pages:
See the included examples for usage.
Add a content container somewhere in your document:
<div id="sidebar">
<h1>leaflet-sidebar</h1>
</div>
Create a new L.Control.Sidebar
and add it to the map:
var sidebar = L.control.sidebar('sidebar', {
position: 'left'
});
map.addControl(sidebar);
The sidebar will be hidden on startup, use the following methods to show or hide it:
// Show sidebar
sidebar.show();
// Hide sidebar
sidebar.hide();
// Toggle sidebar visibility
sidebar.toggle();
// Check sidebar visibility
var visible = sidebar.isVisible();
If you want the sidebar to be visible on startup use the following snippet after adding it to the map:
setTimeout(function () {
sidebar.show();
}, 500);
Do not call show()
directly after adding the control to the map. The setTimeout
will work around some CSS quirks for you.
The content of the sidebar can be changed dynamically:
sidebar.setContent('test <b>test</b> test');
If you need more flexibility you can use sidebar.getContainer()
to get the content container element or use e.g. jQuery on the <div id="sidebar">
element.
The sidebar can be configured with these options:
left
(default) or right
and shouldn't need explaining.true
(default) or false
. If true
a close button will be added to the sidebar.true
(default) or false
. If true
the map will be shifted when the sidebar is shown.Whenever the visibility of the sidebar is changed, an event is fired on the sidebar instance. You can listen for these events like this:
sidebar.on('hidden', function () {
console.log('Sidebar is now hidden.');
});
Available events:
Note that the shown
and hidden
events depend on transitionend
/webkitTransitionEnd
which might not be supported by all browsers yet.
leaflet-sidebar was developed to work with Leaflet 0.6.4 and should work fine with v0.7 too. I have no information whether it works well with older versions.
The leaflet-sidebar plugin has been tested on the following systems and browsers:
leaflet-sidebar is free software, and may be redistributed under the MIT license.
FAQs
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.
Research
Security News
An in-depth analysis of credential stealers, crypto drainers, cryptojackers, and clipboard hijackers abusing open source package registries to compromise Web3 development environments.
Security News
pnpm 10.12.1 introduces a global virtual store for faster installs and new options for managing dependencies with version catalogs.