Class: polygonTool

ajs.maps.gmapdraw. polygonTool

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

new polygonTool(map, ctrl, options)

Google maps drawing polygon tool class. Provides methods to draw over the ajs.maps.gmapdraw.map instance

Parameters:
Name Type Description
map ajs.maps.gmapdraw.map The gmapdraw map instance which handles the tool
ctrl String | Element The id attribute or the element itself which controls the tool when clicking over it
options Object A class options object
Properties
Name Type Argument Default Description
max_items_allowed Number <optional>
3 The maximum number of shapes the tool may draw.
Source:

Extends

Methods

activate()

Activates the tool

Inherited From:
Source:
Returns:
void

addItem(item)

Adds an item to the items

Parameters:
Name Type Description
item Object a google map shape
Inherited From:
Source:
Returns:
void

clear()

Clears all drawed points

Source:
Returns:
void

clickHandler()

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

Source:
Returns:
void

deactivate(remove_ctrl)

Removes the tool

Parameters:
Name Type Argument Default Description
remove_ctrl Boolean <optional>
false Whether or not to remove the tool control if the default one
Inherited From:
Source:
Returns:
void

exportData() → {Array}

Returns all the drawed points data

Source:
Returns:
data An array of arrays of objects representing the polygons' vertex coordinates
Type
Array
Example
// 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}]]

getToolName() → {String}

Returns the tool name

Inherited From:
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:
Example
// 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}]]

<protected> options() → {Object}

Returns the class options

Inherited From:
Source:
Returns:
The class options object
Type
Object

prepareTool()

Prepares the tool

Source:
Returns:
void

<protected> protectedProp() → {Object}

Returns the class protected properties

Inherited From:
Source:
Returns:
The class protected properties object
Type
Object

<protected> removeController()

Removes the default tool controller

Inherited From:
Source:
Returns:
void

<protected> setController(ctrl)

Sets the tool controller

Parameters:
Name Type Argument Default Description
ctrl String/Element <optional>
null The id attribute or the element itself which serves as the tool controller, if null the default controller is used.
Inherited From:
Source:
Returns:
void

setDrawing()

Sets the current drawing tool

Inherited From:
Source:
Returns:
void

setMaxItemsAllowed(max)

Sets the maximum number of items that the tool may draw

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

setNextShape(next_shape)

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

Parameters:
Name Type Description
next_shape Whether or not next click has to start a new shape
Inherited From:
Source:
Returns:
void

tipsText() → {String}

Returns the tool help tip text

Source:
Returns:
The tips text
Type
String

updateInfo()

Displays information about rawed points in the console

Source:
Returns:
void