Skip to main content

Draw Line Mode

Line Mode allows you to create lines on the map by clicking to add vertices.

You can enable Draw Line Mode like this:

map.gm.enableDraw('line');
map.gm.disableDraw();
map.gm.toggleDraw('line');
map.gm.drawEnabled('line');

// Or like this:
map.gm.enableMode('draw', 'line');
map.gm.disableMode('draw', 'line');
map.gm.toggleMode('draw', 'line');
map.gm.isModeEnabled('draw', 'line');

The following events are available on a map instance:

EventParamsDescriptionOutput
gm:drawstarteventFired when line drawing starts.map, shape
gm:createeventFired when a line is created.map, shape, feature
gm:drawendeventFired when line drawing is completed.map, shape

Behavior

Line drawing operates by:

  1. Clicking on the map to place the first vertex
  2. Moving the mouse to see a preview of the line segment
  3. Clicking again to add additional vertices
  4. Double-clicking or clicking on the first vertex to complete the line

Live Draw Line Example