Class: PolygonTool

PolygonTool()

Open Street Map drawing polygon tool class. Provides methods to draw over the Map instance

The polygon drawing tool class, which allows to draw polygons over the gmapdraw map instance.

Constructor

new PolygonTool()

Source:

Extends

Methods

activate() → {Tool}

Activates the tool

Overrides:
Source:
Returns:
instance
Type
Tool

addItem(item)

Adds an item to the items

Parameters:
Name Type Description
item Object a map shape
Overrides:
Source:
Returns:
void

clear()

Clears all polygons

Source:
Returns:
void

clickHandler(evt)

Handles the click event over the map when the tool is the drawing one

Parameters:
Name Type Description
evt L.MouseEvent
Source:
Returns:
void

deactivate(removeCtrlopt) → {Tool}

Removes the tool

Parameters:
Name Type Attributes Default Description
removeCtrl Boolean <optional>
false Whether or not to remove the tool control if the default one
Overrides:
Source:
Returns:
instance
Type
Tool

exportData() → {Array}

Returns all the drawn polygons data

Source:
Returns:
data An array of arrays of objects representing the polygons' vertex coordinates
Type
Array
Example
// exported data, two polygons, the first with 3 vertexes, the second with 4 vertexes.
   [[{lat: 45, lng:7}, {lat:46, lng:7}, {lat: 42, lng: 11}],
    [{lat: 42, lng: 11}, {lat: 41, lng: 10.8}, {lat: 44, lng: 8}, {lat: 33, lng: 12}]]

extendBounds(boundsopt)

Extends the map bounds to fit the polygons

Parameters:
Name Type Attributes Description
bounds LatLngBounds <optional>
the LatLngBounds object
Source:

getToolName() → {String}

Returns the tool name

Overrides:
Source:
Returns:
The tool name
Type
String

importData(data)

Imports the data as polygons

Parameters:
Name Type Description
data Array An array of arrays of objects representing the polygons' vertex coordinates
Source:

prepareTool()

Prepares the tool

Overrides:
Source:
Returns:
void

setDrawing() → {Tool}

Sets the current drawing tool

Overrides:
Source:
Returns:
instance
Type
Tool

setMaxItemsAllowed(max)

Sets the maximum number of items that the tool may draw

Parameters:
Name Type Description
max The maximum number of drawable items
Overrides:
Source:
Returns:
void

setNextShape(enable)

Sets the value of the next shape property (a new click starts a new shape if true)

Parameters:
Name Type Description
enable Whether or not next click has to start a new shape
Overrides:
Source:
Returns:
void

setSelected()

Sets the css selected class

Overrides:
Source:
Returns:
void

setUnselected() → {Tool}

Removes the css selected class

Overrides:
Source:
Returns:
instance
Type
Tool

tipsText() → {String}

Returns the tool help tip text

Source:
Returns:
The tips text
Type
String