Draw Rectangle Mode
Rectangle Mode allows you to create rectangles on the map by clicking and dragging to define opposite corners.
You can enable Draw Rectangle Mode like this:
map.gm.enableDraw('rectangle');
map.gm.disableDraw();
map.gm.toggleDraw('rectangle');
map.gm.drawEnabled('rectangle');
// Or like this:
map.gm.enableMode('draw', 'rectangle');
map.gm.disableMode('draw', 'rectangle');
map.gm.toggleMode('draw', 'rectangle');
map.gm.isModeEnabled('draw', 'rectangle');
The following events are available on a map instance:
Event | Params | Description | Output |
---|---|---|---|
gm:drawstart | event | Fired when rectangle drawing starts. | map , shape |
gm:create | event | Fired when a rectangle is created. | map , shape , feature |
gm:drawend | event | Fired when rectangle drawing is completed. | map , shape |
Behavior
Rectangle drawing operates by:
- Clicking and holding on the map to set the first corner
- Dragging to define the rectangle dimensions
- Releasing the mouse button to complete the rectangle