new map(canvas, options)
Google maps drawing class, provides tools for drawing over a google map instance, and export drawed data.
Parameters:
Name | Type | Argument | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
canvas |
String | The id attribute of the map container | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
options |
Object |
<optional> |
A class options object
Properties
|
- Source:
- src/maps/gmapdraw.js, line 94
Example
var mymap = new ajs.maps.gmapdraw.map('my_map_canvas_id', {
tools: {
point: {
options: {
max_items: 5
}
},
circle: {}
}
});
Methods
-
<protected> addControllersContainer()
Adds an empty container over the map which may contain default controllers if any
-
- Source:
- src/maps/gmapdraw.js, line 165
Returns:
void -
addDefaultCtrl(ctrl)
Adds a controller in the default controllers container
-
Parameters:
Name Type Description ctrl
Element The controller to be added - Source:
- src/maps/gmapdraw.js, line 180
Returns:
void -
addTool(tool)
Adds a drawing tool
-
Parameters:
Name Type Description tool
ajs.maps.gmapdraw.tool The tool object - Source:
- src/maps/gmapdraw.js, line 219
Returns:
void -
clearMap()
Clears the map
-
- Source:
- src/maps/gmapdraw.js, line 569
Returns:
void -
exportMap() → {Object}
Exports the map drawed shapes as data points
-
- Source:
- src/maps/gmapdraw.js, line 606
Returns:
data The drawed data in an object format- Type
- Object
Example
{ '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} ] }
-
geocoderCenter()
Sets the map center converting the geocoder_field input address in a LatLng point
-
- Source:
- src/maps/gmapdraw.js, line 529
Returns:
void -
geocoderDraw()
Fires a map click in a LatLng point converted from the geocoder_field input address
-
- Source:
- src/maps/gmapdraw.js, line 548
Returns:
void -
getDrawingTool() → {ajs.maps.gmapdraw.tool}
Gets the active drawing tool
-
- Source:
- src/maps/gmapdraw.js, line 472
Returns:
The drawing tool -
getTool(tool_name) → {ajs.maps.gmapdraw.tool|null}
Gets a tool object giving its name
-
Parameters:
Name Type Description tool_name
String One of the supported tools name - Source:
- src/maps/gmapdraw.js, line 236
Returns:
The tool object if set or null- Type
- ajs.maps.gmapdraw.tool | null
-
gmap() → {google.maps.Map}
Returns the google map instance google.maps.Map
-
The google map class instance allows to customize direclty some map properties using the google.maps.Map public interface
- Source:
- src/maps/gmapdraw.js, line 674
Returns:
The google map instance- Type
- google.maps.Map
Example
var mygmap = ajs.maps.gmapdraw.map.gmap(); mygmap.setCenter(new google.maps.LatLng(45, 7));
-
importMap(data)
Imports data to the map
-
Data must be in the same form as the exported ones, see ajs.maps.gmapdraw.map#exportMap
Parameters:
Name Type Description data
Object The drawed data in an object format - Source:
- src/maps/gmapdraw.js, line 628
-
initControllers()
Initializes all the map controllers
-
- Source:
- src/maps/gmapdraw.js, line 310
Returns:
void -
initMap()
-
Initializes the google map and its events
- Source:
- src/maps/gmapdraw.js, line 281
Returns:
void -
initMapTips() → {String}
Returns the init text shown in the tips controller
-
- Source:
- src/maps/gmapdraw.js, line 503
Returns:
text The initial tip text- Type
- String
-
initTools()
Initializes the map set tools
-
- Source:
- src/maps/gmapdraw.js, line 480
Returns:
void -
mapClick(point)
Handles the click event over the map, calling the active tool handler
-
This method is public since it has to be called by google maps api
Parameters:
Name Type Description point
Object The callback parameter returned by the google.maps event handler - Source:
- src/maps/gmapdraw.js, line 513
Returns:
void -
<protected> processOptions()
Processes the option object setting properly some class properties
-
- Source:
- src/maps/gmapdraw.js, line 193
Returns:
void -
<protected> removeClearMapController()
Removes the clear map controller depending on the options.clear_map_ctrl value
-
- Source:
- src/maps/gmapdraw.js, line 350
Returns:
void -
<protected> removeExportMapController()
Removes the export map controller depending on the options.clear_map_ctrl value
-
- Source:
- src/maps/gmapdraw.js, line 386
Returns:
void -
<protected> removeGeocoderMapField()
Removes the geocoder input text field and its controllers
-
- Source:
- src/maps/gmapdraw.js, line 448
Returns:
void -
<protected> removeTipsMapController()
Removes the tips map controller depending on the options.tips_map_ctrl value
-
- Source:
- src/maps/gmapdraw.js, line 420
Returns:
void -
removeTool(tool_name, tool)
Removes a drawing tool
-
Parameters:
Name Type Description tool_name
String The name of the tool to be removed tool
ajs.maps.gmapdraw.tool The tool object - Source:
- src/maps/gmapdraw.js, line 254
Returns:
void -
render()
Renders the widget
-
- Source:
- src/maps/gmapdraw.js, line 268
Returns:
void -
setCenter(center)
Sets the center of the map
-
Parameters:
Name Type Description center
Array The [lat, lng] coordinates array - Source:
- src/maps/gmapdraw.js, line 683
Returns:
void -
<protected> setClearMapController()
Sets the clear map controller depending on the options.clear_map_ctrl value
-
- Source:
- src/maps/gmapdraw.js, line 325
Returns:
void -
setClearMapCtrl(ctrl)
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 id attribute or an element the clear map functionality is attached to the element.- Source:
- src/maps/gmapdraw.js, line 709
Returns:
void -
setDrawingTool(tool)
Sets the active drawing tool name
-
Parameters:
Name Type Description tool
ajs.maps.gmapdraw.tool | null The actual drawing tool, null to have no active tool - Source:
- src/maps/gmapdraw.js, line 461
Returns:
void -
<protected> setExportMapController()
Sets the export map controller depending on the options.export_map_ctrl value
-
- Source:
- src/maps/gmapdraw.js, line 361
Returns:
void -
setExportMapCtrl(ctrl)
Sets the export map controller
-
Parameters:
Name Type Description ctrl
String | Element The export map controller. If 'default' the built-in controller is used, if null
the export map functionality is removed. If id attribute or an element the export map functionality is attached to the element.- Source:
- src/maps/gmapdraw.js, line 724
Returns:
void -
setGeocoderMapField(set)
Sets the geocoder map field option
-
Parameters:
Name Type Description set
Boolean Whether or not to activate the geocoder functionality - Source:
- src/maps/gmapdraw.js, line 737
Returns:
void -
<protected> setGeocoderMapFieldController()
Sets the geocoder input text field and its controllers
-
- Source:
- src/maps/gmapdraw.js, line 430
Returns:
void -
<protected> setTipsMapController()
Sets the help tips map controller depending on the options.tips_map_ctrl value
-
- Source:
- src/maps/gmapdraw.js, line 397
Returns:
void -
setTipsMapCtrl(ctrl)
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 id attribute or an element the functionality is attached to the element.- Source:
- src/maps/gmapdraw.js, line 755
Returns:
void -
setZoom(zoom)
Sets the zoom of the map
-
Parameters:
Name Type Description zoom
Number The zoom level - Source:
- src/maps/gmapdraw.js, line 695
Returns:
void -
updateTips(text)
Updates the text displayed in the tips controller
-
Parameters:
Name Type Description text
String The tip text - Source:
- src/maps/gmapdraw.js, line 493
Returns:
void