项目作者: HatfieldConsultants

项目描述 :
A Leaflet plugin for creating panels, and handling plugins which require panels
高级语言: JavaScript
项目地址: git://github.com/HatfieldConsultants/leaflet.panelManager.git
创建时间: 2017-01-10T01:19:43Z
项目社区:https://github.com/HatfieldConsultants/leaflet.panelManager

开源协议:Mozilla Public License 2.0

下载


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.

  1. L.PanelManager.addTo(map);
  2. map.PanelManager.newPanel({
  3. position: "bottom",
  4. toggleHide: true,
  5. title: "Hi there"
  6. }).addTo(map);
  7. map.PanelManager.newPanel({
  8. position: "right",
  9. toggleHide: "button",
  10. title: "I am another panel"
  11. }).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:

  1. title - string (for display)
  2. panelName - string (an identifier)
  3. position - "top" | "bottom" | "right" | "left"
  4. toggleHide - "button" | "peek" | true | false | null
  5. if "button":
  6. toggleIcon: - path to an image
  7. toggleOnCallback - function exectued when panel is shown
  8. toggleOffCallback - function executed when panel is hidden
  9. type - "button-list" | "document-list" | null
  10. if "button-list":
  11. buttons - array of button objects where a button is
  12. name - string
  13. icon - class name (in your styles, you can style the button with this)
  14. callback - function which is executed when your button is clicked
  15. if "document-list":
  16. documentSource: the array of objects to display
  17. documentActions: array of actions associated with the documents (e.g. delete, share), shown as buttons.
  18. Each action is
  19. - name: string (identifier, you can make a class in your styles named after this to style the specific action button)
  20. - displayName: string (what is displayed in the button)
  21. - action: function (executed when the button is clicked)