• Stars
    star
    487
  • Rank 90,352 (Top 2 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created about 11 years ago
  • Updated 8 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A responsive sidebar for Leaflet maps

leaflet-sidebar

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.

Flattr this

Examples

Basic example

Examples are available in the examples folder and on Github Pages:

Using the plugin

See the included examples for usage.

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.

Options

The sidebar can be configured with these options:

  • position: Can be left (default) or right and shouldn't need explaining.
  • closeButton: Can be true (default) or false. If true a close button will be added to the sidebar.
  • autoPan: Can be true (default) or false. If true the map will be shifted when the sidebar is shown.

Events

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:

  • show: Show animation is starting, sidebar will be visible.
  • shown: Show animation finished, sidebar is now visible.
  • hide: Hide animation is starting, sidebar will be hidden.
  • hidden: Hide animation finished, sidebar is now hidden.

Note that the shown and hidden events depend on transitionend/webkitTransitionEnd which might not be supported by all browsers yet.

Compatibility

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:

  • Ubuntu: Firefox, Chrome
  • Mac OS X: Firefox, Chrome, Safari
  • Android 4.3: Firefox, Chrome, Opera
  • iOS: Safari
  • Windows XP: Internet Explorer 6 (failed!)

License

leaflet-sidebar is free software, and may be redistributed under the MIT license.

More Repositories

1

sidebar-v2

A responsive sidebar with tabs for Leaflet, OpenLayers, Google Maps, ...
CSS
814
star
2

utm

Bidirectional UTM-WGS84 converter for python
Python
443
star
3

webpack-notifier

webpack + node-notifier = build status system notifications
TypeScript
306
star
4

intellij-emberjs

Ember.js support for JetBrains IDEs (IntelliJ, WebStorm, ...)
Kotlin
215
star
5

aerofiles

waypoint, task, tracklog readers and writers for aviation
Python
45
star
6

Android-Action-Bar-Icon-Pack-Font

The offical Android Action Bar Icon Pack as an iconic webfont
JavaScript
43
star
7

apwlibrary

Android PDF Writer
Java
42
star
8

eslint-plugin-chai-expect

ESLint plugin that checks for common chai.js expect() mistakes
JavaScript
27
star
9

PasParse

Delphi port of the DGrok (C#) Delphi parser
Pascal
27
star
10

igc-parser

IGC flight log parser
TypeScript
27
star
11

flat-projection-rs

Fast geodesic distance approximations via flat surface projection
Rust
19
star
12

aeroscore

Gliding Competition Scoring
TypeScript
16
star
13

setup.py

setup.py cheatsheet
CSS
16
star
14

ember-qr-scanner

QR Code scanner component for Ember.js
JavaScript
12
star
15

ogn-web-gateway

OpenGliderNet Web-Gateway
Rust
11
star
16

chai-roughly

deep equals assertions with tolerance for chai
JavaScript
11
star
17

flight-club

an online glider simulator
Java
9
star
18

ogn-web-viewer

OpenGliderNet WebViewer
JavaScript
8
star
19

ember-cli-rollup

JavaScript
7
star
20

auto-dist-tag

Automatically rewrites the "publishConfig.tag" setting in your "package.json" file for you
JavaScript
7
star
21

aprs-parser-rs

APRS message parser for Rust
Rust
7
star
22

ember-cli-deploy-ftp

ember-cli-deploy wrapper for ftp-deploy
JavaScript
6
star
23

united-flarmnet

Merging FlarmNet, OGN and WeGlide live tracking data into a single FlarmNet file
Rust
6
star
24

cabwiz

Native Linux replacement for Microsoft's cabwiz.exe
Python
6
star
25

openvario-protocol

OpenVario serial port protocol specification
6
star
26

hosted-git-info-rs

Provides metadata and conversions from repository urls for GitHub, Bitbucket and GitLab
JavaScript
6
star
27

chai-files

file system assertions for chai
JavaScript
5
star
28

github-labels

labels.json file for github-label-sync
5
star
29

toptherm-forecast-format

Reverse-engineered description of the DWD TopTherm forecast file format
4
star
30

igc-filename-parser

IGC flight log filename parser
JavaScript
4
star
31

open-flight-planner

Flight planning tool for glider pilots
JavaScript
3
star
32

flight-recorder-manufacturers

Flight Recorder Manufacturers and their assigned IGC codes
JavaScript
3
star
33

flarmnet.py

Python
3
star
34

DGrok

Delphi Parser
C#
3
star
35

segelflug-classifieds

Segelflug.de Kleinanzeigen Telegram Bot
HTML
2
star
36

skylines-ios-tracker

SkyLines tracking client for iOS
Objective-C
2
star
37

esp8266-nonos

Rust
2
star
38

libfap

(Unmaintained!) unofficial git mirror of libfap - APRS parser
Shell
2
star
39

openaip

OpenAIP file parser
JavaScript
2
star
40

semver-cargo

Parser and evaluator for Cargo's flavor of Semantic Versioning ... in JavaScript
TypeScript
2
star
41

flupp-rs

FluPP flight log file reader for Rust
Rust
2
star
42

FluPP

Pascal
1
star
43

sliding-menu

a sliding menu for Bootstrap 2.3
CSS
1
star
44

py-gpolyencode

Python modules for Google Maps polyline encoding
C++
1
star
45

multifix

Run simple fixes on multiple repositories
Rust
1
star
46

renovate-config

Shareable config presets for Renovate
JavaScript
1
star
47

mergejs.py

Standalone distribution of the mergejs tool of the OpenLayers project.
Python
1
star
48

actix-ogn

OpenGliderNetwork client for Rust based on actix
Rust
1
star
49

rust-igc

IGC file parser for Rust
Rust
1
star
50

lva-camo-status.vue

Vue
1
star
51

chrome-devtools-theme-firacode

Chrome DevTools theme with Fira Code font
JavaScript
1
star
52

avia-converter

Vereinsflieger.de to ameavia flight log converter
Python
1
star
53

strepla-api

scoring*StrePla "API" wrapper
HTML
1
star