PageSourceSearch

https://dubaienergy.netlify.app/src/draw/DrawToolbar.js

js dubaienergy.netlify.app collected 2026-10-03 10:40:30 UTC 2,760 bytes, 110 lines download raw bytes

vendor: 2,760 bytes, lines 1-110
1/**
2 * @class L.DrawToolbar
3 * @aka Toolbar
4 */
5L.DrawToolbar = L.Toolbar.extend({
6
7	statics: {
8		TYPE: 'draw'
9	},
10
11	options: {
12		polyline: {},
13		polygon: {},
14		rectangle: {},
15		circle: {},
16		marker: {},
17		circlemarker: {}
18	},
19
20	// @method initialize(): void
21	initialize: function (options) {
22		// Ensure that the options are merged correctly since L.extend is only shallow
23		for (var type in this.options) {
24			if (this.options.hasOwnProperty(type)) {
25				if (options[type]) {
26					options[type] = L.extend({}, this.options[type], options[type]);
27				}
28			}
29		}
30
31		this._toolbarClass = 'leaflet-draw-draw';
32		L.Toolbar.prototype.initialize.call(this, options);
33	},
34
35	// @method getModeHandlers(): object
36	// Get mode handlers information
37	getModeHandlers: function (map) {
38		return [
39			{
40				enabled: this.options.polyline,
41				handler: new L.Draw.Polyline(map, this.options.polyline),
42				title: L.drawLocal.draw.toolbar.buttons.polyline
43			},
44			{
45				enabled: this.options.polygon,
46				handler: new L.Draw.Polygon(map, this.options.polygon),
47				title: L.drawLocal.draw.toolbar.buttons.polygon
48			},
49			{
50				enabled: this.options.rectangle,
51				handler: new L.Draw.Rectangle(map, this.options.rectangle),
52				title: L.drawLocal.draw.toolbar.buttons.rectangle
53			},
54			{
55				enabled: this.options.circle,
56				handler: new L.Draw.Circle(map, this.options.circle),
57				title: L.drawLocal.draw.toolbar.buttons.circle
58			},
59			{
60				enabled: this.options.marker,
61				handler: new L.Draw.Marker(map, this.options.marker),
62				title: L.drawLocal.draw.toolbar.buttons.marker
63			},
64			{
65				enabled: this.options.circlemarker,
66				handler: new L.Draw.CircleMarker(map, this.options.circlemarker),
67				title: L.drawLocal.draw.toolbar.buttons.circlemarker
68			}
69		];
70	},
71
72	// @method getActions(): object
73	// Get action information
74	getActions: function (handler) {
75		return [
76			{
77				enabled: handler.completeShape,
78				title: L.drawLocal.draw.toolbar.finish.title,
79				text: L.drawLocal.draw.toolbar.finish.text,
80				callback: handler.completeShape,
81				context: handler
82			},
83			{
84				enabled: handler.deleteLastVertex,
85				title: L.drawLocal.draw.toolbar.undo.title,
86				text: L.drawLocal.draw.toolbar.undo.text,
87				callback: handler.deleteLastVertex,
88				context: handler
89			},
90			{
91				title: L.drawLocal.draw.toolbar.actions.title,
92				text: L.drawLocal.draw.toolbar.actions.text,
93				callback: this.disable,
94				context: this
95			}
96		];
97	},
98
99	// @method setOptions(): void
100	// Sets the options to the toolbar
101	setOptions: function (options) {
102		L.setOptions(this, options);
103
104		for (var type in this._modes) {
105			if (this._modes.hasOwnProperty(type) && options.hasOwnProperty(type)) {
106				this._modes[type].handler.setOptions(options[type]);
107			}
108		}
109	}
110});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.