Skip to main content

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:

EventParamsDescriptionOutput
gm:drawstarteventFired when polygon drawing starts.map, shape
gm:createeventFired when a polygon is created.map, shape, feature
gm:drawendeventFired 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