Constructor
new Map(canvas, optionsopt)
Constrcuts a Map
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
canvas |
Element | String | The map container element as selector or jQuery element | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
options |
Object |
<optional> |
A class options object
Properties
|
Example
var mymap = new osmdrawer.Map('my_map_canvas_id', {
tools: {
point: {
options: {
max_items: 5
}
},
circle: {}
}
});
Methods
addDefaultCtrl(ctrl)
Adds a controller in the default controllers container
Parameters:
Name | Type | Description |
---|---|---|
ctrl |
Object | The jQuery controller element to be added |
Returns:
addTool(tool) → {Map}
Adds a drawing tool
Parameters:
Name | Type | Description |
---|---|---|
tool |
osmdrawer.Tool | The tool object |
Returns:
- Type
- Map
clearMap() → {Map}
Clears the map
Returns:
- Type
- Map
exportMap() → {Object}
Exports the map drawed shapes as data points
Returns:
- Type
- Object
Example
// exported data
{
'point': [
{lat: 45, lng: 12},
{lat: 43, lng: 16}
],
'polyline': [
[
{lat: 45, lng: 12},
{lat: 42, lng: 12},
{lat: 42.6, lng: 11}
],
[
{lat: 36.7, lng: 11.2},
{lat: 39, lng: 12}
],
],
'circle': [
{lat: 45, lng: 12, radius: 10000},
{lat: 44, lng: 11, radius: 230000}
]
}
(async) geocoderCenter() → {Map}
Sets the map center converting the geocoder field input address in a LatLng point
Returns:
- Type
- Map
(async) geocoderDraw() → {Map}
Fires a map click in a LatLng point converted from the geocoder field input address
Returns:
- Type
- Map
getDrawingTool() → {osmdrawer.Tool}
Gets the active drawing tool
Returns:
- Type
- osmdrawer.Tool
getTool(toolName) → {osmdrawer.Tool|null}
Gets a tool object giving its name
Parameters:
Name | Type | Description |
---|---|---|
toolName |
String | One of the supported tools name |
Returns:
- Type
- osmdrawer.Tool | null
gmap() → {Map}
Returns the leaflet map instance
Returns:
- Type
- Map
importMap(data) → {Map}
Imports data
Parameters:
Name | Type | Description |
---|---|---|
data |
Object | The data object |
Returns:
- Type
- Map
removeTool(toolName, tool) → {Map}
Removes a drawing tool
Parameters:
Name | Type | Description |
---|---|---|
toolName |
String | The name of the tool to be removed |
tool |
osmdrawer.Tool | The tool object |
Returns:
- Type
- Map
render() → {Map}
Renders the widget
Returns:
- Type
- Map
setCenter(center) → {Map}
Sets the center of the map
Parameters:
Name | Type | Description |
---|---|---|
center |
Array | The [lat, lng] coordinates array |
Returns:
- Type
- Map
setClearMapCtrl(ctrl) → {Map}
Sets the clear map controller
Parameters:
Name | Type | Description |
---|---|---|
ctrl |
String | Element | The clear map controller.
If 'default' the built-in controller is used, if null the clear map
functionality is removed. If selctor or jQuery element the clear map functionality
is attached to the element. |
Returns:
- Type
- Map
setDrawingTool(tool) → {Map}
Sets the active drawing tool name
Parameters:
Name | Type | Description |
---|---|---|
tool |
osmdrawer.Tool | null | The actual drawing tool, null to have no active tool |
Returns:
- Type
- Map
setExportMapCtrl(ctrl) → {Map}
Sets the export map controller
Parameters:
Name | Type | Description |
---|---|---|
ctrl |
String | Element | The clear map controller.
If 'default' the built-in controller is used, if null the export map
functionality is removed. If selctor or jQuery element the export map functionality
is attached to the element. |
Returns:
- Type
- Map
setFullscreen(activate) → {Map}
Sets the fullscreen option
Parameters:
Name | Type | Description |
---|---|---|
activate |
Boolean | Whether or not to activate the fullscreen functionality |
Returns:
- Type
- Map
setGeocoderMapField(activate) → {Map}
Sets the geocoder map field option
Parameters:
Name | Type | Description |
---|---|---|
activate |
Boolean | Whether or not to activate the geocoder functionality |
Returns:
- Type
- Map
setTipsMapCtrl(ctrl) → {Map}
Sets the tips map controller
Parameters:
Name | Type | Description |
---|---|---|
ctrl |
String | Element | The help tips map controller (shows tips about drawing tools).
If 'default' the built-in controller is used, if null the tips box is not shown,
if selector or jQuery element the functionality is attached to the element |
Returns:
- Type
- Map
setZoom(zoom) → {Map}
Sets the zoom of the map
Parameters:
Name | Type | Description |
---|---|---|
zoom |
Number | The zoom level |
Returns:
- Type
- Map
updateTips(html)
Updates the text displayed in the tips controller
Parameters:
Name | Type | Description |
---|---|---|
html |
String | The tip text |