Skip to content

Widgets

Rodrigo E. Principe edited this page Mar 15, 2019 · 6 revisions

widgets module

Custom widgets for the ui

To use it:

var widgets = require('users/fitoprincipe/geetools:widgets')

ClosePanel(options)

A Panel with an X button for "closing" it. To make it work you must add it to another Panel or Map with its method addTo or insertTo, otherwise it will not be able to close it. Parameters are similar to ui.Panel. The difference is that it has a parameter inner_style to set the style for the inner Panel, like backgroundColor or border. To close the panel using another widget it has a close method.

Options:

  • widgets: a list of widgets to add to the panel
  • style:
    • position: position of the panel
    • backgroundColor: background color of the panel
    • margin: margin of the panel
    • shown: shown option of the panel
    • border: border of the panel
  • inner_style:
    • position: position of the inner panel
    • backgroundColor: background color of the inner panel
    • margin: margin of the inner panel
    • shown: shown option of the inner panel
  • layout: layout of the panel

Methods:

  • addTo(widget): adds the panel to the parsed widget
  • insertTo(widget, position): inserts the panel to the parsed widget in the parsed position
  • close(): closes the panel
  • build(): builds the widget. If you need to add the widget without using addTo or insertTo, use this method to get the actual panel. For example:
var panel = new ClosePanel()
Map.add(panel.build())
  • onClose(callback): registers a callback that's fired when the panel is closed. The argument for the callback is the ClosePanel widget

example: https://code.earthengine.google.com/07d13af7a46f0c9ca8d908b3cbab068c

DrawingPanel(options)

Sometimes you need to access new drawn geometries to do some process within an app, but you cannot access the geometries scope.

Options:

  • width: panel width
  • height: panel height
  • border: panel border (example: '1px solid black')
  • position: panel position (example: 'top-center')
  • layout: panel layout (example: ui.Panel.Layout.flow('vertical'))
  • drawings: the type of drawings to include in dropdown, currently only 'polygon' is available
  • map: the map instance. Defaults to Map
  • map_callback: if the map has already a callback for onClick, must be provided here to recover it
  • map_callback_id: if the map has already a callback for onClick, must be provided its ID here to recover it
  • title: a title for the panel

Methods:

  • start(): starts the drawing
  • stop(): stops the drawing
  • addTo(widget): adds the panel to the parsed widget
  • insertTo(widget, position): inserts the panel to the parsed widget in the parsed position
  • build(): builds the widget. If you need to add the widget without using addTo or insertTo, use this method to get the actual panel. See
  • onStart(callback): registers a callback that's fired when the drawing starts. The argument for the callback is the DrawingPanel widget
  • onStop(callback): registers a callback that's fired when the drawing stops. The argument for the callback is first the DrawingPanel widget and second the actual drawing (geometry).

example: https://code.earthengine.google.com/eea12e7b2bdcc153ec6420d3cc893b98

Clone this wiki locally