Skip to content

Latest commit

 

History

History
45 lines (34 loc) · 1.54 KB

File metadata and controls

45 lines (34 loc) · 1.54 KB
title
Draw Polygon

Draw Polygon Mode

Polygon Mode allows you to create polygons on the map by clicking to add vertices and closing the shape.

You can enable Draw Polygon Mode like this:

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

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

The following events are available on a map instance:

Event Params Description Output
gm:drawstart event Fired when polygon drawing starts. map, shape
gm:create event Fired when a polygon is created. map, shape, feature
gm:drawend event Fired when polygon drawing is completed. map, shape

Behavior

Polygon drawing operates by:

  1. Clicking on the map to place the first vertex
  2. Moving the mouse to see a preview of the polygon segment
  3. Clicking to add additional vertices
  4. Closing the polygon by clicking on the first vertex

Live Draw Polygon Example

import BrowserOnlyGmMap from '../../src/components/map/BrowserOnlyGmMap'; import { drawPolygonOptions } from '../../src/components/examples/mode-options';