WrldIndoorPolygonEditor

The WrldIndoorPolygonEditor is an optional widget for drawing and editing polygons on a WRLD Map. It is based off an implementation of Leaflet.Draw.

Dependencies

  • JQuery
  • JQuery UI
  • wrld.css
  • polygon_editor.js
  • polygon_editor.css

For a full example of how to add a WrldIndoorPolygonEditor to a map, see this example.

Constructor

var polygonEditor = new WrldIndoorPolygonEditor(map, options);
Argument Type Description
map L.Wrld.map The map object that the editor will attach to.
options object An object containing optional parameters, described below.

Options

Options are derived from the original Leaflet.Draw Options with some caveats: Only polygon creation and editing is supported by the WRLD Indoor Polygon Editor. Options are defined as follows:

    const options = {
      draw: {
        polygon: {
          allowIntersection: false,
          allowOverlap: false,
          shapeOptions: {
            color: '#FF00AA',
            weight: 10
          }
        }
      },
      edit: {
        poly: {
          allowIntersection: false,
          allowOverlap: false
        }
      }
    };

Draw options

Options Type Default Description
allowIntersection boolean false Allow polygons to self intersect when creating them.
allowOverlap boolean false Allow polygons to overlap other polygons when creating them.
shapeOptions object * A set of shape options. See the Leaflet Docs for more info.

Edit options

Options Type Default Description
allowIntersection boolean false Allow polygons to self intersect when editing them.
allowOverlap boolean false Allow polygons to overlap other polygons when editing them.

Methods

polygonEditor.getFeatureGroup()

Retrieve the FeatureGroup used to store all created polygons.

polygonEditor.getLeafletDrawControl()

Retrieve the reference to the Leaflet.Draw control.

polygon.setUserData(data)

Apply custom user data to a created polygon.

Argument Type Description
data object Custom user data to set on the polygon.

polygon.getUserData()

Retrieve custom user data from a created polygon. Default is undefined.

Events

See the Leaflet.Draw Events documentation for a list of possible events.

v0.1.2080