1.0.5 • Published 6 years ago

leaflet-dialog v1.0.5

Weekly downloads
122
License
-
Repository
github
Last release
6 years ago

Leaflet.Dialog

A dialog modal window that is resizable and positionable on the map.

Check out the Demo Here

Installation:

# Bower:
bower install Leaflet.Dialog
# NPM:
npm install leaflet-dialog

Adding a dialog box:

// After you've set up your map and layers, add the modal window by running:
var dialog = L.control.dialog(options)
              .setContent("<p>Hello! Welcome to your nice new dialog box!</p>")
              .addTo(map);

Working with the dialog box:

Close the window:

dialog.close();

Open the window:

dialog.open();

Destroy the window:

dialog.destroy();

Reset the contents:

dialog.setContent("<p>Here's some new content!</p>");

Options:

PropertyTypeDefaultDescription
sizeArray 300, 300 An array of the starting width and height values (in pixels).
minSizeArray 100, 100 An array with the minimum resize width and height (in pixels).
maxSizeArray 350, 350 An array with the maximum resize width and height (in pixels).
anchorArray 250, 250 The starting point anchor location (from the upper left) in pixels.
positionString'topleft'The leaflet control div to place the modal inside, as a starting reference point.
initOpenBooleantrueWhether or not to initialize in an open state.

Methods:

MethodReturnsExampleDescription
open()thisdialog.open();Opens the dialog window.
close()thisdialog.close();Closes the dialog window.
destroy()thisdialog.destroy();Removes the dialog box from the window.
setLocation( Array anchor location )thisdialog.setLocation( 15, 15 );Move the dialog box to the specified pixel location ( Relative to the 'position' option )
setSize( Array size )thisdialog.setSize( 150, 150 );Resize the dialog window to the specified width and height.
lock()thisdialog.lock();Hides all visible dialog window controls.
unlock()thisdialog.unlock();Re-instates all dialog window controls.
freeze()thisdialog.freeze();Hides all visible dialog window movement/sizing controls.
unfreeze()thisdialog.unfreeze();Re-instates all dialog window movement/sizing controls.
hideClose()thisdialog.hideClose();Hides the closing 'x'
showClose()thisdialog.showClose();Shows the closing 'x'
hideResize()thisdialog.hideResize();Hides the resizing symbol
showResize()thisdialog.showResize();Shows the resizing symbol

Events:

EventDataDescription
dialog:openedthisFired when open() is called.
dialog:closedthisFired when close() is called or when the 'x' is clicked.
dialog:destroyedthisFired when destroy() is called.
dialog:lockedthisFired when lock() is called.
dialog:unlockedthisFired when unlock() is called.
dialog:frozenthisFired when freeze() is called.
dialog:unfrozenthisFired when unfreeze() is called.
dialog:updatedthisFired when contents are set or when added to the map.
dialog:resizestartthisFired when the resize button is clicked.
dialog:resizingthisFired continuously as the resize button is dragged.
dialog:resizeendthisFired when the resize button click is released.
dialog:movestartthisFired when the move button is clicked.
dialog:movingthisFired continuously as the move button is dragged.
dialog:moveendthisFired when the move button click is released.
dialog:closehiddenthisFired when hideClose() is called.
dialog:closeshownthisFired when the showClose() is called.
dialog:resizehiddenthisFired when hideResize() is called.
dialog:resizeshownthisFired when the showResize() is called.