lib/leaflet.draw/src/draw/DrawToolbar.js in leaflet-js-0.6.beta4 vs lib/leaflet.draw/src/draw/DrawToolbar.js in leaflet-js-0.7.0
- old
+ new
@@ -1,26 +1,25 @@
L.DrawToolbar = L.Toolbar.extend({
options: {
- polyline: {
- title: 'Draw a polyline'
- },
- polygon: {
- title: 'Draw a polygon'
- },
- rectangle: {
- title: 'Draw a rectangle'
- },
- circle: {
- title: 'Draw a circle'
- },
- marker: {
- title: 'Add a marker'
- }
+ polyline: {},
+ polygon: {},
+ rectangle: {},
+ circle: {},
+ marker: {}
},
initialize: function (options) {
+ // Ensure that the options are merged correctly since L.extend is only shallow
+ for (var type in this.options) {
+ if (this.options.hasOwnProperty(type)) {
+ if (options[type]) {
+ options[type] = L.extend({}, this.options[type], options[type]);
+ }
+ }
+ }
+
L.Toolbar.prototype.initialize.call(this, options);
},
addToolbar: function (map) {
var container = L.DomUtil.create('div', 'leaflet-draw-section'),
@@ -33,57 +32,62 @@
if (this.options.polyline) {
this._initModeHandler(
new L.Draw.Polyline(map, this.options.polyline),
this._toolbarContainer,
buttonIndex++,
- buttonClassPrefix
+ buttonClassPrefix,
+ L.drawLocal.draw.toolbar.buttons.polyline
);
}
if (this.options.polygon) {
this._initModeHandler(
new L.Draw.Polygon(map, this.options.polygon),
this._toolbarContainer,
buttonIndex++,
- buttonClassPrefix
+ buttonClassPrefix,
+ L.drawLocal.draw.toolbar.buttons.polygon
);
}
if (this.options.rectangle) {
this._initModeHandler(
new L.Draw.Rectangle(map, this.options.rectangle),
this._toolbarContainer,
buttonIndex++,
- buttonClassPrefix
+ buttonClassPrefix,
+ L.drawLocal.draw.toolbar.buttons.rectangle
);
}
if (this.options.circle) {
this._initModeHandler(
new L.Draw.Circle(map, this.options.circle),
this._toolbarContainer,
buttonIndex++,
- buttonClassPrefix
+ buttonClassPrefix,
+ L.drawLocal.draw.toolbar.buttons.circle
);
}
if (this.options.marker) {
this._initModeHandler(
new L.Draw.Marker(map, this.options.marker),
this._toolbarContainer,
buttonIndex++,
- buttonClassPrefix
+ buttonClassPrefix,
+ L.drawLocal.draw.toolbar.buttons.marker
);
}
// Save button index of the last button, -1 as we would have ++ after the last button
this._lastButtonIndex = --buttonIndex;
// Create the actions part of the toolbar
this._actionsContainer = this._createActions([
{
- title: 'Cancel drawing',
- text: 'Cancel',
+ title: L.drawLocal.draw.toolbar.actions.title,
+ text: L.drawLocal.draw.toolbar.actions.text,
callback: this.disable,
context: this
}
]);
\ No newline at end of file