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:
Event | Params | Description | Output |
---|---|---|---|
gm:drawstart | event | Fired when line drawing starts. | map , shape |
gm:create | event | Fired when a line is created. | map , shape , feature |
gm:drawend | event | Fired when line drawing is completed. | map , shape |
Behavior
Line drawing operates by:
- Clicking on the map to place the first vertex
- Moving the mouse to see a preview of the line segment
- Clicking again to add additional vertices
- Double-clicking or clicking on the first vertex to complete the line