Socket
Socket
Sign inDemoInstall

leaflet-control-window

Package Overview
Dependencies
1
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    leaflet-control-window

Simple popup window plugin for leaflet.


Version published
Weekly downloads
13
decreased by-40.91%
Maintainers
1
Install size
3.57 MB
Created
Weekly downloads
 

Readme

Source

leaflet-control-window

leaflet-control-window
Simple popup window plugin for leaflet. Ready for information, prompts, dialogs, photos etc.

The optional action button allows for multiple interaction with the same window as it hides the window instead of closing it.

*Requires Leaflet and modern browser

Features

  • modal/modeless mode
  • draggable
  • customisable
  • responsive
  • optional Action button

Example

Check out demo and example of use!

Installation

Install via npm
npm i leaflet-control-window
Install Manually

Download L.Control.Window.css and L.Control.Window.js and include them in your project.

Getting started

Using leaflet-control-window plugin is very easy and comfortable.

Quick usage

  • Download and place files from src dir to the same folder in your project.
  • Link javascript and style file in your HTML document:
     <script src="...path-to-files.../L.Control.Window.js"></script>
     <link rel="stylesheet" href="...path-to-file.../L.Control.Window.css" />
Include as ES6 Module
import 'leaflet-control-window';
import 'L.Control.Window.css';

How to use

L.control.window( <Map> map ,<window options> options?)

There are two ways to set up control windows. It's up to you what you prefer. Following examples have the same results.

  • using options
var winOpts = L.control.window(map,{title:'Heading!',content:'First paragraph.',visible: true})
  • using methods
var winMtds = L.control.window(map)
        .title('Heading!')
        .content('First paragraph.')
        .show()

Options

PropertyDescriptionDefault ValuePossible values
titleSets window title.nullString, empty string or false causes no title
contentSets window content.nullHTMLElement|String
modalModal|modeless window mode?falseBoolean
positionSets where to show window.'center''center', 'top', 'topRight', 'right', 'bottomRight', 'bottom', 'bottomLeft', 'left', 'topLeft'

Methods

MethodReturnsDescription
show()L.control.window objectRender window.
show( position)L.control.window objectRender window on defined position.
title()HTMLElement|StringGets window title.
title(HTMLElement|String)L.control.window objectSets window title.
content()HTMLElement|StringGets window contet.
content(HTMLElement|String)L.control.window objectSets window content.
close()undefinedHide and remove window.
enableBtn()undefinedEnables the OK button of the window (default).
disableBtn()undefinedDisables the OK button of the window.

Other options

PropertyDescriptionDefault ValuePossible values
closeButtonRender close button?trueBoolean
classNameSets container class to style window.'control-window'String
maxWidthSets maximum width of window container in pixels.600Number
promptJSON object for prompt buttons.undefinedJSON {callback: ..., action: ..., buttonAction: ..., buttonOK: ..., buttonCancel: ...}
prompt.callbackFunction to run after OK button is clicked.undefinede.g. function(){alert('hello')}
prompt.actionFunction to run after ACTION button is clicked.undefinede.g. function(){alert('I\'ll do something')}
prompt.buttonActionText for Action button.button hidden by defaultString
prompt.buttonOKText for OK button.'OK'String
prompt.buttonCancelText for Cancel buttonbutton hidden by defaultString
visibleRender window immediately.falseBoolean

Other Methods

MethodReturnsDescription
showOn( [x,y])L.control.window objectRender window on defined position in pixels ([x,y]).
hide()L.control.window objectHide window, can be rendered by .show() method.
prompt(JSON object)L.control.window objectSets prompt option.
setPromptCallback()L.control.window objectSets prompt option.

Events

EventDescription
showFired when window is shown.
hideFired when window is hidden.
closeFired when window is closed.

License

leaflet-control-window is free software, and may be redistributed under the MIT-LICENSE.

Credit

This whole structure was based on the mapshakers project. So don't be surprised to see somefamiliar code.

Keywords

FAQs

Last updated on 14 Aug 2019

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc