Class: Draw

cercaliagl.interaction/Draw


Provides draw interaction. It is possible to draw different geometry types. Geometry types available are:

  • - cercaliagl.interaction.Draw.Type.POINT
  • - cercaliagl.interaction.Draw.Type.LINE
  • - cercaliagl.interaction.Draw.Type.POLYGON
  • - cercaliagl.interaction.Draw.Type.RECTANGLE

This interaction can be accessed via map object and draw a feature:

const map = new cercaliagl.Map({ target: 'map', controls: []});
const drawInteraction = map.getDrawInteraction();
drawInteraction.enable(cercaliagl.interaction.Draw.Type.POLYGON, function(data) {
  console.log('Geometry', data.geometry);
});

new Draw(map)

Name Type Description
map module:cercaliagl/Map~Map

Methods

Disable interaction.

disableSnap()

Disables snap.

enable(type, callbackFn)

Enable interaction gived a geometry type. Geometry types available are: point, line, polygon, rectangle.
You can access them via:

  • cercaliagl.interaction.Draw.Type.POINT
  • cercaliagl.interaction.Draw.Type.LINE
  • cercaliagl.interaction.Draw.Type.POLYGON
  • cercaliagl.interaction.Draw.Type.RECTANGLE

Optionally you can specify a callback function. Callback function received feature as parameter.
Name Type Description
type string

Type

callbackFn function

Enables snap.

isActive(){boolean}

Return true if interaction is active. Else false.