HatfieldConsultants / leaflet.panelManager

A Leaflet plugin for creating panels, and handling plugins which require panels

Home Page:https://nimaboscarino.github.io/leaflet.panelManager/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Leaflet PanelManager

Create and manage panels stand-alone panels for Leaflet maps, or load panels to house Leaflet plugins

Demo

Installation and Use:

Add PanelManager to the map

  • Link panelManager.css in the head section
  • Link panelManager.js in the body section after instantiating a map in a "map" div
  • After panelManager.js, add PanelManager to the map: var panelManager = L.PanelManager.addTo(map);

Create Panels

E.g.

L.PanelManager.addTo(map);
map.PanelManager.newPanel({
  position: "bottom",
  toggleHide: true,
  title: "Hi there"
}).addTo(map);

map.PanelManager.newPanel({
  position: "right",
  toggleHide: "button",
  title: "I am another panel"
}).addTo(map);

Panel Options for constructing panels directly

  • position
  • toggleHide
  • title
  • initiallyVisible
  • toggleOnCallback
  • toggleOffCallback
  • silentToggleOnEvent
  • silentToggleOffEvent
  • responsiveRules (not yet implemented)

Load a plugin (e.g. Redliner)

  • var redliner = L.Redliner.addTo(map);
  • map.PanelManager.loadPlugin(map.Redliner);
  • The plugin must have a "GUI" property, which exposes a "loadPanels" function

Plugin Development Guide

PluginManager can be used as a kind of front-end for Leaflet plugins which employ the interface. Plugins must have a GUI property with a "loadPanels" function, which must return an array of panel specifications objects. The array can contain as many panel specifications as desired. (See Redliner for an example of implementing both a button-list panel and a document-list panel.

A panel is specified as such:

title - string (for display)
panelName - string (an identifier)
position - "top" | "bottom" | "right" | "left"
toggleHide - "button" | "peek" | true | false | null
	if "button":
    	toggleIcon: - path to an image
    	toggleOnCallback - function exectued when panel is shown
        toggleOffCallback - function executed when panel is hidden
type - "button-list" | "document-list" | null
	if "button-list":
    	buttons - array of button objects where a button is
        	name - string
            icon - class name (in your styles, you can style the button with this)
            callback - function which is executed when your button is clicked

	if "document-list":
    	documentSource: the array of objects to display
        documentActions: array of actions associated with the documents (e.g. delete, share), shown as buttons.
        	Each action is
        	- name: string (identifier, you can make a class in your styles named after this to style the specific action button)
        	- displayName: string (what is displayed in the button)
        	- action: function (executed when the button is clicked)

About

A Leaflet plugin for creating panels, and handling plugins which require panels

https://nimaboscarino.github.io/leaflet.panelManager/

License:Mozilla Public License 2.0


Languages

Language:JavaScript 75.9%Language:CSS 13.8%Language:HTML 10.3%