Class: PolylineTool

PolylineTool(map, ctrl, options)

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

The polyline drawing tool class, which allows to draw polylines over the gmapdraw map instance.

Constructor

new PolylineTool(map, ctrl, options)

Constructs a polyline tool
Parameters:
Name Type Description
map Map The map instance which handles the tool
ctrl String | Object The selector or jQuery element which controls the tool when clicking over it, set to null to have the default controller
options Object A class options object
Properties
Name Type Attributes Default Description
maxItemsAllowed Number <optional>
1 The maximum number of shapes the tool may draw.
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 polylines

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 polylines data

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

extendBounds(boundsopt)

Extends the map bounds to fit the polylines

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 polylines

Parameters:
Name Type Description
data Array An array of arrays of objects representing the polylines' points 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