From e90ec6d4271613845b3a7518bfbfa0f96a0d69d7 Mon Sep 17 00:00:00 2001 From: BONDA Sai Aswath Date: Tue, 19 Oct 2021 16:34:24 +0530 Subject: [PATCH 1/6] Added changes for showing radius in circle edit --- src/edit/handler/Edit.Circle.js | 1 + src/edit/handler/Edit.CircleMarker.js | 2 +- src/edit/handler/EditToolbar.Edit.js | 3 ++- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/edit/handler/Edit.Circle.js b/src/edit/handler/Edit.Circle.js index 9a14f5224..09aade594 100644 --- a/src/edit/handler/Edit.Circle.js +++ b/src/edit/handler/Edit.Circle.js @@ -33,6 +33,7 @@ L.Edit.Circle = L.Edit.CircleMarker.extend({ this._shape.setRadius(radius); if (this._map.editTooltip) { + this._map._editTooltip.updatePosition(latlng); this._map._editTooltip.updateContent({ text: L.drawLocal.edit.handlers.edit.tooltip.subtext + '
' + L.drawLocal.edit.handlers.edit.tooltip.text, subtext: L.drawLocal.draw.handlers.circle.radius + ': ' + diff --git a/src/edit/handler/Edit.CircleMarker.js b/src/edit/handler/Edit.CircleMarker.js index 4f7641508..101d3b17c 100644 --- a/src/edit/handler/Edit.CircleMarker.js +++ b/src/edit/handler/Edit.CircleMarker.js @@ -7,7 +7,7 @@ L.Edit = L.Edit || {}; L.Edit.CircleMarker = L.Edit.SimpleShape.extend({ _createMoveMarker: function () { var center = this._shape.getLatLng(); - + this._map._editTooltip = new L.Draw.Tooltip(this._map); this._moveMarker = this._createMarker(center, this.options.moveIcon); }, diff --git a/src/edit/handler/EditToolbar.Edit.js b/src/edit/handler/EditToolbar.Edit.js index c85d4874c..b789c3670 100644 --- a/src/edit/handler/EditToolbar.Edit.js +++ b/src/edit/handler/EditToolbar.Edit.js @@ -101,7 +101,8 @@ L.EditToolbar.Edit = L.Handler.extend({ if (this._map) { // Clean up selected layers. this._featureGroup.eachLayer(this._disableLayerEdit, this); - + this._map._editTooltip.dispose(); + this._map._editTooltip = null; // Clear the backups of the original layers this._uneditedLayerProps = {}; From edc37c5cbded7a3d4bf739767beb9d4ecfd2f4f9 Mon Sep 17 00:00:00 2001 From: BONDA Sai Aswath Date: Wed, 20 Oct 2021 19:17:49 +0530 Subject: [PATCH 2/6] Added leaflet draw files --- dist/leaflet.draw-src.css | 325 +++ dist/leaflet.draw-src.js | 4776 +++++++++++++++++++++++++++++++++++++ dist/leaflet.draw-src.map | 1 + dist/leaflet.draw.css | 10 + dist/leaflet.draw.js | 10 + 5 files changed, 5122 insertions(+) create mode 100644 dist/leaflet.draw-src.css create mode 100644 dist/leaflet.draw-src.js create mode 100644 dist/leaflet.draw-src.map create mode 100644 dist/leaflet.draw.css create mode 100644 dist/leaflet.draw.js diff --git a/dist/leaflet.draw-src.css b/dist/leaflet.draw-src.css new file mode 100644 index 000000000..dffca06b8 --- /dev/null +++ b/dist/leaflet.draw-src.css @@ -0,0 +1,325 @@ +/* ================================================================== */ +/* Toolbars +/* ================================================================== */ + +.leaflet-draw-section { + position: relative; +} + +.leaflet-draw-toolbar { + margin-top: 12px; +} + +.leaflet-draw-toolbar-top { + margin-top: 0; +} + +.leaflet-draw-toolbar-notop a:first-child { + border-top-right-radius: 0; +} + +.leaflet-draw-toolbar-nobottom a:last-child { + border-bottom-right-radius: 0; +} + +.leaflet-draw-toolbar a { + background-image: url('images/spritesheet.png'); + background-image: linear-gradient(transparent, transparent), url('images/spritesheet.svg'); + background-repeat: no-repeat; + background-size: 300px 30px; + background-clip: padding-box; +} + +.leaflet-retina .leaflet-draw-toolbar a { + background-image: url('images/spritesheet-2x.png'); + background-image: linear-gradient(transparent, transparent), url('images/spritesheet.svg'); +} + +.leaflet-draw a { + display: block; + text-align: center; + text-decoration: none; +} + +.leaflet-draw a .sr-only { + position: absolute; + width: 1px; + height: 1px; + padding: 0; + margin: -1px; + overflow: hidden; + clip: rect(0, 0, 0, 0); + border: 0; +} + +/* ================================================================== */ +/* Toolbar actions menu +/* ================================================================== */ + +.leaflet-draw-actions { + display: none; + list-style: none; + margin: 0; + padding: 0; + position: absolute; + left: 26px; /* leaflet-draw-toolbar.left + leaflet-draw-toolbar.width */ + top: 0; + white-space: nowrap; +} + +.leaflet-touch .leaflet-draw-actions { + left: 32px; +} + +.leaflet-right .leaflet-draw-actions { + right: 26px; + left: auto; +} + +.leaflet-touch .leaflet-right .leaflet-draw-actions { + right: 32px; + left: auto; +} + +.leaflet-draw-actions li { + display: inline-block; +} + +.leaflet-draw-actions li:first-child a { + border-left: none; +} + +.leaflet-draw-actions li:last-child a { + -webkit-border-radius: 0 4px 4px 0; + border-radius: 0 4px 4px 0; +} + +.leaflet-right .leaflet-draw-actions li:last-child a { + -webkit-border-radius: 0; + border-radius: 0; +} + +.leaflet-right .leaflet-draw-actions li:first-child a { + -webkit-border-radius: 4px 0 0 4px; + border-radius: 4px 0 0 4px; +} + +.leaflet-draw-actions a { + background-color: #919187; + border-left: 1px solid #AAA; + color: #FFF; + font: 11px/19px "Helvetica Neue", Arial, Helvetica, sans-serif; + line-height: 28px; + text-decoration: none; + padding-left: 10px; + padding-right: 10px; + height: 28px; +} + +.leaflet-touch .leaflet-draw-actions a { + font-size: 12px; + line-height: 30px; + height: 30px; +} + +.leaflet-draw-actions-bottom { + margin-top: 0; +} + +.leaflet-draw-actions-top { + margin-top: 1px; +} + +.leaflet-draw-actions-top a, +.leaflet-draw-actions-bottom a { + height: 27px; + line-height: 27px; +} + +.leaflet-draw-actions a:hover { + background-color: #A0A098; +} + +.leaflet-draw-actions-top.leaflet-draw-actions-bottom a { + height: 26px; + line-height: 26px; +} + +/* ================================================================== */ +/* Draw toolbar +/* ================================================================== */ + +.leaflet-draw-toolbar .leaflet-draw-draw-polyline { + background-position: -2px -2px; +} + +.leaflet-touch .leaflet-draw-toolbar .leaflet-draw-draw-polyline { + background-position: 0 -1px; +} + +.leaflet-draw-toolbar .leaflet-draw-draw-polygon { + background-position: -31px -2px; +} + +.leaflet-touch .leaflet-draw-toolbar .leaflet-draw-draw-polygon { + background-position: -29px -1px; +} + +.leaflet-draw-toolbar .leaflet-draw-draw-rectangle { + background-position: -62px -2px; +} + +.leaflet-touch .leaflet-draw-toolbar .leaflet-draw-draw-rectangle { + background-position: -60px -1px; +} + +.leaflet-draw-toolbar .leaflet-draw-draw-circle { + background-position: -92px -2px; +} + +.leaflet-touch .leaflet-draw-toolbar .leaflet-draw-draw-circle { + background-position: -90px -1px; +} + +.leaflet-draw-toolbar .leaflet-draw-draw-marker { + background-position: -122px -2px; +} + +.leaflet-touch .leaflet-draw-toolbar .leaflet-draw-draw-marker { + background-position: -120px -1px; +} + +.leaflet-draw-toolbar .leaflet-draw-draw-circlemarker { + background-position: -273px -2px; +} + +.leaflet-touch .leaflet-draw-toolbar .leaflet-draw-draw-circlemarker { + background-position: -271px -1px; +} + +/* ================================================================== */ +/* Edit toolbar +/* ================================================================== */ + +.leaflet-draw-toolbar .leaflet-draw-edit-edit { + background-position: -152px -2px; +} + +.leaflet-touch .leaflet-draw-toolbar .leaflet-draw-edit-edit { + background-position: -150px -1px; +} + +.leaflet-draw-toolbar .leaflet-draw-edit-remove { + background-position: -182px -2px; +} + +.leaflet-touch .leaflet-draw-toolbar .leaflet-draw-edit-remove { + background-position: -180px -1px; +} + +.leaflet-draw-toolbar .leaflet-draw-edit-edit.leaflet-disabled { + background-position: -212px -2px; +} + +.leaflet-touch .leaflet-draw-toolbar .leaflet-draw-edit-edit.leaflet-disabled { + background-position: -210px -1px; +} + +.leaflet-draw-toolbar .leaflet-draw-edit-remove.leaflet-disabled { + background-position: -242px -2px; +} + +.leaflet-touch .leaflet-draw-toolbar .leaflet-draw-edit-remove.leaflet-disabled { + background-position: -240px -2px; +} + +/* ================================================================== */ +/* Drawing styles +/* ================================================================== */ + +.leaflet-mouse-marker { + background-color: #fff; + cursor: crosshair; +} + +.leaflet-draw-tooltip { + background: rgb(54, 54, 54); + background: rgba(0, 0, 0, 0.5); + border: 1px solid transparent; + -webkit-border-radius: 4px; + border-radius: 4px; + color: #fff; + font: 12px/18px "Helvetica Neue", Arial, Helvetica, sans-serif; + margin-left: 20px; + margin-top: -21px; + padding: 4px 8px; + position: absolute; + visibility: hidden; + white-space: nowrap; + z-index: 6; +} + +.leaflet-draw-tooltip:before { + border-right: 6px solid black; + border-right-color: rgba(0, 0, 0, 0.5); + border-top: 6px solid transparent; + border-bottom: 6px solid transparent; + content: ""; + position: absolute; + top: 7px; + left: -7px; +} + +.leaflet-error-draw-tooltip { + background-color: #F2DEDE; + border: 1px solid #E6B6BD; + color: #B94A48; +} + +.leaflet-error-draw-tooltip:before { + border-right-color: #E6B6BD; +} + +.leaflet-draw-tooltip-single { + margin-top: -12px +} + +.leaflet-draw-tooltip-subtext { + color: #f8d5e4; +} + +.leaflet-draw-guide-dash { + font-size: 1%; + opacity: 0.6; + position: absolute; + width: 5px; + height: 5px; +} + +/* ================================================================== */ +/* Edit styles +/* ================================================================== */ + +.leaflet-edit-marker-selected { + background-color: rgba(254, 87, 161, 0.1); + border: 4px dashed rgba(254, 87, 161, 0.6); + -webkit-border-radius: 4px; + border-radius: 4px; + box-sizing: content-box; +} + +.leaflet-edit-move { + cursor: move; +} + +.leaflet-edit-resize { + cursor: pointer; +} + +/* ================================================================== */ +/* Old IE styles +/* ================================================================== */ + +.leaflet-oldie .leaflet-draw-toolbar { + border: 1px solid #999; +} diff --git a/dist/leaflet.draw-src.js b/dist/leaflet.draw-src.js new file mode 100644 index 000000000..21f4d5059 --- /dev/null +++ b/dist/leaflet.draw-src.js @@ -0,0 +1,4776 @@ +/* + Leaflet.draw 1.0.3+e90ec6d, a plugin that adds drawing and editing tools to Leaflet powered maps. + (c) 2012-2017, Jacob Toye, Jon West, Smartrak, Leaflet + + https://github.com/Leaflet/Leaflet.draw + http://leafletjs.com + */ +(function (window, document, undefined) {/** + * Leaflet.draw assumes that you have already included the Leaflet library. + */ +L.drawVersion = "1.0.3+e90ec6d"; +/** + * @class L.Draw + * @aka Draw + * + * + * To add the draw toolbar set the option drawControl: true in the map options. + * + * @example + * ```js + * var map = L.map('map', {drawControl: true}).setView([51.505, -0.09], 13); + * + * L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', { + * attribution: '© OpenStreetMap contributors' + * }).addTo(map); + * ``` + * + * ### Adding the edit toolbar + * To use the edit toolbar you must initialise the Leaflet.draw control and manually add it to the map. + * + * ```js + * var map = L.map('map').setView([51.505, -0.09], 13); + * + * L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', { + * attribution: '© OpenStreetMap contributors' + * }).addTo(map); + * + * // FeatureGroup is to store editable layers + * var drawnItems = new L.FeatureGroup(); + * map.addLayer(drawnItems); + * + * var drawControl = new L.Control.Draw({ + * edit: { + * featureGroup: drawnItems + * } + * }); + * map.addControl(drawControl); + * ``` + * + * The key here is the featureGroup option. This tells the plugin which FeatureGroup contains the layers that + * should be editable. The featureGroup can contain 0 or more features with geometry types Point, LineString, and Polygon. + * Leaflet.draw does not work with multigeometry features such as MultiPoint, MultiLineString, MultiPolygon, + * or GeometryCollection. If you need to add multigeometry features to the draw plugin, convert them to a + * FeatureCollection of non-multigeometries (Points, LineStrings, or Polygons). + */ +L.Draw = {}; + +/** + * @class L.drawLocal + * @aka L.drawLocal + * + * The core toolbar class of the API — it is used to create the toolbar ui + * + * @example + * ```js + * var modifiedDraw = L.drawLocal.extend({ + * draw: { + * toolbar: { + * buttons: { + * polygon: 'Draw an awesome polygon' + * } + * } + * } + * }); + * ``` + * + * The default state for the control is the draw toolbar just below the zoom control. + * This will allow map users to draw vectors and markers. + * **Please note the edit toolbar is not enabled by default.** + */ +L.drawLocal = { + // format: { + // numeric: { + // delimiters: { + // thousands: ',', + // decimal: '.' + // } + // } + // }, + draw: { + toolbar: { + // #TODO: this should be reorganized where actions are nested in actions + // ex: actions.undo or actions.cancel + actions: { + title: 'Cancel drawing', + text: 'Cancel' + }, + finish: { + title: 'Finish drawing', + text: 'Finish' + }, + undo: { + title: 'Delete last point drawn', + text: 'Delete last point' + }, + buttons: { + polyline: 'Draw a polyline', + polygon: 'Draw a polygon', + rectangle: 'Draw a rectangle', + circle: 'Draw a circle', + marker: 'Draw a marker', + circlemarker: 'Draw a circlemarker' + } + }, + handlers: { + circle: { + tooltip: { + start: 'Click and drag to draw circle.' + }, + radius: 'Radius' + }, + circlemarker: { + tooltip: { + start: 'Click map to place circle marker.' + } + }, + marker: { + tooltip: { + start: 'Click map to place marker.' + } + }, + polygon: { + tooltip: { + start: 'Click to start drawing shape.', + cont: 'Click to continue drawing shape.', + end: 'Click first point to close this shape.' + } + }, + polyline: { + error: 'Error: shape edges cannot cross!', + tooltip: { + start: 'Click to start drawing line.', + cont: 'Click to continue drawing line.', + end: 'Click last point to finish line.' + } + }, + rectangle: { + tooltip: { + start: 'Click and drag to draw rectangle.' + } + }, + simpleshape: { + tooltip: { + end: 'Release mouse to finish drawing.' + } + } + } + }, + edit: { + toolbar: { + actions: { + save: { + title: 'Save changes', + text: 'Save' + }, + cancel: { + title: 'Cancel editing, discards all changes', + text: 'Cancel' + }, + clearAll: { + title: 'Clear all layers', + text: 'Clear All' + } + }, + buttons: { + edit: 'Edit layers', + editDisabled: 'No layers to edit', + remove: 'Delete layers', + removeDisabled: 'No layers to delete' + } + }, + handlers: { + edit: { + tooltip: { + text: 'Drag handles or markers to edit features.', + subtext: 'Click cancel to undo changes.' + } + }, + remove: { + tooltip: { + text: 'Click on a feature to remove.' + } + } + } + } +}; + + + +/** + * ### Events + * Once you have successfully added the Leaflet.draw plugin to your map you will want to respond to the different + * actions users can initiate. The following events will be triggered on the map: + * + * @class L.Draw.Event + * @aka Draw.Event + * + * Use `L.Draw.Event.EVENTNAME` constants to ensure events are correct. + * + * @example + * ```js + * map.on(L.Draw.Event.CREATED; function (e) { + * var type = e.layerType, + * layer = e.layer; + * + * if (type === 'marker') { + * // Do marker specific actions + * } + * + * // Do whatever else you need to. (save to db; add to map etc) + * map.addLayer(layer); + *}); + * ``` + */ +L.Draw.Event = {}; +/** + * @event draw:created: PolyLine; Polygon; Rectangle; Circle; Marker | String + * + * Layer that was just created. + * The type of layer this is. One of: `polyline`; `polygon`; `rectangle`; `circle`; `marker` + * Triggered when a new vector or marker has been created. + * + */ +L.Draw.Event.CREATED = 'draw:created'; + +/** + * @event draw:edited: LayerGroup + * + * List of all layers just edited on the map. + * + * + * Triggered when layers in the FeatureGroup; initialised with the plugin; have been edited and saved. + * + * @example + * ```js + * map.on('draw:edited', function (e) { + * var layers = e.layers; + * layers.eachLayer(function (layer) { + * //do whatever you want; most likely save back to db + * }); + * }); + * ``` + */ +L.Draw.Event.EDITED = 'draw:edited'; + +/** + * @event draw:deleted: LayerGroup + * + * List of all layers just removed from the map. + * + * Triggered when layers have been removed (and saved) from the FeatureGroup. + */ +L.Draw.Event.DELETED = 'draw:deleted'; + +/** + * @event draw:drawstart: String + * + * The type of layer this is. One of:`polyline`; `polygon`; `rectangle`; `circle`; `marker` + * + * Triggered when the user has chosen to draw a particular vector or marker. + */ +L.Draw.Event.DRAWSTART = 'draw:drawstart'; + +/** + * @event draw:drawstop: String + * + * The type of layer this is. One of: `polyline`; `polygon`; `rectangle`; `circle`; `marker` + * + * Triggered when the user has finished a particular vector or marker. + */ + +L.Draw.Event.DRAWSTOP = 'draw:drawstop'; + +/** + * @event draw:drawvertex: LayerGroup + * + * List of all layers just being added from the map. + * + * Triggered when a vertex is created on a polyline or polygon. + */ +L.Draw.Event.DRAWVERTEX = 'draw:drawvertex'; + +/** + * @event draw:editstart: String + * + * The type of edit this is. One of: `edit` + * + * Triggered when the user starts edit mode by clicking the edit tool button. + */ + +L.Draw.Event.EDITSTART = 'draw:editstart'; + +/** + * @event draw:editmove: ILayer + * + * Layer that was just moved. + * + * Triggered as the user moves a rectangle; circle or marker. + */ +L.Draw.Event.EDITMOVE = 'draw:editmove'; + +/** + * @event draw:editresize: ILayer + * + * Layer that was just moved. + * + * Triggered as the user resizes a rectangle or circle. + */ +L.Draw.Event.EDITRESIZE = 'draw:editresize'; + +/** + * @event draw:editvertex: LayerGroup + * + * List of all layers just being edited from the map. + * + * Triggered when a vertex is edited on a polyline or polygon. + */ +L.Draw.Event.EDITVERTEX = 'draw:editvertex'; + +/** + * @event draw:editstop: String + * + * The type of edit this is. One of: `edit` + * + * Triggered when the user has finshed editing (edit mode) and saves edits. + */ +L.Draw.Event.EDITSTOP = 'draw:editstop'; + +/** + * @event draw:deletestart: String + * + * The type of edit this is. One of: `remove` + * + * Triggered when the user starts remove mode by clicking the remove tool button. + */ +L.Draw.Event.DELETESTART = 'draw:deletestart'; + +/** + * @event draw:deletestop: String + * + * The type of edit this is. One of: `remove` + * + * Triggered when the user has finished removing shapes (remove mode) and saves. + */ +L.Draw.Event.DELETESTOP = 'draw:deletestop'; + +/** + * @event draw:toolbaropened: String + * + * Triggered when a toolbar is opened. + */ +L.Draw.Event.TOOLBAROPENED = 'draw:toolbaropened'; + +/** + * @event draw:toolbarclosed: String + * + * Triggered when a toolbar is closed. + */ +L.Draw.Event.TOOLBARCLOSED = 'draw:toolbarclosed'; + +/** + * @event draw:markercontext: String + * + * Triggered when a marker is right clicked. + */ +L.Draw.Event.MARKERCONTEXT = 'draw:markercontext'; + + +L.Draw = L.Draw || {}; + +/** + * @class L.Draw.Feature + * @aka Draw.Feature + */ +L.Draw.Feature = L.Handler.extend({ + + // @method initialize(): void + initialize: function (map, options) { + this._map = map; + this._container = map._container; + this._overlayPane = map._panes.overlayPane; + this._popupPane = map._panes.popupPane; + + // Merge default shapeOptions options with custom shapeOptions + if (options && options.shapeOptions) { + options.shapeOptions = L.Util.extend({}, this.options.shapeOptions, options.shapeOptions); + } + L.setOptions(this, options); + + var version = L.version.split('.'); + //If Version is >= 1.2.0 + if (parseInt(version[0], 10) === 1 && parseInt(version[1], 10) >= 2) { + L.Draw.Feature.include(L.Evented.prototype); + } else { + L.Draw.Feature.include(L.Mixin.Events); + } + }, + + // @method enable(): void + // Enables this handler + enable: function () { + if (this._enabled) { + return; + } + + L.Handler.prototype.enable.call(this); + + this.fire('enabled', {handler: this.type}); + + this._map.fire(L.Draw.Event.DRAWSTART, {layerType: this.type}); + }, + + // @method disable(): void + disable: function () { + if (!this._enabled) { + return; + } + + L.Handler.prototype.disable.call(this); + + this._map.fire(L.Draw.Event.DRAWSTOP, {layerType: this.type}); + + this.fire('disabled', {handler: this.type}); + }, + + // @method addHooks(): void + // Add's event listeners to this handler + addHooks: function () { + var map = this._map; + + if (map) { + L.DomUtil.disableTextSelection(); + + map.getContainer().focus(); + + this._tooltip = new L.Draw.Tooltip(this._map); + + L.DomEvent.on(this._container, 'keyup', this._cancelDrawing, this); + } + }, + + // @method removeHooks(): void + // Removes event listeners from this handler + removeHooks: function () { + if (this._map) { + L.DomUtil.enableTextSelection(); + + this._tooltip.dispose(); + this._tooltip = null; + + L.DomEvent.off(this._container, 'keyup', this._cancelDrawing, this); + } + }, + + // @method setOptions(object): void + // Sets new options to this handler + setOptions: function (options) { + L.setOptions(this, options); + }, + + _fireCreatedEvent: function (layer) { + this._map.fire(L.Draw.Event.CREATED, {layer: layer, layerType: this.type}); + }, + + // Cancel drawing when the escape key is pressed + _cancelDrawing: function (e) { + if (e.keyCode === 27) { + this._map.fire('draw:canceled', {layerType: this.type}); + this.disable(); + } + } +}); + + + +/** + * @class L.Draw.Polyline + * @aka Draw.Polyline + * @inherits L.Draw.Feature + */ +L.Draw.Polyline = L.Draw.Feature.extend({ + statics: { + TYPE: 'polyline' + }, + + Poly: L.Polyline, + + options: { + allowIntersection: true, + repeatMode: false, + drawError: { + color: '#b00b00', + timeout: 2500 + }, + icon: new L.DivIcon({ + iconSize: new L.Point(8, 8), + className: 'leaflet-div-icon leaflet-editing-icon' + }), + touchIcon: new L.DivIcon({ + iconSize: new L.Point(20, 20), + className: 'leaflet-div-icon leaflet-editing-icon leaflet-touch-icon' + }), + guidelineDistance: 20, + maxGuideLineLength: 4000, + shapeOptions: { + stroke: true, + color: '#3388ff', + weight: 4, + opacity: 0.5, + fill: false, + clickable: true + }, + metric: true, // Whether to use the metric measurement system or imperial + feet: true, // When not metric, to use feet instead of yards for display. + nautic: false, // When not metric, not feet use nautic mile for display + showLength: true, // Whether to display distance in the tooltip + zIndexOffset: 2000, // This should be > than the highest z-index any map layers + factor: 1, // To change distance calculation + maxPoints: 0 // Once this number of points are placed, finish shape + }, + + // @method initialize(): void + initialize: function (map, options) { + // if touch, switch to touch icon + if (L.Browser.touch) { + this.options.icon = this.options.touchIcon; + } + + // Need to set this here to ensure the correct message is used. + this.options.drawError.message = L.drawLocal.draw.handlers.polyline.error; + + // Merge default drawError options with custom options + if (options && options.drawError) { + options.drawError = L.Util.extend({}, this.options.drawError, options.drawError); + } + + // Save the type so super can fire, need to do this as cannot do this.TYPE :( + this.type = L.Draw.Polyline.TYPE; + + L.Draw.Feature.prototype.initialize.call(this, map, options); + }, + + // @method addHooks(): void + // Add listener hooks to this handler + addHooks: function () { + L.Draw.Feature.prototype.addHooks.call(this); + if (this._map) { + this._markers = []; + + this._markerGroup = new L.LayerGroup(); + this._map.addLayer(this._markerGroup); + + this._poly = new L.Polyline([], this.options.shapeOptions); + + this._tooltip.updateContent(this._getTooltipText()); + + // Make a transparent marker that will used to catch click events. These click + // events will create the vertices. We need to do this so we can ensure that + // we can create vertices over other map layers (markers, vector layers). We + // also do not want to trigger any click handlers of objects we are clicking on + // while drawing. + if (!this._mouseMarker) { + this._mouseMarker = L.marker(this._map.getCenter(), { + icon: L.divIcon({ + className: 'leaflet-mouse-marker', + iconAnchor: [20, 20], + iconSize: [40, 40] + }), + opacity: 0, + zIndexOffset: this.options.zIndexOffset + }); + } + + this._mouseMarker + .on('mouseout', this._onMouseOut, this) + .on('mousemove', this._onMouseMove, this) // Necessary to prevent 0.8 stutter + .on('mousedown', this._onMouseDown, this) + .on('mouseup', this._onMouseUp, this) // Necessary for 0.8 compatibility + .addTo(this._map); + + this._map + .on('mouseup', this._onMouseUp, this) // Necessary for 0.7 compatibility + .on('mousemove', this._onMouseMove, this) + .on('zoomlevelschange', this._onZoomEnd, this) + .on('touchstart', this._onTouch, this) + .on('zoomend', this._onZoomEnd, this); + + } + }, + + // @method removeHooks(): void + // Remove listener hooks from this handler. + removeHooks: function () { + L.Draw.Feature.prototype.removeHooks.call(this); + + this._clearHideErrorTimeout(); + + this._cleanUpShape(); + + // remove markers from map + this._map.removeLayer(this._markerGroup); + delete this._markerGroup; + delete this._markers; + + this._map.removeLayer(this._poly); + delete this._poly; + + this._mouseMarker + .off('mousedown', this._onMouseDown, this) + .off('mouseout', this._onMouseOut, this) + .off('mouseup', this._onMouseUp, this) + .off('mousemove', this._onMouseMove, this); + this._map.removeLayer(this._mouseMarker); + delete this._mouseMarker; + + // clean up DOM + this._clearGuides(); + + this._map + .off('mouseup', this._onMouseUp, this) + .off('mousemove', this._onMouseMove, this) + .off('zoomlevelschange', this._onZoomEnd, this) + .off('zoomend', this._onZoomEnd, this) + .off('touchstart', this._onTouch, this) + .off('click', this._onTouch, this); + }, + + // @method deleteLastVertex(): void + // Remove the last vertex from the polyline, removes polyline from map if only one point exists. + deleteLastVertex: function () { + if (this._markers.length <= 1) { + return; + } + + var lastMarker = this._markers.pop(), + poly = this._poly, + // Replaces .spliceLatLngs() + latlngs = poly.getLatLngs(), + latlng = latlngs.splice(-1, 1)[0]; + this._poly.setLatLngs(latlngs); + + this._markerGroup.removeLayer(lastMarker); + + if (poly.getLatLngs().length < 2) { + this._map.removeLayer(poly); + } + + this._vertexChanged(latlng, false); + }, + + // @method addVertex(): void + // Add a vertex to the end of the polyline + addVertex: function (latlng) { + var markersLength = this._markers.length; + // markersLength must be greater than or equal to 2 before intersections can occur + if (markersLength >= 2 && !this.options.allowIntersection && this._poly.newLatLngIntersects(latlng)) { + this._showErrorTooltip(); + return; + } + else if (this._errorShown) { + this._hideErrorTooltip(); + } + + this._markers.push(this._createMarker(latlng)); + + this._poly.addLatLng(latlng); + + if (this._poly.getLatLngs().length === 2) { + this._map.addLayer(this._poly); + } + + this._vertexChanged(latlng, true); + }, + + // @method completeShape(): void + // Closes the polyline between the first and last points + completeShape: function () { + if (this._markers.length <= 1 || !this._shapeIsValid()) { + return; + } + + this._fireCreatedEvent(); + this.disable(); + + if (this.options.repeatMode) { + this.enable(); + } + }, + + _finishShape: function () { + var latlngs = this._poly._defaultShape ? this._poly._defaultShape() : this._poly.getLatLngs(); + var intersects = this._poly.newLatLngIntersects(latlngs[latlngs.length - 1]); + + if ((!this.options.allowIntersection && intersects) || !this._shapeIsValid()) { + this._showErrorTooltip(); + return; + } + + this._fireCreatedEvent(); + this.disable(); + if (this.options.repeatMode) { + this.enable(); + } + }, + + // Called to verify the shape is valid when the user tries to finish it + // Return false if the shape is not valid + _shapeIsValid: function () { + return true; + }, + + _onZoomEnd: function () { + if (this._markers !== null) { + this._updateGuide(); + } + }, + + _onMouseMove: function (e) { + var newPos = this._map.mouseEventToLayerPoint(e.originalEvent); + var latlng = this._map.layerPointToLatLng(newPos); + + // Save latlng + // should this be moved to _updateGuide() ? + this._currentLatLng = latlng; + + this._updateTooltip(latlng); + + // Update the guide line + this._updateGuide(newPos); + + // Update the mouse marker position + this._mouseMarker.setLatLng(latlng); + + L.DomEvent.preventDefault(e.originalEvent); + }, + + _vertexChanged: function (latlng, added) { + this._map.fire(L.Draw.Event.DRAWVERTEX, {layers: this._markerGroup}); + this._updateFinishHandler(); + + this._updateRunningMeasure(latlng, added); + + this._clearGuides(); + + this._updateTooltip(); + }, + + _onMouseDown: function (e) { + if (!this._clickHandled && !this._touchHandled && !this._disableMarkers) { + this._onMouseMove(e); + this._clickHandled = true; + this._disableNewMarkers(); + var originalEvent = e.originalEvent; + var clientX = originalEvent.clientX; + var clientY = originalEvent.clientY; + this._startPoint.call(this, clientX, clientY); + } + }, + + _startPoint: function (clientX, clientY) { + this._mouseDownOrigin = L.point(clientX, clientY); + }, + + _onMouseUp: function (e) { + var originalEvent = e.originalEvent; + var clientX = originalEvent.clientX; + var clientY = originalEvent.clientY; + this._endPoint.call(this, clientX, clientY, e); + this._clickHandled = null; + }, + + _endPoint: function (clientX, clientY, e) { + if (this._mouseDownOrigin) { + var dragCheckDistance = L.point(clientX, clientY) + .distanceTo(this._mouseDownOrigin); + var lastPtDistance = this._calculateFinishDistance(e.latlng); + if (this.options.maxPoints > 1 && this.options.maxPoints == this._markers.length + 1) { + this.addVertex(e.latlng); + this._finishShape(); + } else if (lastPtDistance < 10 && L.Browser.touch) { + this._finishShape(); + } else if (Math.abs(dragCheckDistance) < 9 * (window.devicePixelRatio || 1)) { + this.addVertex(e.latlng); + } + this._enableNewMarkers(); // after a short pause, enable new markers + } + this._mouseDownOrigin = null; + }, + + // ontouch prevented by clickHandled flag because some browsers fire both click/touch events, + // causing unwanted behavior + _onTouch: function (e) { + var originalEvent = e.originalEvent; + var clientX; + var clientY; + if (originalEvent.touches && originalEvent.touches[0] && !this._clickHandled && !this._touchHandled && !this._disableMarkers) { + clientX = originalEvent.touches[0].clientX; + clientY = originalEvent.touches[0].clientY; + this._disableNewMarkers(); + this._touchHandled = true; + this._startPoint.call(this, clientX, clientY); + this._endPoint.call(this, clientX, clientY, e); + this._touchHandled = null; + } + this._clickHandled = null; + }, + + _onMouseOut: function () { + if (this._tooltip) { + this._tooltip._onMouseOut.call(this._tooltip); + } + }, + + // calculate if we are currently within close enough distance + // of the closing point (first point for shapes, last point for lines) + // this is semi-ugly code but the only reliable way i found to get the job done + // note: calculating point.distanceTo between mouseDownOrigin and last marker did NOT work + _calculateFinishDistance: function (potentialLatLng) { + var lastPtDistance; + if (this._markers.length > 0) { + var finishMarker; + if (this.type === L.Draw.Polyline.TYPE) { + finishMarker = this._markers[this._markers.length - 1]; + } else if (this.type === L.Draw.Polygon.TYPE) { + finishMarker = this._markers[0]; + } else { + return Infinity; + } + var lastMarkerPoint = this._map.latLngToContainerPoint(finishMarker.getLatLng()), + potentialMarker = new L.Marker(potentialLatLng, { + icon: this.options.icon, + zIndexOffset: this.options.zIndexOffset * 2 + }); + var potentialMarkerPint = this._map.latLngToContainerPoint(potentialMarker.getLatLng()); + lastPtDistance = lastMarkerPoint.distanceTo(potentialMarkerPint); + } else { + lastPtDistance = Infinity; + } + return lastPtDistance; + }, + + _updateFinishHandler: function () { + var markerCount = this._markers.length; + // The last marker should have a click handler to close the polyline + if (markerCount > 1) { + this._markers[markerCount - 1].on('click', this._finishShape, this); + } + + // Remove the old marker click handler (as only the last point should close the polyline) + if (markerCount > 2) { + this._markers[markerCount - 2].off('click', this._finishShape, this); + } + }, + + _createMarker: function (latlng) { + var marker = new L.Marker(latlng, { + icon: this.options.icon, + zIndexOffset: this.options.zIndexOffset * 2 + }); + + this._markerGroup.addLayer(marker); + + return marker; + }, + + _updateGuide: function (newPos) { + var markerCount = this._markers ? this._markers.length : 0; + + if (markerCount > 0) { + newPos = newPos || this._map.latLngToLayerPoint(this._currentLatLng); + + // draw the guide line + this._clearGuides(); + this._drawGuide( + this._map.latLngToLayerPoint(this._markers[markerCount - 1].getLatLng()), + newPos + ); + } + }, + + _updateTooltip: function (latLng) { + var text = this._getTooltipText(); + + if (latLng) { + this._tooltip.updatePosition(latLng); + } + + if (!this._errorShown) { + this._tooltip.updateContent(text); + } + }, + + _drawGuide: function (pointA, pointB) { + var length = Math.floor(Math.sqrt(Math.pow((pointB.x - pointA.x), 2) + Math.pow((pointB.y - pointA.y), 2))), + guidelineDistance = this.options.guidelineDistance, + maxGuideLineLength = this.options.maxGuideLineLength, + // Only draw a guideline with a max length + i = length > maxGuideLineLength ? length - maxGuideLineLength : guidelineDistance, + fraction, + dashPoint, + dash; + + //create the guides container if we haven't yet + if (!this._guidesContainer) { + this._guidesContainer = L.DomUtil.create('div', 'leaflet-draw-guides', this._overlayPane); + } + + //draw a dash every GuildeLineDistance + for (; i < length; i += this.options.guidelineDistance) { + //work out fraction along line we are + fraction = i / length; + + //calculate new x,y point + dashPoint = { + x: Math.floor((pointA.x * (1 - fraction)) + (fraction * pointB.x)), + y: Math.floor((pointA.y * (1 - fraction)) + (fraction * pointB.y)) + }; + + //add guide dash to guide container + dash = L.DomUtil.create('div', 'leaflet-draw-guide-dash', this._guidesContainer); + dash.style.backgroundColor = + !this._errorShown ? this.options.shapeOptions.color : this.options.drawError.color; + + L.DomUtil.setPosition(dash, dashPoint); + } + }, + + _updateGuideColor: function (color) { + if (this._guidesContainer) { + for (var i = 0, l = this._guidesContainer.childNodes.length; i < l; i++) { + this._guidesContainer.childNodes[i].style.backgroundColor = color; + } + } + }, + + // removes all child elements (guide dashes) from the guides container + _clearGuides: function () { + if (this._guidesContainer) { + while (this._guidesContainer.firstChild) { + this._guidesContainer.removeChild(this._guidesContainer.firstChild); + } + } + }, + + _getTooltipText: function () { + var showLength = this.options.showLength, + labelText, distanceStr; + if (this._markers.length === 0) { + labelText = { + text: L.drawLocal.draw.handlers.polyline.tooltip.start + }; + } else { + distanceStr = showLength ? this._getMeasurementString() : ''; + + if (this._markers.length === 1) { + labelText = { + text: L.drawLocal.draw.handlers.polyline.tooltip.cont, + subtext: distanceStr + }; + } else { + labelText = { + text: L.drawLocal.draw.handlers.polyline.tooltip.end, + subtext: distanceStr + }; + } + } + return labelText; + }, + + _updateRunningMeasure: function (latlng, added) { + var markersLength = this._markers.length, + previousMarkerIndex, distance; + + if (this._markers.length === 1) { + this._measurementRunningTotal = 0; + } else { + previousMarkerIndex = markersLength - (added ? 2 : 1); + + // Calculate the distance based on the version + if (L.GeometryUtil.isVersion07x()) { + distance = latlng.distanceTo(this._markers[previousMarkerIndex].getLatLng()) * (this.options.factor || 1); + } else { + distance = this._map.distance(latlng, this._markers[previousMarkerIndex].getLatLng()) * (this.options.factor || 1); + } + + this._measurementRunningTotal += distance * (added ? 1 : -1); + } + }, + + _getMeasurementString: function () { + var currentLatLng = this._currentLatLng, + previousLatLng = this._markers[this._markers.length - 1].getLatLng(), + distance; + + // Calculate the distance from the last fixed point to the mouse position based on the version + if (L.GeometryUtil.isVersion07x()) { + distance = previousLatLng && currentLatLng && currentLatLng.distanceTo ? this._measurementRunningTotal + currentLatLng.distanceTo(previousLatLng) * (this.options.factor || 1) : this._measurementRunningTotal || 0; + } else { + distance = previousLatLng && currentLatLng ? this._measurementRunningTotal + this._map.distance(currentLatLng, previousLatLng) * (this.options.factor || 1) : this._measurementRunningTotal || 0; + } + + return L.GeometryUtil.readableDistance(distance, this.options.metric, this.options.feet, this.options.nautic, this.options.precision); + }, + + _showErrorTooltip: function () { + this._errorShown = true; + + // Update tooltip + this._tooltip + .showAsError() + .updateContent({text: this.options.drawError.message}); + + // Update shape + this._updateGuideColor(this.options.drawError.color); + this._poly.setStyle({color: this.options.drawError.color}); + + // Hide the error after 2 seconds + this._clearHideErrorTimeout(); + this._hideErrorTimeout = setTimeout(L.Util.bind(this._hideErrorTooltip, this), this.options.drawError.timeout); + }, + + _hideErrorTooltip: function () { + this._errorShown = false; + + this._clearHideErrorTimeout(); + + // Revert tooltip + this._tooltip + .removeError() + .updateContent(this._getTooltipText()); + + // Revert shape + this._updateGuideColor(this.options.shapeOptions.color); + this._poly.setStyle({color: this.options.shapeOptions.color}); + }, + + _clearHideErrorTimeout: function () { + if (this._hideErrorTimeout) { + clearTimeout(this._hideErrorTimeout); + this._hideErrorTimeout = null; + } + }, + + // disable new markers temporarily; + // this is to prevent duplicated touch/click events in some browsers + _disableNewMarkers: function () { + this._disableMarkers = true; + }, + + // see _disableNewMarkers + _enableNewMarkers: function () { + setTimeout(function () { + this._disableMarkers = false; + }.bind(this), 50); + }, + + _cleanUpShape: function () { + if (this._markers.length > 1) { + this._markers[this._markers.length - 1].off('click', this._finishShape, this); + } + }, + + _fireCreatedEvent: function () { + var poly = new this.Poly(this._poly.getLatLngs(), this.options.shapeOptions); + L.Draw.Feature.prototype._fireCreatedEvent.call(this, poly); + } +}); + + + +/** + * @class L.Draw.Polygon + * @aka Draw.Polygon + * @inherits L.Draw.Polyline + */ +L.Draw.Polygon = L.Draw.Polyline.extend({ + statics: { + TYPE: 'polygon' + }, + + Poly: L.Polygon, + + options: { + showArea: false, + showLength: false, + shapeOptions: { + stroke: true, + color: '#3388ff', + weight: 4, + opacity: 0.5, + fill: true, + fillColor: null, //same as color by default + fillOpacity: 0.2, + clickable: true + }, + // Whether to use the metric measurement system (truthy) or not (falsy). + // Also defines the units to use for the metric system as an array of + // strings (e.g. `['ha', 'm']`). + metric: true, + feet: true, // When not metric, to use feet instead of yards for display. + nautic: false, // When not metric, not feet use nautic mile for display + // Defines the precision for each type of unit (e.g. {km: 2, ft: 0} + precision: {} + }, + + // @method initialize(): void + initialize: function (map, options) { + L.Draw.Polyline.prototype.initialize.call(this, map, options); + + // Save the type so super can fire, need to do this as cannot do this.TYPE :( + this.type = L.Draw.Polygon.TYPE; + }, + + _updateFinishHandler: function () { + var markerCount = this._markers.length; + + // The first marker should have a click handler to close the polygon + if (markerCount === 1) { + this._markers[0].on('click', this._finishShape, this); + } + + // Add and update the double click handler + if (markerCount > 2) { + this._markers[markerCount - 1].on('dblclick', this._finishShape, this); + // Only need to remove handler if has been added before + if (markerCount > 3) { + this._markers[markerCount - 2].off('dblclick', this._finishShape, this); + } + } + }, + + _getTooltipText: function () { + var text, subtext; + + if (this._markers.length === 0) { + text = L.drawLocal.draw.handlers.polygon.tooltip.start; + } else if (this._markers.length < 3) { + text = L.drawLocal.draw.handlers.polygon.tooltip.cont; + subtext = this._getMeasurementString(); + } else { + text = L.drawLocal.draw.handlers.polygon.tooltip.end; + subtext = this._getMeasurementString(); + } + + return { + text: text, + subtext: subtext + }; + }, + + _getMeasurementString: function () { + var area = this._area, + measurementString = ''; + + + if (!area && !this.options.showLength) { + return null; + } + + if (this.options.showLength) { + measurementString = L.Draw.Polyline.prototype._getMeasurementString.call(this); + } + + if (area) { + measurementString += '
' + L.GeometryUtil.readableArea(area, this.options.metric, this.options.precision); + } + + return measurementString; + }, + + _shapeIsValid: function () { + return this._markers.length >= 3; + }, + + _vertexChanged: function (latlng, added) { + var latLngs; + + // Check to see if we should show the area + if (!this.options.allowIntersection && this.options.showArea) { + latLngs = this._poly.getLatLngs(); + + this._area = L.GeometryUtil.geodesicArea(latLngs); + } + + L.Draw.Polyline.prototype._vertexChanged.call(this, latlng, added); + }, + + _cleanUpShape: function () { + var markerCount = this._markers.length; + + if (markerCount > 0) { + this._markers[0].off('click', this._finishShape, this); + + if (markerCount > 2) { + this._markers[markerCount - 1].off('dblclick', this._finishShape, this); + } + } + } +}); + + + +L.SimpleShape = {}; +/** + * @class L.Draw.SimpleShape + * @aka Draw.SimpleShape + * @inherits L.Draw.Feature + */ +L.Draw.SimpleShape = L.Draw.Feature.extend({ + options: { + repeatMode: false + }, + + // @method initialize(): void + initialize: function (map, options) { + this._endLabelText = L.drawLocal.draw.handlers.simpleshape.tooltip.end; + + L.Draw.Feature.prototype.initialize.call(this, map, options); + }, + + // @method addHooks(): void + // Add listener hooks to this handler. + addHooks: function () { + L.Draw.Feature.prototype.addHooks.call(this); + if (this._map) { + this._mapDraggable = this._map.dragging.enabled(); + + if (this._mapDraggable) { + this._map.dragging.disable(); + } + + //TODO refactor: move cursor to styles + this._container.style.cursor = 'crosshair'; + + this._tooltip.updateContent({text: this._initialLabelText}); + + this._map + .on('mousedown', this._onMouseDown, this) + .on('mousemove', this._onMouseMove, this) + .on('touchstart', this._onMouseDown, this) + .on('touchmove', this._onMouseMove, this); + + // we should prevent default, otherwise default behavior (scrolling) will fire, + // and that will cause document.touchend to fire and will stop the drawing + // (circle, rectangle) in touch mode. + // (update): we have to send passive now to prevent scroll, because by default it is {passive: true} now, which means, + // handler can't event.preventDefault + // check the news https://developers.google.com/web/updates/2016/06/passive-event-listeners + document.addEventListener('touchstart', L.DomEvent.preventDefault, {passive: false}); + } + }, + + // @method removeHooks(): void + // Remove listener hooks from this handler. + removeHooks: function () { + L.Draw.Feature.prototype.removeHooks.call(this); + if (this._map) { + if (this._mapDraggable) { + this._map.dragging.enable(); + } + + //TODO refactor: move cursor to styles + this._container.style.cursor = ''; + + this._map + .off('mousedown', this._onMouseDown, this) + .off('mousemove', this._onMouseMove, this) + .off('touchstart', this._onMouseDown, this) + .off('touchmove', this._onMouseMove, this); + + L.DomEvent.off(document, 'mouseup', this._onMouseUp, this); + L.DomEvent.off(document, 'touchend', this._onMouseUp, this); + + document.removeEventListener('touchstart', L.DomEvent.preventDefault); + + // If the box element doesn't exist they must not have moved the mouse, so don't need to destroy/return + if (this._shape) { + this._map.removeLayer(this._shape); + delete this._shape; + } + } + this._isDrawing = false; + }, + + _getTooltipText: function () { + return { + text: this._endLabelText + }; + }, + + _onMouseDown: function (e) { + this._isDrawing = true; + this._startLatLng = e.latlng; + + L.DomEvent + .on(document, 'mouseup', this._onMouseUp, this) + .on(document, 'touchend', this._onMouseUp, this) + .preventDefault(e.originalEvent); + }, + + _onMouseMove: function (e) { + var latlng = e.latlng; + + this._tooltip.updatePosition(latlng); + if (this._isDrawing) { + this._tooltip.updateContent(this._getTooltipText()); + this._drawShape(latlng); + } + }, + + _onMouseUp: function () { + if (this._shape) { + this._fireCreatedEvent(); + } + + this.disable(); + if (this.options.repeatMode) { + this.enable(); + } + } +}); + + + +/** + * @class L.Draw.Rectangle + * @aka Draw.Rectangle + * @inherits L.Draw.SimpleShape + */ +L.Draw.Rectangle = L.Draw.SimpleShape.extend({ + statics: { + TYPE: 'rectangle' + }, + + options: { + shapeOptions: { + stroke: true, + color: '#3388ff', + weight: 4, + opacity: 0.5, + fill: true, + fillColor: null, //same as color by default + fillOpacity: 0.2, + clickable: true + }, + showArea: true, //Whether to show the area in the tooltip + metric: true // Whether to use the metric measurement system or imperial + }, + + // @method initialize(): void + initialize: function (map, options) { + // Save the type so super can fire, need to do this as cannot do this.TYPE :( + this.type = L.Draw.Rectangle.TYPE; + + this._initialLabelText = L.drawLocal.draw.handlers.rectangle.tooltip.start; + + L.Draw.SimpleShape.prototype.initialize.call(this, map, options); + }, + + // @method disable(): void + disable: function () { + if (!this._enabled) { + return; + } + + this._isCurrentlyTwoClickDrawing = false; + L.Draw.SimpleShape.prototype.disable.call(this); + }, + + _onMouseUp: function (e) { + if (!this._shape && !this._isCurrentlyTwoClickDrawing) { + this._isCurrentlyTwoClickDrawing = true; + return; + } + + // Make sure closing click is on map + if (this._isCurrentlyTwoClickDrawing && !_hasAncestor(e.target, 'leaflet-pane')) { + return; + } + + L.Draw.SimpleShape.prototype._onMouseUp.call(this); + }, + + _drawShape: function (latlng) { + if (!this._shape) { + this._shape = new L.Rectangle(new L.LatLngBounds(this._startLatLng, latlng), this.options.shapeOptions); + this._map.addLayer(this._shape); + } else { + this._shape.setBounds(new L.LatLngBounds(this._startLatLng, latlng)); + } + }, + + _fireCreatedEvent: function () { + var rectangle = new L.Rectangle(this._shape.getBounds(), this.options.shapeOptions); + L.Draw.SimpleShape.prototype._fireCreatedEvent.call(this, rectangle); + }, + + _getTooltipText: function () { + var tooltipText = L.Draw.SimpleShape.prototype._getTooltipText.call(this), + shape = this._shape, + showArea = this.options.showArea, + latLngs, area, subtext; + + if (shape) { + latLngs = this._shape._defaultShape ? this._shape._defaultShape() : this._shape.getLatLngs(); + area = L.GeometryUtil.geodesicArea(latLngs); + subtext = showArea ? L.GeometryUtil.readableArea(area, this.options.metric) : ''; + } + + return { + text: tooltipText.text, + subtext: subtext + }; + } +}); + +function _hasAncestor(el, cls) { + while ((el = el.parentElement) && !el.classList.contains(cls)) { + ; + } + return el; +} + + + +/** + * @class L.Draw.Marker + * @aka Draw.Marker + * @inherits L.Draw.Feature + */ +L.Draw.Marker = L.Draw.Feature.extend({ + statics: { + TYPE: 'marker' + }, + + options: { + icon: new L.Icon.Default(), + repeatMode: false, + zIndexOffset: 2000 // This should be > than the highest z-index any markers + }, + + // @method initialize(): void + initialize: function (map, options) { + // Save the type so super can fire, need to do this as cannot do this.TYPE :( + this.type = L.Draw.Marker.TYPE; + + this._initialLabelText = L.drawLocal.draw.handlers.marker.tooltip.start; + + L.Draw.Feature.prototype.initialize.call(this, map, options); + }, + + // @method addHooks(): void + // Add listener hooks to this handler. + addHooks: function () { + L.Draw.Feature.prototype.addHooks.call(this); + + if (this._map) { + this._tooltip.updateContent({text: this._initialLabelText}); + + // Same mouseMarker as in Draw.Polyline + if (!this._mouseMarker) { + this._mouseMarker = L.marker(this._map.getCenter(), { + icon: L.divIcon({ + className: 'leaflet-mouse-marker', + iconAnchor: [20, 20], + iconSize: [40, 40] + }), + opacity: 0, + zIndexOffset: this.options.zIndexOffset + }); + } + + this._mouseMarker + .on('click', this._onClick, this) + .addTo(this._map); + + this._map.on('mousemove', this._onMouseMove, this); + this._map.on('click', this._onTouch, this); + } + }, + + // @method removeHooks(): void + // Remove listener hooks from this handler. + removeHooks: function () { + L.Draw.Feature.prototype.removeHooks.call(this); + + if (this._map) { + this._map + .off('click', this._onClick, this) + .off('click', this._onTouch, this); + if (this._marker) { + this._marker.off('click', this._onClick, this); + this._map + .removeLayer(this._marker); + delete this._marker; + } + + this._mouseMarker.off('click', this._onClick, this); + this._map.removeLayer(this._mouseMarker); + delete this._mouseMarker; + + this._map.off('mousemove', this._onMouseMove, this); + } + }, + + _onMouseMove: function (e) { + var latlng = e.latlng; + + this._tooltip.updatePosition(latlng); + this._mouseMarker.setLatLng(latlng); + + if (!this._marker) { + this._marker = this._createMarker(latlng); + // Bind to both marker and map to make sure we get the click event. + this._marker.on('click', this._onClick, this); + this._map + .on('click', this._onClick, this) + .addLayer(this._marker); + } + else { + latlng = this._mouseMarker.getLatLng(); + this._marker.setLatLng(latlng); + } + }, + + _createMarker: function (latlng) { + return new L.Marker(latlng, { + icon: this.options.icon, + zIndexOffset: this.options.zIndexOffset + }); + }, + + _onClick: function () { + this._fireCreatedEvent(); + + this.disable(); + if (this.options.repeatMode) { + this.enable(); + } + }, + + _onTouch: function (e) { + // called on click & tap, only really does any thing on tap + this._onMouseMove(e); // creates & places marker + this._onClick(); // permanently places marker & ends interaction + }, + + _fireCreatedEvent: function () { + var marker = new L.Marker.Touch(this._marker.getLatLng(), {icon: this.options.icon}); + L.Draw.Feature.prototype._fireCreatedEvent.call(this, marker); + } +}); + + + +/** + * @class L.Draw.CircleMarker + * @aka Draw.CircleMarker + * @inherits L.Draw.Marker + */ +L.Draw.CircleMarker = L.Draw.Marker.extend({ + statics: { + TYPE: 'circlemarker' + }, + + options: { + stroke: true, + color: '#3388ff', + weight: 4, + opacity: 0.5, + fill: true, + fillColor: null, //same as color by default + fillOpacity: 0.2, + clickable: true, + zIndexOffset: 2000 // This should be > than the highest z-index any markers + }, + + // @method initialize(): void + initialize: function (map, options) { + // Save the type so super can fire, need to do this as cannot do this.TYPE :( + this.type = L.Draw.CircleMarker.TYPE; + + this._initialLabelText = L.drawLocal.draw.handlers.circlemarker.tooltip.start; + + L.Draw.Feature.prototype.initialize.call(this, map, options); + }, + + + _fireCreatedEvent: function () { + var circleMarker = new L.CircleMarker(this._marker.getLatLng(), this.options); + L.Draw.Feature.prototype._fireCreatedEvent.call(this, circleMarker); + }, + + _createMarker: function (latlng) { + return new L.CircleMarker(latlng, this.options); + } +}); + + + +/** + * @class L.Draw.Circle + * @aka Draw.Circle + * @inherits L.Draw.SimpleShape + */ +L.Draw.Circle = L.Draw.SimpleShape.extend({ + statics: { + TYPE: 'circle' + }, + + options: { + shapeOptions: { + stroke: true, + color: '#3388ff', + weight: 4, + opacity: 0.5, + fill: true, + fillColor: null, //same as color by default + fillOpacity: 0.2, + clickable: true + }, + showRadius: true, + metric: true, // Whether to use the metric measurement system or imperial + feet: true, // When not metric, use feet instead of yards for display + nautic: false // When not metric, not feet use nautic mile for display + }, + + // @method initialize(): void + initialize: function (map, options) { + // Save the type so super can fire, need to do this as cannot do this.TYPE :( + this.type = L.Draw.Circle.TYPE; + + this._initialLabelText = L.drawLocal.draw.handlers.circle.tooltip.start; + + L.Draw.SimpleShape.prototype.initialize.call(this, map, options); + }, + + _drawShape: function (latlng) { + // Calculate the distance based on the version + if (L.GeometryUtil.isVersion07x()) { + var distance = this._startLatLng.distanceTo(latlng); + } else { + var distance = this._map.distance(this._startLatLng, latlng); + } + + if (!this._shape) { + this._shape = new L.Circle(this._startLatLng, distance, this.options.shapeOptions); + this._map.addLayer(this._shape); + } else { + this._shape.setRadius(distance); + } + }, + + _fireCreatedEvent: function () { + var circle = new L.Circle(this._startLatLng, this._shape.getRadius(), this.options.shapeOptions); + L.Draw.SimpleShape.prototype._fireCreatedEvent.call(this, circle); + }, + + _onMouseMove: function (e) { + var latlng = e.latlng, + showRadius = this.options.showRadius, + useMetric = this.options.metric, + radius; + + this._tooltip.updatePosition(latlng); + if (this._isDrawing) { + this._drawShape(latlng); + + // Get the new radius (rounded to 1 dp) + radius = this._shape.getRadius().toFixed(1); + + var subtext = ''; + if (showRadius) { + subtext = L.drawLocal.draw.handlers.circle.radius + ': ' + + L.GeometryUtil.readableDistance(radius, useMetric, this.options.feet, this.options.nautic); + } + this._tooltip.updateContent({ + text: this._endLabelText, + subtext: subtext + }); + } + } +}); + + + +L.Edit = L.Edit || {}; + +/** + * @class L.Edit.Marker + * @aka Edit.Marker + */ +L.Edit.Marker = L.Handler.extend({ + // @method initialize(): void + initialize: function (marker, options) { + this._marker = marker; + L.setOptions(this, options); + }, + + // @method addHooks(): void + // Add listener hooks to this handler + addHooks: function () { + var marker = this._marker; + + marker.dragging.enable(); + marker.on('dragend', this._onDragEnd, marker); + this._toggleMarkerHighlight(); + }, + + // @method removeHooks(): void + // Remove listener hooks from this handler + removeHooks: function () { + var marker = this._marker; + + marker.dragging.disable(); + marker.off('dragend', this._onDragEnd, marker); + this._toggleMarkerHighlight(); + }, + + _onDragEnd: function (e) { + var layer = e.target; + layer.edited = true; + this._map.fire(L.Draw.Event.EDITMOVE, {layer: layer}); + }, + + _toggleMarkerHighlight: function () { + var icon = this._marker._icon; + + // Don't do anything if this layer is a marker but doesn't have an icon. Markers + // should usually have icons. If using Leaflet.draw with Leaflet.markercluster there + // is a chance that a marker doesn't. + if (!icon) { + return; + } + + // This is quite naughty, but I don't see another way of doing it. (short of setting a new icon) + icon.style.display = 'none'; + + if (L.DomUtil.hasClass(icon, 'leaflet-edit-marker-selected')) { + L.DomUtil.removeClass(icon, 'leaflet-edit-marker-selected'); + // Offset as the border will make the icon move. + this._offsetMarker(icon, -4); + + } else { + L.DomUtil.addClass(icon, 'leaflet-edit-marker-selected'); + // Offset as the border will make the icon move. + this._offsetMarker(icon, 4); + } + + icon.style.display = ''; + }, + + _offsetMarker: function (icon, offset) { + var iconMarginTop = parseInt(icon.style.marginTop, 10) - offset, + iconMarginLeft = parseInt(icon.style.marginLeft, 10) - offset; + + icon.style.marginTop = iconMarginTop + 'px'; + icon.style.marginLeft = iconMarginLeft + 'px'; + } +}); + +L.Marker.addInitHook(function () { + if (L.Edit.Marker) { + this.editing = new L.Edit.Marker(this); + + if (this.options.editable) { + this.editing.enable(); + } + } +}); + + + +L.Edit = L.Edit || {}; + +/** + * @class L.Edit.Polyline + * @aka L.Edit.Poly + * @aka Edit.Poly + */ +L.Edit.Poly = L.Handler.extend({ + // @method initialize(): void + initialize: function (poly) { + + this.latlngs = [poly._latlngs]; + if (poly._holes) { + this.latlngs = this.latlngs.concat(poly._holes); + } + + this._poly = poly; + + this._poly.on('revert-edited', this._updateLatLngs, this); + }, + + // Compatibility method to normalize Poly* objects + // between 0.7.x and 1.0+ + _defaultShape: function () { + if (!L.Polyline._flat) { + return this._poly._latlngs; + } + return L.Polyline._flat(this._poly._latlngs) ? this._poly._latlngs : this._poly._latlngs[0]; + }, + + _eachVertexHandler: function (callback) { + for (var i = 0; i < this._verticesHandlers.length; i++) { + callback(this._verticesHandlers[i]); + } + }, + + // @method addHooks(): void + // Add listener hooks to this handler + addHooks: function () { + this._initHandlers(); + this._eachVertexHandler(function (handler) { + handler.addHooks(); + }); + }, + + // @method removeHooks(): void + // Remove listener hooks from this handler + removeHooks: function () { + this._eachVertexHandler(function (handler) { + handler.removeHooks(); + }); + }, + + // @method updateMarkers(): void + // Fire an update for each vertex handler + updateMarkers: function () { + this._eachVertexHandler(function (handler) { + handler.updateMarkers(); + }); + }, + + _initHandlers: function () { + this._verticesHandlers = []; + for (var i = 0; i < this.latlngs.length; i++) { + this._verticesHandlers.push(new L.Edit.PolyVerticesEdit(this._poly, this.latlngs[i], this._poly.options.poly)); + } + }, + + _updateLatLngs: function (e) { + this.latlngs = [e.layer._latlngs]; + if (e.layer._holes) { + this.latlngs = this.latlngs.concat(e.layer._holes); + } + } + +}); + +/** + * @class L.Edit.PolyVerticesEdit + * @aka Edit.PolyVerticesEdit + */ +L.Edit.PolyVerticesEdit = L.Handler.extend({ + options: { + icon: new L.DivIcon({ + iconSize: new L.Point(8, 8), + className: 'leaflet-div-icon leaflet-editing-icon' + }), + touchIcon: new L.DivIcon({ + iconSize: new L.Point(20, 20), + className: 'leaflet-div-icon leaflet-editing-icon leaflet-touch-icon' + }), + drawError: { + color: '#b00b00', + timeout: 1000 + } + + + }, + + // @method intialize(): void + initialize: function (poly, latlngs, options) { + // if touch, switch to touch icon + if (L.Browser.touch) { + this.options.icon = this.options.touchIcon; + } + this._poly = poly; + + if (options && options.drawError) { + options.drawError = L.Util.extend({}, this.options.drawError, options.drawError); + } + + this._latlngs = latlngs; + + L.setOptions(this, options); + }, + + // Compatibility method to normalize Poly* objects + // between 0.7.x and 1.0+ + _defaultShape: function () { + if (!L.Polyline._flat) { + return this._latlngs; + } + return L.Polyline._flat(this._latlngs) ? this._latlngs : this._latlngs[0]; + }, + + // @method addHooks(): void + // Add listener hooks to this handler. + addHooks: function () { + var poly = this._poly; + var path = poly._path; + + if (!(poly instanceof L.Polygon)) { + poly.options.fill = false; + if (poly.options.editing) { + poly.options.editing.fill = false; + } + } + + if (path) { + if (poly.options.editing && poly.options.editing.className) { + if (poly.options.original.className) { + poly.options.original.className.split(' ').forEach(function (className) { + L.DomUtil.removeClass(path, className); + }); + } + poly.options.editing.className.split(' ').forEach(function (className) { + L.DomUtil.addClass(path, className); + }); + } + } + + poly.setStyle(poly.options.editing); + + if (this._poly._map) { + + this._map = this._poly._map; // Set map + + if (!this._markerGroup) { + this._initMarkers(); + } + this._poly._map.addLayer(this._markerGroup); + } + }, + + // @method removeHooks(): void + // Remove listener hooks from this handler. + removeHooks: function () { + var poly = this._poly; + var path = poly._path; + + if (path) { + if (poly.options.editing && poly.options.editing.className) { + poly.options.editing.className.split(' ').forEach(function (className) { + L.DomUtil.removeClass(path, className); + }); + if (poly.options.original.className) { + poly.options.original.className.split(' ').forEach(function (className) { + L.DomUtil.addClass(path, className); + }); + } + } + } + + poly.setStyle(poly.options.original); + + if (poly._map) { + poly._map.removeLayer(this._markerGroup); + delete this._markerGroup; + delete this._markers; + } + }, + + // @method updateMarkers(): void + // Clear markers and update their location + updateMarkers: function () { + this._markerGroup.clearLayers(); + this._initMarkers(); + }, + + _initMarkers: function () { + if (!this._markerGroup) { + this._markerGroup = new L.LayerGroup(); + } + this._markers = []; + + var latlngs = this._defaultShape(), + i, j, len, marker; + + for (i = 0, len = latlngs.length; i < len; i++) { + + marker = this._createMarker(latlngs[i], i); + marker.on('click', this._onMarkerClick, this); + marker.on('contextmenu', this._onContextMenu, this); + this._markers.push(marker); + } + + var markerLeft, markerRight; + + for (i = 0, j = len - 1; i < len; j = i++) { + if (i === 0 && !(L.Polygon && (this._poly instanceof L.Polygon))) { + continue; + } + + markerLeft = this._markers[j]; + markerRight = this._markers[i]; + + this._createMiddleMarker(markerLeft, markerRight); + this._updatePrevNext(markerLeft, markerRight); + } + }, + + _createMarker: function (latlng, index) { + // Extending L.Marker in TouchEvents.js to include touch. + var marker = new L.Marker.Touch(latlng, { + draggable: true, + icon: this.options.icon, + }); + + marker._origLatLng = latlng; + marker._index = index; + + marker + .on('dragstart', this._onMarkerDragStart, this) + .on('drag', this._onMarkerDrag, this) + .on('dragend', this._fireEdit, this) + .on('touchmove', this._onTouchMove, this) + .on('touchend', this._fireEdit, this) + .on('MSPointerMove', this._onTouchMove, this) + .on('MSPointerUp', this._fireEdit, this); + + this._markerGroup.addLayer(marker); + + return marker; + }, + + _onMarkerDragStart: function () { + this._poly.fire('editstart'); + }, + + _spliceLatLngs: function () { + var latlngs = this._defaultShape(); + var removed = [].splice.apply(latlngs, arguments); + this._poly._convertLatLngs(latlngs, true); + this._poly.redraw(); + return removed; + }, + + _removeMarker: function (marker) { + var i = marker._index; + + this._markerGroup.removeLayer(marker); + this._markers.splice(i, 1); + this._spliceLatLngs(i, 1); + this._updateIndexes(i, -1); + + marker + .off('dragstart', this._onMarkerDragStart, this) + .off('drag', this._onMarkerDrag, this) + .off('dragend', this._fireEdit, this) + .off('touchmove', this._onMarkerDrag, this) + .off('touchend', this._fireEdit, this) + .off('click', this._onMarkerClick, this) + .off('MSPointerMove', this._onTouchMove, this) + .off('MSPointerUp', this._fireEdit, this); + }, + + _fireEdit: function () { + this._poly.edited = true; + this._poly.fire('edit'); + this._poly._map.fire(L.Draw.Event.EDITVERTEX, {layers: this._markerGroup, poly: this._poly}); + }, + + _onMarkerDrag: function (e) { + var marker = e.target; + var poly = this._poly; + + var oldOrigLatLng = L.LatLngUtil.cloneLatLng(marker._origLatLng); + L.extend(marker._origLatLng, marker._latlng); + if (poly.options.poly) { + var tooltip = poly._map._editTooltip; // Access the tooltip + + // If we don't allow intersections and the polygon intersects + if (!poly.options.poly.allowIntersection && poly.intersects()) { + L.extend(marker._origLatLng, oldOrigLatLng); + marker.setLatLng(oldOrigLatLng); + var originalColor = poly.options.color; + poly.setStyle({color: this.options.drawError.color}); + if (tooltip) { + tooltip.updateContent({ + text: L.drawLocal.draw.handlers.polyline.error + }); + } + + // Reset everything back to normal after a second + setTimeout(function () { + poly.setStyle({color: originalColor}); + if (tooltip) { + tooltip.updateContent({ + text: L.drawLocal.edit.handlers.edit.tooltip.text, + subtext: L.drawLocal.edit.handlers.edit.tooltip.subtext + }); + } + }, 1000); + } + } + + if (marker._middleLeft) { + marker._middleLeft.setLatLng(this._getMiddleLatLng(marker._prev, marker)); + } + if (marker._middleRight) { + marker._middleRight.setLatLng(this._getMiddleLatLng(marker, marker._next)); + } + + //refresh the bounds when draging + this._poly._bounds._southWest = L.latLng(Infinity, Infinity); + this._poly._bounds._northEast = L.latLng(-Infinity, -Infinity); + var latlngs = this._poly.getLatLngs(); + this._poly._convertLatLngs(latlngs, true); + this._poly.redraw(); + this._poly.fire('editdrag'); + }, + + _onMarkerClick: function (e) { + + var minPoints = L.Polygon && (this._poly instanceof L.Polygon) ? 4 : 3, + marker = e.target; + + // If removing this point would create an invalid polyline/polygon don't remove + if (this._defaultShape().length < minPoints) { + return; + } + + // remove the marker + this._removeMarker(marker); + + // update prev/next links of adjacent markers + this._updatePrevNext(marker._prev, marker._next); + + // remove ghost markers near the removed marker + if (marker._middleLeft) { + this._markerGroup.removeLayer(marker._middleLeft); + } + if (marker._middleRight) { + this._markerGroup.removeLayer(marker._middleRight); + } + + // create a ghost marker in place of the removed one + if (marker._prev && marker._next) { + this._createMiddleMarker(marker._prev, marker._next); + + } else if (!marker._prev) { + marker._next._middleLeft = null; + + } else if (!marker._next) { + marker._prev._middleRight = null; + } + + this._fireEdit(); + }, + + _onContextMenu: function (e) { + var marker = e.target; + var poly = this._poly; + this._poly._map.fire(L.Draw.Event.MARKERCONTEXT, {marker: marker, layers: this._markerGroup, poly: this._poly}); + L.DomEvent.stopPropagation; + }, + + _onTouchMove: function (e) { + + var layerPoint = this._map.mouseEventToLayerPoint(e.originalEvent.touches[0]), + latlng = this._map.layerPointToLatLng(layerPoint), + marker = e.target; + + L.extend(marker._origLatLng, latlng); + + if (marker._middleLeft) { + marker._middleLeft.setLatLng(this._getMiddleLatLng(marker._prev, marker)); + } + if (marker._middleRight) { + marker._middleRight.setLatLng(this._getMiddleLatLng(marker, marker._next)); + } + + this._poly.redraw(); + this.updateMarkers(); + }, + + _updateIndexes: function (index, delta) { + this._markerGroup.eachLayer(function (marker) { + if (marker._index > index) { + marker._index += delta; + } + }); + }, + + _createMiddleMarker: function (marker1, marker2) { + var latlng = this._getMiddleLatLng(marker1, marker2), + marker = this._createMarker(latlng), + onClick, + onDragStart, + onDragEnd; + + marker.setOpacity(0.6); + + marker1._middleRight = marker2._middleLeft = marker; + + onDragStart = function () { + marker.off('touchmove', onDragStart, this); + var i = marker2._index; + + marker._index = i; + + marker + .off('click', onClick, this) + .on('click', this._onMarkerClick, this); + + latlng.lat = marker.getLatLng().lat; + latlng.lng = marker.getLatLng().lng; + this._spliceLatLngs(i, 0, latlng); + this._markers.splice(i, 0, marker); + + marker.setOpacity(1); + + this._updateIndexes(i, 1); + marker2._index++; + this._updatePrevNext(marker1, marker); + this._updatePrevNext(marker, marker2); + + this._poly.fire('editstart'); + }; + + onDragEnd = function () { + marker.off('dragstart', onDragStart, this); + marker.off('dragend', onDragEnd, this); + marker.off('touchmove', onDragStart, this); + + this._createMiddleMarker(marker1, marker); + this._createMiddleMarker(marker, marker2); + }; + + onClick = function () { + onDragStart.call(this); + onDragEnd.call(this); + this._fireEdit(); + }; + + marker + .on('click', onClick, this) + .on('dragstart', onDragStart, this) + .on('dragend', onDragEnd, this) + .on('touchmove', onDragStart, this); + + this._markerGroup.addLayer(marker); + }, + + _updatePrevNext: function (marker1, marker2) { + if (marker1) { + marker1._next = marker2; + } + if (marker2) { + marker2._prev = marker1; + } + }, + + _getMiddleLatLng: function (marker1, marker2) { + var map = this._poly._map, + p1 = map.project(marker1.getLatLng()), + p2 = map.project(marker2.getLatLng()); + + return map.unproject(p1._add(p2)._divideBy(2)); + } +}); + +L.Polyline.addInitHook(function () { + + // Check to see if handler has already been initialized. This is to support versions of Leaflet that still have L.Handler.PolyEdit + if (this.editing) { + return; + } + + if (L.Edit.Poly) { + + this.editing = new L.Edit.Poly(this); + + if (this.options.editable) { + this.editing.enable(); + } + } + + this.on('add', function () { + if (this.editing && this.editing.enabled()) { + this.editing.addHooks(); + } + }); + + this.on('remove', function () { + if (this.editing && this.editing.enabled()) { + this.editing.removeHooks(); + } + }); +}); + + + +L.Edit = L.Edit || {}; +/** + * @class L.Edit.SimpleShape + * @aka Edit.SimpleShape + */ +L.Edit.SimpleShape = L.Handler.extend({ + options: { + moveIcon: new L.DivIcon({ + iconSize: new L.Point(8, 8), + className: 'leaflet-div-icon leaflet-editing-icon leaflet-edit-move' + }), + resizeIcon: new L.DivIcon({ + iconSize: new L.Point(8, 8), + className: 'leaflet-div-icon leaflet-editing-icon leaflet-edit-resize' + }), + touchMoveIcon: new L.DivIcon({ + iconSize: new L.Point(20, 20), + className: 'leaflet-div-icon leaflet-editing-icon leaflet-edit-move leaflet-touch-icon' + }), + touchResizeIcon: new L.DivIcon({ + iconSize: new L.Point(20, 20), + className: 'leaflet-div-icon leaflet-editing-icon leaflet-edit-resize leaflet-touch-icon' + }), + }, + + // @method intialize(): void + initialize: function (shape, options) { + // if touch, switch to touch icon + if (L.Browser.touch) { + this.options.moveIcon = this.options.touchMoveIcon; + this.options.resizeIcon = this.options.touchResizeIcon; + } + + this._shape = shape; + L.Util.setOptions(this, options); + }, + + // @method addHooks(): void + // Add listener hooks to this handler + addHooks: function () { + var shape = this._shape; + if (this._shape._map) { + this._map = this._shape._map; + shape.setStyle(shape.options.editing); + + if (shape._map) { + this._map = shape._map; + if (!this._markerGroup) { + this._initMarkers(); + } + this._map.addLayer(this._markerGroup); + } + } + }, + + // @method removeHooks(): void + // Remove listener hooks from this handler + removeHooks: function () { + var shape = this._shape; + + shape.setStyle(shape.options.original); + + if (shape._map) { + this._unbindMarker(this._moveMarker); + + for (var i = 0, l = this._resizeMarkers.length; i < l; i++) { + this._unbindMarker(this._resizeMarkers[i]); + } + this._resizeMarkers = null; + + this._map.removeLayer(this._markerGroup); + delete this._markerGroup; + } + + this._map = null; + }, + + // @method updateMarkers(): void + // Remove the edit markers from this layer + updateMarkers: function () { + this._markerGroup.clearLayers(); + this._initMarkers(); + }, + + _initMarkers: function () { + if (!this._markerGroup) { + this._markerGroup = new L.LayerGroup(); + } + + // Create center marker + this._createMoveMarker(); + + // Create edge marker + this._createResizeMarker(); + }, + + _createMoveMarker: function () { + // Children override + }, + + _createResizeMarker: function () { + // Children override + }, + + _createMarker: function (latlng, icon) { + // Extending L.Marker in TouchEvents.js to include touch. + var marker = new L.Marker.Touch(latlng, { + draggable: true, + icon: icon, + zIndexOffset: 10 + }); + + this._bindMarker(marker); + + this._markerGroup.addLayer(marker); + + return marker; + }, + + _bindMarker: function (marker) { + marker + .on('dragstart', this._onMarkerDragStart, this) + .on('drag', this._onMarkerDrag, this) + .on('dragend', this._onMarkerDragEnd, this) + .on('touchstart', this._onTouchStart, this) + .on('touchmove', this._onTouchMove, this) + .on('MSPointerMove', this._onTouchMove, this) + .on('touchend', this._onTouchEnd, this) + .on('MSPointerUp', this._onTouchEnd, this); + }, + + _unbindMarker: function (marker) { + marker + .off('dragstart', this._onMarkerDragStart, this) + .off('drag', this._onMarkerDrag, this) + .off('dragend', this._onMarkerDragEnd, this) + .off('touchstart', this._onTouchStart, this) + .off('touchmove', this._onTouchMove, this) + .off('MSPointerMove', this._onTouchMove, this) + .off('touchend', this._onTouchEnd, this) + .off('MSPointerUp', this._onTouchEnd, this); + }, + + _onMarkerDragStart: function (e) { + var marker = e.target; + marker.setOpacity(0); + + this._shape.fire('editstart'); + }, + + _fireEdit: function () { + this._shape.edited = true; + this._shape.fire('edit'); + }, + + _onMarkerDrag: function (e) { + var marker = e.target, + latlng = marker.getLatLng(); + + if (marker === this._moveMarker) { + this._move(latlng); + } else { + this._resize(latlng); + } + + this._shape.redraw(); + this._shape.fire('editdrag'); + }, + + _onMarkerDragEnd: function (e) { + var marker = e.target; + marker.setOpacity(1); + + this._fireEdit(); + }, + + _onTouchStart: function (e) { + L.Edit.SimpleShape.prototype._onMarkerDragStart.call(this, e); + + if (typeof(this._getCorners) === 'function') { + // Save a reference to the opposite point + var corners = this._getCorners(), + marker = e.target, + currentCornerIndex = marker._cornerIndex; + + marker.setOpacity(0); + + // Copyed from Edit.Rectangle.js line 23 _onMarkerDragStart() + // Latlng is null otherwise. + this._oppositeCorner = corners[(currentCornerIndex + 2) % 4]; + this._toggleCornerMarkers(0, currentCornerIndex); + } + + this._shape.fire('editstart'); + }, + + _onTouchMove: function (e) { + var layerPoint = this._map.mouseEventToLayerPoint(e.originalEvent.touches[0]), + latlng = this._map.layerPointToLatLng(layerPoint), + marker = e.target; + + if (marker === this._moveMarker) { + this._move(latlng); + } else { + this._resize(latlng); + } + + this._shape.redraw(); + + // prevent touchcancel in IOS + // e.preventDefault(); + return false; + }, + + _onTouchEnd: function (e) { + var marker = e.target; + marker.setOpacity(1); + this.updateMarkers(); + this._fireEdit(); + }, + + _move: function () { + // Children override + }, + + _resize: function () { + // Children override + } +}); + + + +L.Edit = L.Edit || {}; +/** + * @class L.Edit.Rectangle + * @aka Edit.Rectangle + * @inherits L.Edit.SimpleShape + */ +L.Edit.Rectangle = L.Edit.SimpleShape.extend({ + _createMoveMarker: function () { + var bounds = this._shape.getBounds(), + center = bounds.getCenter(); + + this._moveMarker = this._createMarker(center, this.options.moveIcon); + }, + + _createResizeMarker: function () { + var corners = this._getCorners(); + + this._resizeMarkers = []; + + for (var i = 0, l = corners.length; i < l; i++) { + this._resizeMarkers.push(this._createMarker(corners[i], this.options.resizeIcon)); + // Monkey in the corner index as we will need to know this for dragging + this._resizeMarkers[i]._cornerIndex = i; + } + }, + + _onMarkerDragStart: function (e) { + L.Edit.SimpleShape.prototype._onMarkerDragStart.call(this, e); + + // Save a reference to the opposite point + var corners = this._getCorners(), + marker = e.target, + currentCornerIndex = marker._cornerIndex; + + this._oppositeCorner = corners[(currentCornerIndex + 2) % 4]; + + this._toggleCornerMarkers(0, currentCornerIndex); + }, + + _onMarkerDragEnd: function (e) { + var marker = e.target, + bounds, center; + + // Reset move marker position to the center + if (marker === this._moveMarker) { + bounds = this._shape.getBounds(); + center = bounds.getCenter(); + + marker.setLatLng(center); + } + + this._toggleCornerMarkers(1); + + this._repositionCornerMarkers(); + + L.Edit.SimpleShape.prototype._onMarkerDragEnd.call(this, e); + }, + + _move: function (newCenter) { + var latlngs = this._shape._defaultShape ? this._shape._defaultShape() : this._shape.getLatLngs(), + bounds = this._shape.getBounds(), + center = bounds.getCenter(), + offset, newLatLngs = []; + + // Offset the latlngs to the new center + for (var i = 0, l = latlngs.length; i < l; i++) { + offset = [latlngs[i].lat - center.lat, latlngs[i].lng - center.lng]; + newLatLngs.push([newCenter.lat + offset[0], newCenter.lng + offset[1]]); + } + + this._shape.setLatLngs(newLatLngs); + + // Reposition the resize markers + this._repositionCornerMarkers(); + + this._map.fire(L.Draw.Event.EDITMOVE, {layer: this._shape}); + }, + + _resize: function (latlng) { + var bounds; + + // Update the shape based on the current position of this corner and the opposite point + this._shape.setBounds(L.latLngBounds(latlng, this._oppositeCorner)); + + // Reposition the move marker + bounds = this._shape.getBounds(); + this._moveMarker.setLatLng(bounds.getCenter()); + + this._map.fire(L.Draw.Event.EDITRESIZE, {layer: this._shape}); + }, + + _getCorners: function () { + var bounds = this._shape.getBounds(), + nw = bounds.getNorthWest(), + ne = bounds.getNorthEast(), + se = bounds.getSouthEast(), + sw = bounds.getSouthWest(); + + return [nw, ne, se, sw]; + }, + + _toggleCornerMarkers: function (opacity) { + for (var i = 0, l = this._resizeMarkers.length; i < l; i++) { + this._resizeMarkers[i].setOpacity(opacity); + } + }, + + _repositionCornerMarkers: function () { + var corners = this._getCorners(); + + for (var i = 0, l = this._resizeMarkers.length; i < l; i++) { + this._resizeMarkers[i].setLatLng(corners[i]); + } + } +}); + +L.Rectangle.addInitHook(function () { + if (L.Edit.Rectangle) { + this.editing = new L.Edit.Rectangle(this); + + if (this.options.editable) { + this.editing.enable(); + } + } +}); + + + +L.Edit = L.Edit || {}; +/** + * @class L.Edit.CircleMarker + * @aka Edit.Circle + * @inherits L.Edit.SimpleShape + */ +L.Edit.CircleMarker = L.Edit.SimpleShape.extend({ + _createMoveMarker: function () { + var center = this._shape.getLatLng(); + this._map._editTooltip = new L.Draw.Tooltip(this._map); + this._moveMarker = this._createMarker(center, this.options.moveIcon); + }, + + _createResizeMarker: function () { + // To avoid an undefined check in L.Edit.SimpleShape.removeHooks + this._resizeMarkers = []; + }, + + _move: function (latlng) { + if (this._resizeMarkers.length) { + var resizemarkerPoint = this._getResizeMarkerPoint(latlng); + // Move the resize marker + this._resizeMarkers[0].setLatLng(resizemarkerPoint); + } + + // Move the circle + this._shape.setLatLng(latlng); + + this._map.fire(L.Draw.Event.EDITMOVE, {layer: this._shape}); + }, +}); + +L.CircleMarker.addInitHook(function () { + if (L.Edit.CircleMarker) { + this.editing = new L.Edit.CircleMarker(this); + + if (this.options.editable) { + this.editing.enable(); + } + } + + this.on('add', function () { + if (this.editing && this.editing.enabled()) { + this.editing.addHooks(); + } + }); + + this.on('remove', function () { + if (this.editing && this.editing.enabled()) { + this.editing.removeHooks(); + } + }); +}); + + + +L.Edit = L.Edit || {}; +/** + * @class L.Edit.Circle + * @aka Edit.Circle + * @inherits L.Edit.CircleMarker + */ +L.Edit.Circle = L.Edit.CircleMarker.extend({ + + _createResizeMarker: function () { + var center = this._shape.getLatLng(), + resizemarkerPoint = this._getResizeMarkerPoint(center); + + this._resizeMarkers = []; + this._resizeMarkers.push(this._createMarker(resizemarkerPoint, this.options.resizeIcon)); + }, + + _getResizeMarkerPoint: function (latlng) { + // From L.shape.getBounds() + var delta = this._shape._radius * Math.cos(Math.PI / 4), + point = this._map.project(latlng); + return this._map.unproject([point.x + delta, point.y - delta]); + }, + + _resize: function (latlng) { + var moveLatLng = this._moveMarker.getLatLng(); + + // Calculate the radius based on the version + if (L.GeometryUtil.isVersion07x()) { + radius = moveLatLng.distanceTo(latlng); + } else { + radius = this._map.distance(moveLatLng, latlng); + } + this._shape.setRadius(radius); + + if (this._map.editTooltip) { + this._map._editTooltip.updatePosition(latlng); + this._map._editTooltip.updateContent({ + text: L.drawLocal.edit.handlers.edit.tooltip.subtext + '
' + L.drawLocal.edit.handlers.edit.tooltip.text, + subtext: L.drawLocal.draw.handlers.circle.radius + ': ' + + L.GeometryUtil.readableDistance(radius, true, this.options.feet, this.options.nautic) + }); + } + + this._shape.setRadius(radius); + + this._map.fire(L.Draw.Event.EDITRESIZE, {layer: this._shape}); + } +}); + +L.Circle.addInitHook(function () { + if (L.Edit.Circle) { + this.editing = new L.Edit.Circle(this); + + if (this.options.editable) { + this.editing.enable(); + } + } +}); + + + +L.Map.mergeOptions({ + touchExtend: true +}); + +/** + * @class L.Map.TouchExtend + * @aka TouchExtend + */ +L.Map.TouchExtend = L.Handler.extend({ + + // @method initialize(): void + // Sets TouchExtend private accessor variables + initialize: function (map) { + this._map = map; + this._container = map._container; + this._pane = map._panes.overlayPane; + }, + + // @method addHooks(): void + // Adds dom listener events to the map container + addHooks: function () { + L.DomEvent.on(this._container, 'touchstart', this._onTouchStart, this); + L.DomEvent.on(this._container, 'touchend', this._onTouchEnd, this); + L.DomEvent.on(this._container, 'touchmove', this._onTouchMove, this); + if (this._detectIE()) { + L.DomEvent.on(this._container, 'MSPointerDown', this._onTouchStart, this); + L.DomEvent.on(this._container, 'MSPointerUp', this._onTouchEnd, this); + L.DomEvent.on(this._container, 'MSPointerMove', this._onTouchMove, this); + L.DomEvent.on(this._container, 'MSPointerCancel', this._onTouchCancel, this); + + } else { + L.DomEvent.on(this._container, 'touchcancel', this._onTouchCancel, this); + L.DomEvent.on(this._container, 'touchleave', this._onTouchLeave, this); + } + }, + + // @method removeHooks(): void + // Removes dom listener events from the map container + removeHooks: function () { + L.DomEvent.off(this._container, 'touchstart', this._onTouchStart, this); + L.DomEvent.off(this._container, 'touchend', this._onTouchEnd, this); + L.DomEvent.off(this._container, 'touchmove', this._onTouchMove, this); + if (this._detectIE()) { + L.DomEvent.off(this._container, 'MSPointerDown', this._onTouchStart, this); + L.DomEvent.off(this._container, 'MSPointerUp', this._onTouchEnd, this); + L.DomEvent.off(this._container, 'MSPointerMove', this._onTouchMove, this); + L.DomEvent.off(this._container, 'MSPointerCancel', this._onTouchCancel, this); + } else { + L.DomEvent.off(this._container, 'touchcancel', this._onTouchCancel, this); + L.DomEvent.off(this._container, 'touchleave', this._onTouchLeave, this); + } + }, + + _touchEvent: function (e, type) { + // #TODO: fix the pageX error that is do a bug in Android where a single touch triggers two click events + // _filterClick is what leaflet uses as a workaround. + // This is a problem with more things than just android. Another problem is touchEnd has no touches in + // its touch list. + var touchEvent = {}; + if (typeof e.touches !== 'undefined') { + if (!e.touches.length) { + return; + } + touchEvent = e.touches[0]; + } else if (e.pointerType === 'touch') { + touchEvent = e; + if (!this._filterClick(e)) { + return; + } + } else { + return; + } + + var containerPoint = this._map.mouseEventToContainerPoint(touchEvent), + layerPoint = this._map.mouseEventToLayerPoint(touchEvent), + latlng = this._map.layerPointToLatLng(layerPoint); + + this._map.fire(type, { + latlng: latlng, + layerPoint: layerPoint, + containerPoint: containerPoint, + pageX: touchEvent.pageX, + pageY: touchEvent.pageY, + originalEvent: e + }); + }, + + /** Borrowed from Leaflet and modified for bool ops **/ + _filterClick: function (e) { + var timeStamp = (e.timeStamp || e.originalEvent.timeStamp), + elapsed = L.DomEvent._lastClick && (timeStamp - L.DomEvent._lastClick); + + // are they closer together than 500ms yet more than 100ms? + // Android typically triggers them ~300ms apart while multiple listeners + // on the same event should be triggered far faster; + // or check if click is simulated on the element, and if it is, reject any non-simulated events + if ((elapsed && elapsed > 100 && elapsed < 500) || (e.target._simulatedClick && !e._simulated)) { + L.DomEvent.stop(e); + return false; + } + L.DomEvent._lastClick = timeStamp; + return true; + }, + + _onTouchStart: function (e) { + if (!this._map._loaded) { + return; + } + + var type = 'touchstart'; + this._touchEvent(e, type); + + }, + + _onTouchEnd: function (e) { + if (!this._map._loaded) { + return; + } + + var type = 'touchend'; + this._touchEvent(e, type); + }, + + _onTouchCancel: function (e) { + if (!this._map._loaded) { + return; + } + + var type = 'touchcancel'; + if (this._detectIE()) { + type = 'pointercancel'; + } + this._touchEvent(e, type); + }, + + _onTouchLeave: function (e) { + if (!this._map._loaded) { + return; + } + + var type = 'touchleave'; + this._touchEvent(e, type); + }, + + _onTouchMove: function (e) { + if (!this._map._loaded) { + return; + } + + var type = 'touchmove'; + this._touchEvent(e, type); + }, + + _detectIE: function () { + var ua = window.navigator.userAgent; + + var msie = ua.indexOf('MSIE '); + if (msie > 0) { + // IE 10 or older => return version number + return parseInt(ua.substring(msie + 5, ua.indexOf('.', msie)), 10); + } + + var trident = ua.indexOf('Trident/'); + if (trident > 0) { + // IE 11 => return version number + var rv = ua.indexOf('rv:'); + return parseInt(ua.substring(rv + 3, ua.indexOf('.', rv)), 10); + } + + var edge = ua.indexOf('Edge/'); + if (edge > 0) { + // IE 12 => return version number + return parseInt(ua.substring(edge + 5, ua.indexOf('.', edge)), 10); + } + + // other browser + return false; + } +}); + +L.Map.addInitHook('addHandler', 'touchExtend', L.Map.TouchExtend); + + +/** + * @class L.Marker.Touch + * @aka Marker.Touch + * + * This isn't full Touch support. This is just to get markers to also support dom touch events after creation + * #TODO: find a better way of getting markers to support touch. + */ +L.Marker.Touch = L.Marker.extend({ + + _initInteraction: function () { + if (!this.addInteractiveTarget) { + // 0.7.x support + return this._initInteractionLegacy(); + } + // TODO this may need be updated to re-add touch events for 1.0+ + return L.Marker.prototype._initInteraction.apply(this); + }, + + // This is an exact copy of https://github.com/Leaflet/Leaflet/blob/v0.7/src/layer/marker/Marker.js + // with the addition of the touch events + _initInteractionLegacy: function () { + + if (!this.options.clickable) { + return; + } + + // TODO refactor into something shared with Map/Path/etc. to DRY it up + + var icon = this._icon, + events = ['dblclick', + 'mousedown', + 'mouseover', + 'mouseout', + 'contextmenu', + 'touchstart', + 'touchend', + 'touchmove']; + if (this._detectIE) { + events.concat(['MSPointerDown', + 'MSPointerUp', + 'MSPointerMove', + 'MSPointerCancel']); + } else { + events.concat(['touchcancel']); + } + + L.DomUtil.addClass(icon, 'leaflet-clickable'); + L.DomEvent.on(icon, 'click', this._onMouseClick, this); + L.DomEvent.on(icon, 'keypress', this._onKeyPress, this); + + for (var i = 0; i < events.length; i++) { + L.DomEvent.on(icon, events[i], this._fireMouseEvent, this); + } + + if (L.Handler.MarkerDrag) { + this.dragging = new L.Handler.MarkerDrag(this); + + if (this.options.draggable) { + this.dragging.enable(); + } + } + }, + + _detectIE: function () { + var ua = window.navigator.userAgent; + + var msie = ua.indexOf('MSIE '); + if (msie > 0) { + // IE 10 or older => return version number + return parseInt(ua.substring(msie + 5, ua.indexOf('.', msie)), 10); + } + + var trident = ua.indexOf('Trident/'); + if (trident > 0) { + // IE 11 => return version number + var rv = ua.indexOf('rv:'); + return parseInt(ua.substring(rv + 3, ua.indexOf('.', rv)), 10); + } + + var edge = ua.indexOf('Edge/'); + if (edge > 0) { + // IE 12 => return version number + return parseInt(ua.substring(edge + 5, ua.indexOf('.', edge)), 10); + } + + // other browser + return false; + } +}); + + + +/** + * @class L.LatLngUtil + * @aka LatLngUtil + */ +L.LatLngUtil = { + // Clones a LatLngs[], returns [][] + + // @method cloneLatLngs(LatLngs[]): L.LatLngs[] + // Clone the latLng point or points or nested points and return an array with those points + cloneLatLngs: function (latlngs) { + var clone = []; + for (var i = 0, l = latlngs.length; i < l; i++) { + // Check for nested array (Polyline/Polygon) + if (Array.isArray(latlngs[i])) { + clone.push(L.LatLngUtil.cloneLatLngs(latlngs[i])); + } else { + clone.push(this.cloneLatLng(latlngs[i])); + } + } + return clone; + }, + + // @method cloneLatLng(LatLng): L.LatLng + // Clone the latLng and return a new LatLng object. + cloneLatLng: function (latlng) { + return L.latLng(latlng.lat, latlng.lng); + } +}; + + + +(function () { + + var defaultPrecision = { + km: 2, + ha: 2, + m: 0, + mi: 2, + ac: 2, + yd: 0, + ft: 0, + nm: 2 + }; + + + /** + * @class L.GeometryUtil + * @aka GeometryUtil + */ + L.GeometryUtil = L.extend(L.GeometryUtil || {}, { + // Ported from the OpenLayers implementation. See https://github.com/openlayers/openlayers/blob/master/lib/OpenLayers/Geometry/LinearRing.js#L270 + + // @method geodesicArea(): number + geodesicArea: function (latLngs) { + var pointsCount = latLngs.length, + area = 0.0, + d2r = Math.PI / 180, + p1, p2; + + if (pointsCount > 2) { + for (var i = 0; i < pointsCount; i++) { + p1 = latLngs[i]; + p2 = latLngs[(i + 1) % pointsCount]; + area += ((p2.lng - p1.lng) * d2r) * + (2 + Math.sin(p1.lat * d2r) + Math.sin(p2.lat * d2r)); + } + area = area * 6378137.0 * 6378137.0 / 2.0; + } + + return Math.abs(area); + }, + + // @method formattedNumber(n, precision): string + // Returns n in specified number format (if defined) and precision + formattedNumber: function (n, precision) { + var formatted = parseFloat(n).toFixed(precision), + format = L.drawLocal.format && L.drawLocal.format.numeric, + delimiters = format && format.delimiters, + thousands = delimiters && delimiters.thousands, + decimal = delimiters && delimiters.decimal; + + if (thousands || decimal) { + var splitValue = formatted.split('.'); + formatted = thousands ? splitValue[0].replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1' + thousands) : splitValue[0]; + decimal = decimal || '.'; + if (splitValue.length > 1) { + formatted = formatted + decimal + splitValue[1]; + } + } + + return formatted; + }, + + // @method readableArea(area, isMetric, precision): string + // Returns a readable area string in yards or metric. + // The value will be rounded as defined by the precision option object. + readableArea: function (area, isMetric, precision) { + var areaStr, + units, + precision = L.Util.extend({}, defaultPrecision, precision); + + if (isMetric) { + units = ['ha', 'm']; + type = typeof isMetric; + if (type === 'string') { + units = [isMetric]; + } else if (type !== 'boolean') { + units = isMetric; + } + + if (area >= 1000000 && units.indexOf('km') !== -1) { + areaStr = L.GeometryUtil.formattedNumber(area * 0.000001, precision['km']) + ' km²'; + } else if (area >= 10000 && units.indexOf('ha') !== -1) { + areaStr = L.GeometryUtil.formattedNumber(area * 0.0001, precision['ha']) + ' ha'; + } else { + areaStr = L.GeometryUtil.formattedNumber(area, precision['m']) + ' m²'; + } + } else { + area /= 0.836127; // Square yards in 1 meter + + if (area >= 3097600) { //3097600 square yards in 1 square mile + areaStr = L.GeometryUtil.formattedNumber(area / 3097600, precision['mi']) + ' mi²'; + } else if (area >= 4840) { //4840 square yards in 1 acre + areaStr = L.GeometryUtil.formattedNumber(area / 4840, precision['ac']) + ' acres'; + } else { + areaStr = L.GeometryUtil.formattedNumber(area, precision['yd']) + ' yd²'; + } + } + + return areaStr; + }, + + // @method readableDistance(distance, units): string + // Converts a metric distance to one of [ feet, nauticalMile, metric or yards ] string + // + // @alternative + // @method readableDistance(distance, isMetric, useFeet, isNauticalMile, precision): string + // Converts metric distance to distance string. + // The value will be rounded as defined by the precision option object. + readableDistance: function (distance, isMetric, isFeet, isNauticalMile, precision) { + var distanceStr, + units, + precision = L.Util.extend({}, defaultPrecision, precision); + + if (isMetric) { + units = typeof isMetric == 'string' ? isMetric : 'metric'; + } else if (isFeet) { + units = 'feet'; + } else if (isNauticalMile) { + units = 'nauticalMile'; + } else { + units = 'yards'; + } + + switch (units) { + case 'metric': + // show metres when distance is < 1km, then show km + if (distance > 1000) { + distanceStr = L.GeometryUtil.formattedNumber(distance / 1000, precision['km']) + ' km'; + } else { + distanceStr = L.GeometryUtil.formattedNumber(distance, precision['m']) + ' m'; + } + break; + case 'feet': + distance *= 1.09361 * 3; + distanceStr = L.GeometryUtil.formattedNumber(distance, precision['ft']) + ' ft'; + + break; + case 'nauticalMile': + distance *= 0.53996; + distanceStr = L.GeometryUtil.formattedNumber(distance / 1000, precision['nm']) + ' nm'; + break; + case 'yards': + default: + distance *= 1.09361; + + if (distance > 1760) { + distanceStr = L.GeometryUtil.formattedNumber(distance / 1760, precision['mi']) + ' miles'; + } else { + distanceStr = L.GeometryUtil.formattedNumber(distance, precision['yd']) + ' yd'; + } + break; + } + return distanceStr; + }, + + // @method isVersion07x(): boolean + // Returns true if the Leaflet version is 0.7.x, false otherwise. + isVersion07x: function () { + var version = L.version.split('.'); + //If Version is == 0.7.* + return parseInt(version[0], 10) === 0 && parseInt(version[1], 10) === 7; + }, + }); + +})(); + + + +/** + * @class L.LineUtil + * @aka Util + * @aka L.Utils + */ +L.Util.extend(L.LineUtil, { + + // @method segmentsIntersect(): boolean + // Checks to see if two line segments intersect. Does not handle degenerate cases. + // http://compgeom.cs.uiuc.edu/~jeffe/teaching/373/notes/x06-sweepline.pdf + segmentsIntersect: function (/*Point*/ p, /*Point*/ p1, /*Point*/ p2, /*Point*/ p3) { + return this._checkCounterclockwise(p, p2, p3) !== + this._checkCounterclockwise(p1, p2, p3) && + this._checkCounterclockwise(p, p1, p2) !== + this._checkCounterclockwise(p, p1, p3); + }, + + // check to see if points are in counterclockwise order + _checkCounterclockwise: function (/*Point*/ p, /*Point*/ p1, /*Point*/ p2) { + return (p2.y - p.y) * (p1.x - p.x) > (p1.y - p.y) * (p2.x - p.x); + } +}); + + + +/** + * @class L.Polyline + * @aka Polyline + */ +L.Polyline.include({ + + // @method intersects(): boolean + // Check to see if this polyline has any linesegments that intersect. + // NOTE: does not support detecting intersection for degenerate cases. + intersects: function () { + var points = this._getProjectedPoints(), + len = points ? points.length : 0, + i, p, p1; + + if (this._tooFewPointsForIntersection()) { + return false; + } + + for (i = len - 1; i >= 3; i--) { + p = points[i - 1]; + p1 = points[i]; + + + if (this._lineSegmentsIntersectsRange(p, p1, i - 2)) { + return true; + } + } + + return false; + }, + + // @method newLatLngIntersects(): boolean + // Check for intersection if new latlng was added to this polyline. + // NOTE: does not support detecting intersection for degenerate cases. + newLatLngIntersects: function (latlng, skipFirst) { + // Cannot check a polyline for intersecting lats/lngs when not added to the map + if (!this._map) { + return false; + } + + return this.newPointIntersects(this._map.latLngToLayerPoint(latlng), skipFirst); + }, + + // @method newPointIntersects(): boolean + // Check for intersection if new point was added to this polyline. + // newPoint must be a layer point. + // NOTE: does not support detecting intersection for degenerate cases. + newPointIntersects: function (newPoint, skipFirst) { + var points = this._getProjectedPoints(), + len = points ? points.length : 0, + lastPoint = points ? points[len - 1] : null, + // The previous previous line segment. Previous line segment doesn't need testing. + maxIndex = len - 2; + + if (this._tooFewPointsForIntersection(1)) { + return false; + } + + return this._lineSegmentsIntersectsRange(lastPoint, newPoint, maxIndex, skipFirst ? 1 : 0); + }, + + // Polylines with 2 sides can only intersect in cases where points are collinear (we don't support detecting these). + // Cannot have intersection when < 3 line segments (< 4 points) + _tooFewPointsForIntersection: function (extraPoints) { + var points = this._getProjectedPoints(), + len = points ? points.length : 0; + // Increment length by extraPoints if present + len += extraPoints || 0; + + return !points || len <= 3; + }, + + // Checks a line segment intersections with any line segments before its predecessor. + // Don't need to check the predecessor as will never intersect. + _lineSegmentsIntersectsRange: function (p, p1, maxIndex, minIndex) { + var points = this._getProjectedPoints(), + p2, p3; + + minIndex = minIndex || 0; + + // Check all previous line segments (beside the immediately previous) for intersections + for (var j = maxIndex; j > minIndex; j--) { + p2 = points[j - 1]; + p3 = points[j]; + + if (L.LineUtil.segmentsIntersect(p, p1, p2, p3)) { + return true; + } + } + + return false; + }, + + _getProjectedPoints: function () { + if (!this._defaultShape) { + return this._originalPoints; + } + var points = [], + _shape = this._defaultShape(); + + for (var i = 0; i < _shape.length; i++) { + points.push(this._map.latLngToLayerPoint(_shape[i])); + } + return points; + } +}); + + + +/** + * @class L.Polygon + * @aka Polygon + */ +L.Polygon.include({ + + // @method intersects(): boolean + // Checks a polygon for any intersecting line segments. Ignores holes. + intersects: function () { + var polylineIntersects, + points = this._getProjectedPoints(), + len, firstPoint, lastPoint, maxIndex; + + if (this._tooFewPointsForIntersection()) { + return false; + } + + polylineIntersects = L.Polyline.prototype.intersects.call(this); + + // If already found an intersection don't need to check for any more. + if (polylineIntersects) { + return true; + } + + len = points.length; + firstPoint = points[0]; + lastPoint = points[len - 1]; + maxIndex = len - 2; + + // Check the line segment between last and first point. Don't need to check the first line segment (minIndex = 1) + return this._lineSegmentsIntersectsRange(lastPoint, firstPoint, maxIndex, 1); + } +}); + + + +/** + * @class L.Control.Draw + * @aka L.Draw + */ +L.Control.Draw = L.Control.extend({ + + // Options + options: { + position: 'topleft', + draw: {}, + edit: false + }, + + // @method initialize(): void + // Initializes draw control, toolbars from the options + initialize: function (options) { + if (L.version < '0.7') { + throw new Error('Leaflet.draw 0.2.3+ requires Leaflet 0.7.0+. Download latest from https://github.com/Leaflet/Leaflet/'); + } + + L.Control.prototype.initialize.call(this, options); + + var toolbar; + + this._toolbars = {}; + + // Initialize toolbars + if (L.DrawToolbar && this.options.draw) { + toolbar = new L.DrawToolbar(this.options.draw); + + this._toolbars[L.DrawToolbar.TYPE] = toolbar; + + // Listen for when toolbar is enabled + this._toolbars[L.DrawToolbar.TYPE].on('enable', this._toolbarEnabled, this); + } + + if (L.EditToolbar && this.options.edit) { + toolbar = new L.EditToolbar(this.options.edit); + + this._toolbars[L.EditToolbar.TYPE] = toolbar; + + // Listen for when toolbar is enabled + this._toolbars[L.EditToolbar.TYPE].on('enable', this._toolbarEnabled, this); + } + L.toolbar = this; //set global var for editing the toolbar + }, + + // @method onAdd(): container + // Adds the toolbar container to the map + onAdd: function (map) { + var container = L.DomUtil.create('div', 'leaflet-draw'), + addedTopClass = false, + topClassName = 'leaflet-draw-toolbar-top', + toolbarContainer; + + for (var toolbarId in this._toolbars) { + if (this._toolbars.hasOwnProperty(toolbarId)) { + toolbarContainer = this._toolbars[toolbarId].addToolbar(map); + + if (toolbarContainer) { + // Add class to the first toolbar to remove the margin + if (!addedTopClass) { + if (!L.DomUtil.hasClass(toolbarContainer, topClassName)) { + L.DomUtil.addClass(toolbarContainer.childNodes[0], topClassName); + } + addedTopClass = true; + } + + container.appendChild(toolbarContainer); + } + } + } + + return container; + }, + + // @method onRemove(): void + // Removes the toolbars from the map toolbar container + onRemove: function () { + for (var toolbarId in this._toolbars) { + if (this._toolbars.hasOwnProperty(toolbarId)) { + this._toolbars[toolbarId].removeToolbar(); + } + } + }, + + // @method setDrawingOptions(options): void + // Sets options to all toolbar instances + setDrawingOptions: function (options) { + for (var toolbarId in this._toolbars) { + if (this._toolbars[toolbarId] instanceof L.DrawToolbar) { + this._toolbars[toolbarId].setOptions(options); + } + } + }, + + _toolbarEnabled: function (e) { + var enabledToolbar = e.target; + + for (var toolbarId in this._toolbars) { + if (this._toolbars[toolbarId] !== enabledToolbar) { + this._toolbars[toolbarId].disable(); + } + } + } +}); + +L.Map.mergeOptions({ + drawControlTooltips: true, + drawControl: false +}); + +L.Map.addInitHook(function () { + if (this.options.drawControl) { + this.drawControl = new L.Control.Draw(); + this.addControl(this.drawControl); + } +}); + + + +/** + * @class L.Draw.Toolbar + * @aka Toolbar + * + * The toolbar class of the API — it is used to create the ui + * This will be depreciated + * + * @example + * + * ```js + * var toolbar = L.Toolbar(); + * toolbar.addToolbar(map); + * ``` + * + * ### Disabling a toolbar + * + * If you do not want a particular toolbar in your app you can turn it off by setting the toolbar to false. + * + * ```js + * var drawControl = new L.Control.Draw({ + * draw: false, + * edit: { + * featureGroup: editableLayers + * } + * }); + * ``` + * + * ### Disabling a toolbar item + * + * If you want to turn off a particular toolbar item, set it to false. The following disables drawing polygons and + * markers. It also turns off the ability to edit layers. + * + * ```js + * var drawControl = new L.Control.Draw({ + * draw: { + * polygon: false, + * marker: false + * }, + * edit: { + * featureGroup: editableLayers, + * edit: false + * } + * }); + * ``` + */ +L.Toolbar = L.Class.extend({ + // @section Methods for modifying the toolbar + + // @method initialize(options): void + // Toolbar constructor + initialize: function (options) { + L.setOptions(this, options); + + this._modes = {}; + this._actionButtons = []; + this._activeMode = null; + + var version = L.version.split('.'); + //If Version is >= 1.2.0 + if (parseInt(version[0], 10) === 1 && parseInt(version[1], 10) >= 2) { + L.Toolbar.include(L.Evented.prototype); + } else { + L.Toolbar.include(L.Mixin.Events); + } + }, + + // @method enabled(): boolean + // Gets a true/false of whether the toolbar is enabled + enabled: function () { + return this._activeMode !== null; + }, + + // @method disable(): void + // Disables the toolbar + disable: function () { + if (!this.enabled()) { + return; + } + + this._activeMode.handler.disable(); + }, + + // @method addToolbar(map): L.DomUtil + // Adds the toolbar to the map and returns the toolbar dom element + addToolbar: function (map) { + var container = L.DomUtil.create('div', 'leaflet-draw-section'), + buttonIndex = 0, + buttonClassPrefix = this._toolbarClass || '', + modeHandlers = this.getModeHandlers(map), + i; + + this._toolbarContainer = L.DomUtil.create('div', 'leaflet-draw-toolbar leaflet-bar'); + this._map = map; + + for (i = 0; i < modeHandlers.length; i++) { + if (modeHandlers[i].enabled) { + this._initModeHandler( + modeHandlers[i].handler, + this._toolbarContainer, + buttonIndex++, + buttonClassPrefix, + modeHandlers[i].title + ); + } + } + + // if no buttons were added, do not add the toolbar + if (!buttonIndex) { + return; + } + + // Save button index of the last button, -1 as we would have ++ after the last button + this._lastButtonIndex = --buttonIndex; + + // Create empty actions part of the toolbar + this._actionsContainer = L.DomUtil.create('ul', 'leaflet-draw-actions'); + + // Add draw and cancel containers to the control container + container.appendChild(this._toolbarContainer); + container.appendChild(this._actionsContainer); + + return container; + }, + + // @method removeToolbar(): void + // Removes the toolbar and drops the handler event listeners + removeToolbar: function () { + // Dispose each handler + for (var handlerId in this._modes) { + if (this._modes.hasOwnProperty(handlerId)) { + // Unbind handler button + this._disposeButton( + this._modes[handlerId].button, + this._modes[handlerId].handler.enable, + this._modes[handlerId].handler + ); + + // Make sure is disabled + this._modes[handlerId].handler.disable(); + + // Unbind handler + this._modes[handlerId].handler + .off('enabled', this._handlerActivated, this) + .off('disabled', this._handlerDeactivated, this); + } + } + this._modes = {}; + + // Dispose the actions toolbar + for (var i = 0, l = this._actionButtons.length; i < l; i++) { + this._disposeButton( + this._actionButtons[i].button, + this._actionButtons[i].callback, + this + ); + } + this._actionButtons = []; + this._actionsContainer = null; + }, + + _initModeHandler: function (handler, container, buttonIndex, classNamePredix, buttonTitle) { + var type = handler.type; + + this._modes[type] = {}; + + this._modes[type].handler = handler; + + this._modes[type].button = this._createButton({ + type: type, + title: buttonTitle, + className: classNamePredix + '-' + type, + container: container, + callback: this._modes[type].handler.enable, + context: this._modes[type].handler + }); + + this._modes[type].buttonIndex = buttonIndex; + + this._modes[type].handler + .on('enabled', this._handlerActivated, this) + .on('disabled', this._handlerDeactivated, this); + }, + + /* Detect iOS based on browser User Agent, based on: + * http://stackoverflow.com/a/9039885 */ + _detectIOS: function () { + var iOS = (/iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream); + return iOS; + }, + + _createButton: function (options) { + + var link = L.DomUtil.create('a', options.className || '', options.container); + // Screen reader tag + var sr = L.DomUtil.create('span', 'sr-only', options.container); + + link.href = '#'; + link.appendChild(sr); + + if (options.title) { + link.title = options.title; + sr.innerHTML = options.title; + } + + if (options.text) { + link.innerHTML = options.text; + sr.innerHTML = options.text; + } + + /* iOS does not use click events */ + var buttonEvent = this._detectIOS() ? 'touchstart' : 'click'; + + L.DomEvent + .on(link, 'click', L.DomEvent.stopPropagation) + .on(link, 'mousedown', L.DomEvent.stopPropagation) + .on(link, 'dblclick', L.DomEvent.stopPropagation) + .on(link, 'touchstart', L.DomEvent.stopPropagation) + .on(link, 'click', L.DomEvent.preventDefault) + .on(link, buttonEvent, options.callback, options.context); + + return link; + }, + + _disposeButton: function (button, callback) { + /* iOS does not use click events */ + var buttonEvent = this._detectIOS() ? 'touchstart' : 'click'; + + L.DomEvent + .off(button, 'click', L.DomEvent.stopPropagation) + .off(button, 'mousedown', L.DomEvent.stopPropagation) + .off(button, 'dblclick', L.DomEvent.stopPropagation) + .off(button, 'touchstart', L.DomEvent.stopPropagation) + .off(button, 'click', L.DomEvent.preventDefault) + .off(button, buttonEvent, callback); + }, + + _handlerActivated: function (e) { + // Disable active mode (if present) + this.disable(); + + // Cache new active feature + this._activeMode = this._modes[e.handler]; + + L.DomUtil.addClass(this._activeMode.button, 'leaflet-draw-toolbar-button-enabled'); + + this._showActionsToolbar(); + + this.fire('enable'); + }, + + _handlerDeactivated: function () { + this._hideActionsToolbar(); + + L.DomUtil.removeClass(this._activeMode.button, 'leaflet-draw-toolbar-button-enabled'); + + this._activeMode = null; + + this.fire('disable'); + }, + + _createActions: function (handler) { + var container = this._actionsContainer, + buttons = this.getActions(handler), + l = buttons.length, + li, di, dl, button; + + // Dispose the actions toolbar (todo: dispose only not used buttons) + for (di = 0, dl = this._actionButtons.length; di < dl; di++) { + this._disposeButton(this._actionButtons[di].button, this._actionButtons[di].callback); + } + this._actionButtons = []; + + // Remove all old buttons + while (container.firstChild) { + container.removeChild(container.firstChild); + } + + for (var i = 0; i < l; i++) { + if ('enabled' in buttons[i] && !buttons[i].enabled) { + continue; + } + + li = L.DomUtil.create('li', '', container); + + button = this._createButton({ + title: buttons[i].title, + text: buttons[i].text, + container: li, + callback: buttons[i].callback, + context: buttons[i].context + }); + + this._actionButtons.push({ + button: button, + callback: buttons[i].callback + }); + } + }, + + _showActionsToolbar: function () { + var buttonIndex = this._activeMode.buttonIndex, + lastButtonIndex = this._lastButtonIndex, + toolbarPosition = this._activeMode.button.offsetTop - 1; + + // Recreate action buttons on every click + this._createActions(this._activeMode.handler); + + // Correctly position the cancel button + this._actionsContainer.style.top = toolbarPosition + 'px'; + + if (buttonIndex === 0) { + L.DomUtil.addClass(this._toolbarContainer, 'leaflet-draw-toolbar-notop'); + L.DomUtil.addClass(this._actionsContainer, 'leaflet-draw-actions-top'); + } + + if (buttonIndex === lastButtonIndex) { + L.DomUtil.addClass(this._toolbarContainer, 'leaflet-draw-toolbar-nobottom'); + L.DomUtil.addClass(this._actionsContainer, 'leaflet-draw-actions-bottom'); + } + + this._actionsContainer.style.display = 'block'; + this._map.fire(L.Draw.Event.TOOLBAROPENED); + }, + + _hideActionsToolbar: function () { + this._actionsContainer.style.display = 'none'; + + L.DomUtil.removeClass(this._toolbarContainer, 'leaflet-draw-toolbar-notop'); + L.DomUtil.removeClass(this._toolbarContainer, 'leaflet-draw-toolbar-nobottom'); + L.DomUtil.removeClass(this._actionsContainer, 'leaflet-draw-actions-top'); + L.DomUtil.removeClass(this._actionsContainer, 'leaflet-draw-actions-bottom'); + this._map.fire(L.Draw.Event.TOOLBARCLOSED); + } +}); + + + +L.Draw = L.Draw || {}; +/** + * @class L.Draw.Tooltip + * @aka Tooltip + * + * The tooltip class — it is used to display the tooltip while drawing + * This will be depreciated + * + * @example + * + * ```js + * var tooltip = L.Draw.Tooltip(); + * ``` + * + */ +L.Draw.Tooltip = L.Class.extend({ + + // @section Methods for modifying draw state + + // @method initialize(map): void + // Tooltip constructor + initialize: function (map) { + this._map = map; + this._popupPane = map._panes.popupPane; + this._visible = false; + + this._container = map.options.drawControlTooltips ? + L.DomUtil.create('div', 'leaflet-draw-tooltip', this._popupPane) : null; + this._singleLineLabel = false; + + this._map.on('mouseout', this._onMouseOut, this); + }, + + // @method dispose(): void + // Remove Tooltip DOM and unbind events + dispose: function () { + this._map.off('mouseout', this._onMouseOut, this); + + if (this._container) { + this._popupPane.removeChild(this._container); + this._container = null; + } + }, + + // @method updateContent(labelText): this + // Changes the tooltip text to string in function call + updateContent: function (labelText) { + if (!this._container) { + return this; + } + labelText.subtext = labelText.subtext || ''; + + // update the vertical position (only if changed) + if (labelText.subtext.length === 0 && !this._singleLineLabel) { + L.DomUtil.addClass(this._container, 'leaflet-draw-tooltip-single'); + this._singleLineLabel = true; + } + else if (labelText.subtext.length > 0 && this._singleLineLabel) { + L.DomUtil.removeClass(this._container, 'leaflet-draw-tooltip-single'); + this._singleLineLabel = false; + } + + this._container.innerHTML = + (labelText.subtext.length > 0 ? + '' + labelText.subtext + '' + '
' : '') + + '' + labelText.text + ''; + + if (!labelText.text && !labelText.subtext) { + this._visible = false; + this._container.style.visibility = 'hidden'; + } else { + this._visible = true; + this._container.style.visibility = 'inherit'; + } + + return this; + }, + + // @method updatePosition(latlng): this + // Changes the location of the tooltip + updatePosition: function (latlng) { + var pos = this._map.latLngToLayerPoint(latlng), + tooltipContainer = this._container; + + if (this._container) { + if (this._visible) { + tooltipContainer.style.visibility = 'inherit'; + } + L.DomUtil.setPosition(tooltipContainer, pos); + } + + return this; + }, + + // @method showAsError(): this + // Applies error class to tooltip + showAsError: function () { + if (this._container) { + L.DomUtil.addClass(this._container, 'leaflet-error-draw-tooltip'); + } + return this; + }, + + // @method removeError(): this + // Removes the error class from the tooltip + removeError: function () { + if (this._container) { + L.DomUtil.removeClass(this._container, 'leaflet-error-draw-tooltip'); + } + return this; + }, + + _onMouseOut: function () { + if (this._container) { + this._container.style.visibility = 'hidden'; + } + } +}); + + + +/** + * @class L.DrawToolbar + * @aka Toolbar + */ +L.DrawToolbar = L.Toolbar.extend({ + + statics: { + TYPE: 'draw' + }, + + options: { + polyline: {}, + polygon: {}, + rectangle: {}, + circle: {}, + marker: {}, + circlemarker: {} + }, + + // @method initialize(): void + 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]); + } + } + } + + this._toolbarClass = 'leaflet-draw-draw'; + L.Toolbar.prototype.initialize.call(this, options); + }, + + // @method getModeHandlers(): object + // Get mode handlers information + getModeHandlers: function (map) { + return [ + { + enabled: this.options.polyline, + handler: new L.Draw.Polyline(map, this.options.polyline), + title: L.drawLocal.draw.toolbar.buttons.polyline + }, + { + enabled: this.options.polygon, + handler: new L.Draw.Polygon(map, this.options.polygon), + title: L.drawLocal.draw.toolbar.buttons.polygon + }, + { + enabled: this.options.rectangle, + handler: new L.Draw.Rectangle(map, this.options.rectangle), + title: L.drawLocal.draw.toolbar.buttons.rectangle + }, + { + enabled: this.options.circle, + handler: new L.Draw.Circle(map, this.options.circle), + title: L.drawLocal.draw.toolbar.buttons.circle + }, + { + enabled: this.options.marker, + handler: new L.Draw.Marker(map, this.options.marker), + title: L.drawLocal.draw.toolbar.buttons.marker + }, + { + enabled: this.options.circlemarker, + handler: new L.Draw.CircleMarker(map, this.options.circlemarker), + title: L.drawLocal.draw.toolbar.buttons.circlemarker + } + ]; + }, + + // @method getActions(): object + // Get action information + getActions: function (handler) { + return [ + { + enabled: handler.completeShape, + title: L.drawLocal.draw.toolbar.finish.title, + text: L.drawLocal.draw.toolbar.finish.text, + callback: handler.completeShape, + context: handler + }, + { + enabled: handler.deleteLastVertex, + title: L.drawLocal.draw.toolbar.undo.title, + text: L.drawLocal.draw.toolbar.undo.text, + callback: handler.deleteLastVertex, + context: handler + }, + { + title: L.drawLocal.draw.toolbar.actions.title, + text: L.drawLocal.draw.toolbar.actions.text, + callback: this.disable, + context: this + } + ]; + }, + + // @method setOptions(): void + // Sets the options to the toolbar + setOptions: function (options) { + L.setOptions(this, options); + + for (var type in this._modes) { + if (this._modes.hasOwnProperty(type) && options.hasOwnProperty(type)) { + this._modes[type].handler.setOptions(options[type]); + } + } + } +}); + + + +/*L.Map.mergeOptions({ + editControl: true + });*/ +/** + * @class L.EditToolbar + * @aka EditToolbar + */ +L.EditToolbar = L.Toolbar.extend({ + statics: { + TYPE: 'edit' + }, + + options: { + edit: { + selectedPathOptions: { + dashArray: '10, 10', + + fill: true, + fillColor: '#fe57a1', + fillOpacity: 0.1, + + // Whether to user the existing layers color + maintainColor: false + } + }, + remove: {}, + poly: null, + featureGroup: null /* REQUIRED! TODO: perhaps if not set then all layers on the map are selectable? */ + }, + + // @method intialize(): void + initialize: function (options) { + // Need to set this manually since null is an acceptable value here + if (options.edit) { + if (typeof options.edit.selectedPathOptions === 'undefined') { + options.edit.selectedPathOptions = this.options.edit.selectedPathOptions; + } + options.edit.selectedPathOptions = L.extend({}, this.options.edit.selectedPathOptions, options.edit.selectedPathOptions); + } + + if (options.remove) { + options.remove = L.extend({}, this.options.remove, options.remove); + } + + if (options.poly) { + options.poly = L.extend({}, this.options.poly, options.poly); + } + + this._toolbarClass = 'leaflet-draw-edit'; + L.Toolbar.prototype.initialize.call(this, options); + + this._selectedFeatureCount = 0; + }, + + // @method getModeHandlers(): object + // Get mode handlers information + getModeHandlers: function (map) { + var featureGroup = this.options.featureGroup; + return [ + { + enabled: this.options.edit, + handler: new L.EditToolbar.Edit(map, { + featureGroup: featureGroup, + selectedPathOptions: this.options.edit.selectedPathOptions, + poly: this.options.poly + }), + title: L.drawLocal.edit.toolbar.buttons.edit + }, + { + enabled: this.options.remove, + handler: new L.EditToolbar.Delete(map, { + featureGroup: featureGroup + }), + title: L.drawLocal.edit.toolbar.buttons.remove + } + ]; + }, + + // @method getActions(): object + // Get actions information + getActions: function (handler) { + var actions = [ + { + title: L.drawLocal.edit.toolbar.actions.save.title, + text: L.drawLocal.edit.toolbar.actions.save.text, + callback: this._save, + context: this + }, + { + title: L.drawLocal.edit.toolbar.actions.cancel.title, + text: L.drawLocal.edit.toolbar.actions.cancel.text, + callback: this.disable, + context: this + } + ]; + + if (handler.removeAllLayers) { + actions.push({ + title: L.drawLocal.edit.toolbar.actions.clearAll.title, + text: L.drawLocal.edit.toolbar.actions.clearAll.text, + callback: this._clearAllLayers, + context: this + }); + } + + return actions; + }, + + // @method addToolbar(map): L.DomUtil + // Adds the toolbar to the map + addToolbar: function (map) { + var container = L.Toolbar.prototype.addToolbar.call(this, map); + + this._checkDisabled(); + + this.options.featureGroup.on('layeradd layerremove', this._checkDisabled, this); + + return container; + }, + + // @method removeToolbar(): void + // Removes the toolbar from the map + removeToolbar: function () { + this.options.featureGroup.off('layeradd layerremove', this._checkDisabled, this); + + L.Toolbar.prototype.removeToolbar.call(this); + }, + + // @method disable(): void + // Disables the toolbar + disable: function () { + if (!this.enabled()) { + return; + } + + this._activeMode.handler.revertLayers(); + + L.Toolbar.prototype.disable.call(this); + }, + + _save: function () { + this._activeMode.handler.save(); + if (this._activeMode) { + this._activeMode.handler.disable(); + } + }, + + _clearAllLayers: function () { + this._activeMode.handler.removeAllLayers(); + if (this._activeMode) { + this._activeMode.handler.disable(); + } + }, + + _checkDisabled: function () { + var featureGroup = this.options.featureGroup, + hasLayers = featureGroup.getLayers().length !== 0, + button; + + if (this.options.edit) { + button = this._modes[L.EditToolbar.Edit.TYPE].button; + + if (hasLayers) { + L.DomUtil.removeClass(button, 'leaflet-disabled'); + } else { + L.DomUtil.addClass(button, 'leaflet-disabled'); + } + + button.setAttribute( + 'title', + hasLayers ? + L.drawLocal.edit.toolbar.buttons.edit + : L.drawLocal.edit.toolbar.buttons.editDisabled + ); + } + + if (this.options.remove) { + button = this._modes[L.EditToolbar.Delete.TYPE].button; + + if (hasLayers) { + L.DomUtil.removeClass(button, 'leaflet-disabled'); + } else { + L.DomUtil.addClass(button, 'leaflet-disabled'); + } + + button.setAttribute( + 'title', + hasLayers ? + L.drawLocal.edit.toolbar.buttons.remove + : L.drawLocal.edit.toolbar.buttons.removeDisabled + ); + } + } +}); + + + +/** + * @class L.EditToolbar.Edit + * @aka EditToolbar.Edit + */ +L.EditToolbar.Edit = L.Handler.extend({ + statics: { + TYPE: 'edit' + }, + + // @method intialize(): void + initialize: function (map, options) { + L.Handler.prototype.initialize.call(this, map); + + L.setOptions(this, options); + + // Store the selectable layer group for ease of access + this._featureGroup = options.featureGroup; + + if (!(this._featureGroup instanceof L.FeatureGroup)) { + throw new Error('options.featureGroup must be a L.FeatureGroup'); + } + + this._uneditedLayerProps = {}; + + // Save the type so super can fire, need to do this as cannot do this.TYPE :( + this.type = L.EditToolbar.Edit.TYPE; + + var version = L.version.split('.'); + //If Version is >= 1.2.0 + if (parseInt(version[0], 10) === 1 && parseInt(version[1], 10) >= 2) { + L.EditToolbar.Edit.include(L.Evented.prototype); + } else { + L.EditToolbar.Edit.include(L.Mixin.Events); + } + }, + + // @method enable(): void + // Enable the edit toolbar + enable: function () { + if (this._enabled || !this._hasAvailableLayers()) { + return; + } + this.fire('enabled', {handler: this.type}); + //this disable other handlers + + this._map.fire(L.Draw.Event.EDITSTART, {handler: this.type}); + //allow drawLayer to be updated before beginning edition. + + L.Handler.prototype.enable.call(this); + this._featureGroup + .on('layeradd', this._enableLayerEdit, this) + .on('layerremove', this._disableLayerEdit, this); + }, + + // @method disable(): void + // Disable the edit toolbar + disable: function () { + if (!this._enabled) { + return; + } + this._featureGroup + .off('layeradd', this._enableLayerEdit, this) + .off('layerremove', this._disableLayerEdit, this); + L.Handler.prototype.disable.call(this); + this._map.fire(L.Draw.Event.EDITSTOP, {handler: this.type}); + this.fire('disabled', {handler: this.type}); + }, + + // @method addHooks(): void + // Add listener hooks for this handler + addHooks: function () { + var map = this._map; + + if (map) { + map.getContainer().focus(); + + this._featureGroup.eachLayer(this._enableLayerEdit, this); + + this._tooltip = new L.Draw.Tooltip(this._map); + this._tooltip.updateContent({ + text: L.drawLocal.edit.handlers.edit.tooltip.text, + subtext: L.drawLocal.edit.handlers.edit.tooltip.subtext + }); + + // Quickly access the tooltip to update for intersection checking + map._editTooltip = this._tooltip; + + this._updateTooltip(); + + this._map + .on('mousemove', this._onMouseMove, this) + .on('touchmove', this._onMouseMove, this) + .on('MSPointerMove', this._onMouseMove, this) + .on(L.Draw.Event.EDITVERTEX, this._updateTooltip, this); + } + }, + + // @method removeHooks(): void + // Remove listener hooks for this handler + removeHooks: function () { + if (this._map) { + // Clean up selected layers. + this._featureGroup.eachLayer(this._disableLayerEdit, this); + this._map._editTooltip.dispose(); + this._map._editTooltip = null; + // Clear the backups of the original layers + this._uneditedLayerProps = {}; + + this._tooltip.dispose(); + this._tooltip = null; + + this._map + .off('mousemove', this._onMouseMove, this) + .off('touchmove', this._onMouseMove, this) + .off('MSPointerMove', this._onMouseMove, this) + .off(L.Draw.Event.EDITVERTEX, this._updateTooltip, this); + } + }, + + // @method revertLayers(): void + // Revert each layer's geometry changes + revertLayers: function () { + this._featureGroup.eachLayer(function (layer) { + this._revertLayer(layer); + }, this); + }, + + // @method save(): void + // Save the layer geometries + save: function () { + var editedLayers = new L.LayerGroup(); + this._featureGroup.eachLayer(function (layer) { + if (layer.edited) { + editedLayers.addLayer(layer); + layer.edited = false; + } + }); + this._map.fire(L.Draw.Event.EDITED, {layers: editedLayers}); + }, + + _backupLayer: function (layer) { + var id = L.Util.stamp(layer); + + if (!this._uneditedLayerProps[id]) { + // Polyline, Polygon or Rectangle + if (layer instanceof L.Polyline || layer instanceof L.Polygon || layer instanceof L.Rectangle) { + this._uneditedLayerProps[id] = { + latlngs: L.LatLngUtil.cloneLatLngs(layer.getLatLngs()) + }; + } else if (layer instanceof L.Circle) { + this._uneditedLayerProps[id] = { + latlng: L.LatLngUtil.cloneLatLng(layer.getLatLng()), + radius: layer.getRadius() + }; + } else if (layer instanceof L.Marker || layer instanceof L.CircleMarker) { // Marker + this._uneditedLayerProps[id] = { + latlng: L.LatLngUtil.cloneLatLng(layer.getLatLng()) + }; + } + } + }, + + _getTooltipText: function () { + return ({ + text: L.drawLocal.edit.handlers.edit.tooltip.text, + subtext: L.drawLocal.edit.handlers.edit.tooltip.subtext + }); + }, + + _updateTooltip: function () { + this._tooltip.updateContent(this._getTooltipText()); + }, + + _revertLayer: function (layer) { + var id = L.Util.stamp(layer); + layer.edited = false; + if (this._uneditedLayerProps.hasOwnProperty(id)) { + // Polyline, Polygon or Rectangle + if (layer instanceof L.Polyline || layer instanceof L.Polygon || layer instanceof L.Rectangle) { + layer.setLatLngs(this._uneditedLayerProps[id].latlngs); + } else if (layer instanceof L.Circle) { + layer.setLatLng(this._uneditedLayerProps[id].latlng); + layer.setRadius(this._uneditedLayerProps[id].radius); + } else if (layer instanceof L.Marker || layer instanceof L.CircleMarker) { // Marker or CircleMarker + layer.setLatLng(this._uneditedLayerProps[id].latlng); + } + + layer.fire('revert-edited', {layer: layer}); + } + }, + + _enableLayerEdit: function (e) { + var layer = e.layer || e.target || e, + pathOptions, poly; + + // Back up this layer (if haven't before) + this._backupLayer(layer); + + if (this.options.poly) { + poly = L.Util.extend({}, this.options.poly); + layer.options.poly = poly; + } + + // Set different style for editing mode + if (this.options.selectedPathOptions) { + pathOptions = L.Util.extend({}, this.options.selectedPathOptions); + + // Use the existing color of the layer + if (pathOptions.maintainColor) { + pathOptions.color = layer.options.color; + pathOptions.fillColor = layer.options.fillColor; + } + + layer.options.original = L.extend({}, layer.options); + layer.options.editing = pathOptions; + + } + + if (layer instanceof L.Marker) { + if (layer.editing) { + layer.editing.enable(); + } + layer.dragging.enable(); + layer + .on('dragend', this._onMarkerDragEnd) + // #TODO: remove when leaflet finally fixes their draggable so it's touch friendly again. + .on('touchmove', this._onTouchMove, this) + .on('MSPointerMove', this._onTouchMove, this) + .on('touchend', this._onMarkerDragEnd, this) + .on('MSPointerUp', this._onMarkerDragEnd, this); + } else { + layer.editing.enable(); + } + }, + + _disableLayerEdit: function (e) { + var layer = e.layer || e.target || e; + + layer.edited = false; + if (layer.editing) { + layer.editing.disable(); + } + + delete layer.options.editing; + delete layer.options.original; + // Reset layer styles to that of before select + if (this._selectedPathOptions) { + if (layer instanceof L.Marker) { + this._toggleMarkerHighlight(layer); + } else { + // reset the layer style to what is was before being selected + layer.setStyle(layer.options.previousOptions); + // remove the cached options for the layer object + delete layer.options.previousOptions; + } + } + + if (layer instanceof L.Marker) { + layer.dragging.disable(); + layer + .off('dragend', this._onMarkerDragEnd, this) + .off('touchmove', this._onTouchMove, this) + .off('MSPointerMove', this._onTouchMove, this) + .off('touchend', this._onMarkerDragEnd, this) + .off('MSPointerUp', this._onMarkerDragEnd, this); + } else { + layer.editing.disable(); + } + }, + + _onMouseMove: function (e) { + this._tooltip.updatePosition(e.latlng); + }, + + _onMarkerDragEnd: function (e) { + var layer = e.target; + layer.edited = true; + this._map.fire(L.Draw.Event.EDITMOVE, {layer: layer}); + }, + + _onTouchMove: function (e) { + var touchEvent = e.originalEvent.changedTouches[0], + layerPoint = this._map.mouseEventToLayerPoint(touchEvent), + latlng = this._map.layerPointToLatLng(layerPoint); + e.target.setLatLng(latlng); + }, + + _hasAvailableLayers: function () { + return this._featureGroup.getLayers().length !== 0; + } +}); + + + +/** + * @class L.EditToolbar.Delete + * @aka EditToolbar.Delete + */ +L.EditToolbar.Delete = L.Handler.extend({ + statics: { + TYPE: 'remove' // not delete as delete is reserved in js + }, + + // @method intialize(): void + initialize: function (map, options) { + L.Handler.prototype.initialize.call(this, map); + + L.Util.setOptions(this, options); + + // Store the selectable layer group for ease of access + this._deletableLayers = this.options.featureGroup; + + if (!(this._deletableLayers instanceof L.FeatureGroup)) { + throw new Error('options.featureGroup must be a L.FeatureGroup'); + } + + // Save the type so super can fire, need to do this as cannot do this.TYPE :( + this.type = L.EditToolbar.Delete.TYPE; + + var version = L.version.split('.'); + //If Version is >= 1.2.0 + if (parseInt(version[0], 10) === 1 && parseInt(version[1], 10) >= 2) { + L.EditToolbar.Delete.include(L.Evented.prototype); + } else { + L.EditToolbar.Delete.include(L.Mixin.Events); + } + + }, + + // @method enable(): void + // Enable the delete toolbar + enable: function () { + if (this._enabled || !this._hasAvailableLayers()) { + return; + } + this.fire('enabled', {handler: this.type}); + + this._map.fire(L.Draw.Event.DELETESTART, {handler: this.type}); + + L.Handler.prototype.enable.call(this); + + this._deletableLayers + .on('layeradd', this._enableLayerDelete, this) + .on('layerremove', this._disableLayerDelete, this); + }, + + // @method disable(): void + // Disable the delete toolbar + disable: function () { + if (!this._enabled) { + return; + } + + this._deletableLayers + .off('layeradd', this._enableLayerDelete, this) + .off('layerremove', this._disableLayerDelete, this); + + L.Handler.prototype.disable.call(this); + + this._map.fire(L.Draw.Event.DELETESTOP, {handler: this.type}); + + this.fire('disabled', {handler: this.type}); + }, + + // @method addHooks(): void + // Add listener hooks to this handler + addHooks: function () { + var map = this._map; + + if (map) { + map.getContainer().focus(); + + this._deletableLayers.eachLayer(this._enableLayerDelete, this); + this._deletedLayers = new L.LayerGroup(); + + this._tooltip = new L.Draw.Tooltip(this._map); + this._tooltip.updateContent({text: L.drawLocal.edit.handlers.remove.tooltip.text}); + + this._map.on('mousemove', this._onMouseMove, this); + } + }, + + // @method removeHooks(): void + // Remove listener hooks from this handler + removeHooks: function () { + if (this._map) { + this._deletableLayers.eachLayer(this._disableLayerDelete, this); + this._deletedLayers = null; + + this._tooltip.dispose(); + this._tooltip = null; + + this._map.off('mousemove', this._onMouseMove, this); + } + }, + + // @method revertLayers(): void + // Revert the deleted layers back to their prior state. + revertLayers: function () { + // Iterate of the deleted layers and add them back into the featureGroup + this._deletedLayers.eachLayer(function (layer) { + this._deletableLayers.addLayer(layer); + layer.fire('revert-deleted', {layer: layer}); + }, this); + }, + + // @method save(): void + // Save deleted layers + save: function () { + this._map.fire(L.Draw.Event.DELETED, {layers: this._deletedLayers}); + }, + + // @method removeAllLayers(): void + // Remove all delateable layers + removeAllLayers: function () { + // Iterate of the delateable layers and add remove them + this._deletableLayers.eachLayer(function (layer) { + this._removeLayer({layer: layer}); + }, this); + this.save(); + }, + + _enableLayerDelete: function (e) { + var layer = e.layer || e.target || e; + + layer.on('click', this._removeLayer, this); + }, + + _disableLayerDelete: function (e) { + var layer = e.layer || e.target || e; + + layer.off('click', this._removeLayer, this); + + // Remove from the deleted layers so we can't accidentally revert if the user presses cancel + this._deletedLayers.removeLayer(layer); + }, + + _removeLayer: function (e) { + var layer = e.layer || e.target || e; + + this._deletableLayers.removeLayer(layer); + + this._deletedLayers.addLayer(layer); + + layer.fire('deleted'); + }, + + _onMouseMove: function (e) { + this._tooltip.updatePosition(e.latlng); + }, + + _hasAvailableLayers: function () { + return this._deletableLayers.getLayers().length !== 0; + } +}); + + + +}(window, document)); +//# sourceMappingURL=leaflet.draw-src.map \ No newline at end of file diff --git a/dist/leaflet.draw-src.map b/dist/leaflet.draw-src.map new file mode 100644 index 000000000..81a68cc98 --- /dev/null +++ b/dist/leaflet.draw-src.map @@ -0,0 +1 @@ +{"version":3,"sources":["src/Leaflet.draw.js","src/Leaflet.Draw.Event.js","src/draw/handler/Draw.Feature.js","src/draw/handler/Draw.Polyline.js","src/draw/handler/Draw.Polygon.js","src/draw/handler/Draw.SimpleShape.js","src/draw/handler/Draw.Rectangle.js","src/draw/handler/Draw.Marker.js","src/draw/handler/Draw.CircleMarker.js","src/draw/handler/Draw.Circle.js","src/edit/handler/Edit.Marker.js","src/edit/handler/Edit.Poly.js","src/edit/handler/Edit.SimpleShape.js","src/edit/handler/Edit.Rectangle.js","src/edit/handler/Edit.CircleMarker.js","src/edit/handler/Edit.Circle.js","src/ext/TouchEvents.js","src/ext/LatLngUtil.js","src/ext/GeometryUtil.js","src/ext/LineUtil.Intersect.js","src/ext/Polyline.Intersect.js","src/ext/Polygon.Intersect.js","src/Control.Draw.js","src/Toolbar.js","src/Tooltip.js","src/draw/DrawToolbar.js","src/edit/EditToolbar.js","src/edit/handler/EditToolbar.Edit.js","src/edit/handler/EditToolbar.Delete.js"],"names":[],"mappings":";;;;;;;yCAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC7LA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AChLA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACxGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AChlBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACjIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACvHA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AClGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC/HA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC1CA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACnFA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACpFA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACxgBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACrOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC7HA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACrDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC1DA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AChRA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC5BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACrKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACtBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC1GA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACjCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACtHA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC9UA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACtHA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC9GA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AClMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACnSA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","sourcesContent":["/**\r\n * Leaflet.draw assumes that you have already included the Leaflet library.\r\n */\r\nL.drawVersion = \"1.0.3+e90ec6d\";\r\n/**\r\n * @class L.Draw\r\n * @aka Draw\r\n *\r\n *\r\n * To add the draw toolbar set the option drawControl: true in the map options.\r\n *\r\n * @example\r\n * ```js\r\n * var map = L.map('map', {drawControl: true}).setView([51.505, -0.09], 13);\r\n *\r\n * L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {\r\n * attribution: '© OpenStreetMap contributors'\r\n * }).addTo(map);\r\n * ```\r\n *\r\n * ### Adding the edit toolbar\r\n * To use the edit toolbar you must initialise the Leaflet.draw control and manually add it to the map.\r\n *\r\n * ```js\r\n * var map = L.map('map').setView([51.505, -0.09], 13);\r\n *\r\n * L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {\r\n * attribution: '© OpenStreetMap contributors'\r\n * }).addTo(map);\r\n *\r\n * // FeatureGroup is to store editable layers\r\n * var drawnItems = new L.FeatureGroup();\r\n * map.addLayer(drawnItems);\r\n *\r\n * var drawControl = new L.Control.Draw({\r\n * edit: {\r\n * featureGroup: drawnItems\r\n * }\r\n * });\r\n * map.addControl(drawControl);\r\n * ```\r\n *\r\n * The key here is the featureGroup option. This tells the plugin which FeatureGroup contains the layers that\r\n * should be editable. The featureGroup can contain 0 or more features with geometry types Point, LineString, and Polygon.\r\n * Leaflet.draw does not work with multigeometry features such as MultiPoint, MultiLineString, MultiPolygon,\r\n * or GeometryCollection. If you need to add multigeometry features to the draw plugin, convert them to a\r\n * FeatureCollection of non-multigeometries (Points, LineStrings, or Polygons).\r\n */\r\nL.Draw = {};\r\n\r\n/**\r\n * @class L.drawLocal\r\n * @aka L.drawLocal\r\n *\r\n * The core toolbar class of the API — it is used to create the toolbar ui\r\n *\r\n * @example\r\n * ```js\r\n * var modifiedDraw = L.drawLocal.extend({\r\n * draw: {\r\n * toolbar: {\r\n * buttons: {\r\n * polygon: 'Draw an awesome polygon'\r\n * }\r\n * }\r\n * }\r\n * });\r\n * ```\r\n *\r\n * The default state for the control is the draw toolbar just below the zoom control.\r\n * This will allow map users to draw vectors and markers.\r\n * **Please note the edit toolbar is not enabled by default.**\r\n */\r\nL.drawLocal = {\r\n\t// format: {\r\n\t// \tnumeric: {\r\n\t// \t\tdelimiters: {\r\n\t// \t\t\tthousands: ',',\r\n\t// \t\t\tdecimal: '.'\r\n\t// \t\t}\r\n\t// \t}\r\n\t// },\r\n\tdraw: {\r\n\t\ttoolbar: {\r\n\t\t\t// #TODO: this should be reorganized where actions are nested in actions\r\n\t\t\t// ex: actions.undo or actions.cancel\r\n\t\t\tactions: {\r\n\t\t\t\ttitle: 'Cancel drawing',\r\n\t\t\t\ttext: 'Cancel'\r\n\t\t\t},\r\n\t\t\tfinish: {\r\n\t\t\t\ttitle: 'Finish drawing',\r\n\t\t\t\ttext: 'Finish'\r\n\t\t\t},\r\n\t\t\tundo: {\r\n\t\t\t\ttitle: 'Delete last point drawn',\r\n\t\t\t\ttext: 'Delete last point'\r\n\t\t\t},\r\n\t\t\tbuttons: {\r\n\t\t\t\tpolyline: 'Draw a polyline',\r\n\t\t\t\tpolygon: 'Draw a polygon',\r\n\t\t\t\trectangle: 'Draw a rectangle',\r\n\t\t\t\tcircle: 'Draw a circle',\r\n\t\t\t\tmarker: 'Draw a marker',\r\n\t\t\t\tcirclemarker: 'Draw a circlemarker'\r\n\t\t\t}\r\n\t\t},\r\n\t\thandlers: {\r\n\t\t\tcircle: {\r\n\t\t\t\ttooltip: {\r\n\t\t\t\t\tstart: 'Click and drag to draw circle.'\r\n\t\t\t\t},\r\n\t\t\t\tradius: 'Radius'\r\n\t\t\t},\r\n\t\t\tcirclemarker: {\r\n\t\t\t\ttooltip: {\r\n\t\t\t\t\tstart: 'Click map to place circle marker.'\r\n\t\t\t\t}\r\n\t\t\t},\r\n\t\t\tmarker: {\r\n\t\t\t\ttooltip: {\r\n\t\t\t\t\tstart: 'Click map to place marker.'\r\n\t\t\t\t}\r\n\t\t\t},\r\n\t\t\tpolygon: {\r\n\t\t\t\ttooltip: {\r\n\t\t\t\t\tstart: 'Click to start drawing shape.',\r\n\t\t\t\t\tcont: 'Click to continue drawing shape.',\r\n\t\t\t\t\tend: 'Click first point to close this shape.'\r\n\t\t\t\t}\r\n\t\t\t},\r\n\t\t\tpolyline: {\r\n\t\t\t\terror: 'Error: shape edges cannot cross!',\r\n\t\t\t\ttooltip: {\r\n\t\t\t\t\tstart: 'Click to start drawing line.',\r\n\t\t\t\t\tcont: 'Click to continue drawing line.',\r\n\t\t\t\t\tend: 'Click last point to finish line.'\r\n\t\t\t\t}\r\n\t\t\t},\r\n\t\t\trectangle: {\r\n\t\t\t\ttooltip: {\r\n\t\t\t\t\tstart: 'Click and drag to draw rectangle.'\r\n\t\t\t\t}\r\n\t\t\t},\r\n\t\t\tsimpleshape: {\r\n\t\t\t\ttooltip: {\r\n\t\t\t\t\tend: 'Release mouse to finish drawing.'\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t},\r\n\tedit: {\r\n\t\ttoolbar: {\r\n\t\t\tactions: {\r\n\t\t\t\tsave: {\r\n\t\t\t\t\ttitle: 'Save changes',\r\n\t\t\t\t\ttext: 'Save'\r\n\t\t\t\t},\r\n\t\t\t\tcancel: {\r\n\t\t\t\t\ttitle: 'Cancel editing, discards all changes',\r\n\t\t\t\t\ttext: 'Cancel'\r\n\t\t\t\t},\r\n\t\t\t\tclearAll: {\r\n\t\t\t\t\ttitle: 'Clear all layers',\r\n\t\t\t\t\ttext: 'Clear All'\r\n\t\t\t\t}\r\n\t\t\t},\r\n\t\t\tbuttons: {\r\n\t\t\t\tedit: 'Edit layers',\r\n\t\t\t\teditDisabled: 'No layers to edit',\r\n\t\t\t\tremove: 'Delete layers',\r\n\t\t\t\tremoveDisabled: 'No layers to delete'\r\n\t\t\t}\r\n\t\t},\r\n\t\thandlers: {\r\n\t\t\tedit: {\r\n\t\t\t\ttooltip: {\r\n\t\t\t\t\ttext: 'Drag handles or markers to edit features.',\r\n\t\t\t\t\tsubtext: 'Click cancel to undo changes.'\r\n\t\t\t\t}\r\n\t\t\t},\r\n\t\t\tremove: {\r\n\t\t\t\ttooltip: {\r\n\t\t\t\t\ttext: 'Click on a feature to remove.'\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n};\r\n","/**\r\n * ### Events\r\n * Once you have successfully added the Leaflet.draw plugin to your map you will want to respond to the different\r\n * actions users can initiate. The following events will be triggered on the map:\r\n *\r\n * @class L.Draw.Event\r\n * @aka Draw.Event\r\n *\r\n * Use `L.Draw.Event.EVENTNAME` constants to ensure events are correct.\r\n *\r\n * @example\r\n * ```js\r\n * map.on(L.Draw.Event.CREATED; function (e) {\r\n * var type = e.layerType,\r\n * layer = e.layer;\r\n *\r\n * if (type === 'marker') {\r\n * // Do marker specific actions\r\n * }\r\n *\r\n * // Do whatever else you need to. (save to db; add to map etc)\r\n * map.addLayer(layer);\r\n *});\r\n * ```\r\n */\r\nL.Draw.Event = {};\r\n/**\r\n * @event draw:created: PolyLine; Polygon; Rectangle; Circle; Marker | String\r\n *\r\n * Layer that was just created.\r\n * The type of layer this is. One of: `polyline`; `polygon`; `rectangle`; `circle`; `marker`\r\n * Triggered when a new vector or marker has been created.\r\n *\r\n */\r\nL.Draw.Event.CREATED = 'draw:created';\r\n\r\n/**\r\n * @event draw:edited: LayerGroup\r\n *\r\n * List of all layers just edited on the map.\r\n *\r\n *\r\n * Triggered when layers in the FeatureGroup; initialised with the plugin; have been edited and saved.\r\n *\r\n * @example\r\n * ```js\r\n * map.on('draw:edited', function (e) {\r\n * var layers = e.layers;\r\n * layers.eachLayer(function (layer) {\r\n * //do whatever you want; most likely save back to db\r\n * });\r\n * });\r\n * ```\r\n */\r\nL.Draw.Event.EDITED = 'draw:edited';\r\n\r\n/**\r\n * @event draw:deleted: LayerGroup\r\n *\r\n * List of all layers just removed from the map.\r\n *\r\n * Triggered when layers have been removed (and saved) from the FeatureGroup.\r\n */\r\nL.Draw.Event.DELETED = 'draw:deleted';\r\n\r\n/**\r\n * @event draw:drawstart: String\r\n *\r\n * The type of layer this is. One of:`polyline`; `polygon`; `rectangle`; `circle`; `marker`\r\n *\r\n * Triggered when the user has chosen to draw a particular vector or marker.\r\n */\r\nL.Draw.Event.DRAWSTART = 'draw:drawstart';\r\n\r\n/**\r\n * @event draw:drawstop: String\r\n *\r\n * The type of layer this is. One of: `polyline`; `polygon`; `rectangle`; `circle`; `marker`\r\n *\r\n * Triggered when the user has finished a particular vector or marker.\r\n */\r\n\r\nL.Draw.Event.DRAWSTOP = 'draw:drawstop';\r\n\r\n/**\r\n * @event draw:drawvertex: LayerGroup\r\n *\r\n * List of all layers just being added from the map.\r\n *\r\n * Triggered when a vertex is created on a polyline or polygon.\r\n */\r\nL.Draw.Event.DRAWVERTEX = 'draw:drawvertex';\r\n\r\n/**\r\n * @event draw:editstart: String\r\n *\r\n * The type of edit this is. One of: `edit`\r\n *\r\n * Triggered when the user starts edit mode by clicking the edit tool button.\r\n */\r\n\r\nL.Draw.Event.EDITSTART = 'draw:editstart';\r\n\r\n/**\r\n * @event draw:editmove: ILayer\r\n *\r\n * Layer that was just moved.\r\n *\r\n * Triggered as the user moves a rectangle; circle or marker.\r\n */\r\nL.Draw.Event.EDITMOVE = 'draw:editmove';\r\n\r\n/**\r\n * @event draw:editresize: ILayer\r\n *\r\n * Layer that was just moved.\r\n *\r\n * Triggered as the user resizes a rectangle or circle.\r\n */\r\nL.Draw.Event.EDITRESIZE = 'draw:editresize';\r\n\r\n/**\r\n * @event draw:editvertex: LayerGroup\r\n *\r\n * List of all layers just being edited from the map.\r\n *\r\n * Triggered when a vertex is edited on a polyline or polygon.\r\n */\r\nL.Draw.Event.EDITVERTEX = 'draw:editvertex';\r\n\r\n/**\r\n * @event draw:editstop: String\r\n *\r\n * The type of edit this is. One of: `edit`\r\n *\r\n * Triggered when the user has finshed editing (edit mode) and saves edits.\r\n */\r\nL.Draw.Event.EDITSTOP = 'draw:editstop';\r\n\r\n/**\r\n * @event draw:deletestart: String\r\n *\r\n * The type of edit this is. One of: `remove`\r\n *\r\n * Triggered when the user starts remove mode by clicking the remove tool button.\r\n */\r\nL.Draw.Event.DELETESTART = 'draw:deletestart';\r\n\r\n/**\r\n * @event draw:deletestop: String\r\n *\r\n * The type of edit this is. One of: `remove`\r\n *\r\n * Triggered when the user has finished removing shapes (remove mode) and saves.\r\n */\r\nL.Draw.Event.DELETESTOP = 'draw:deletestop';\r\n\r\n/**\r\n * @event draw:toolbaropened: String\r\n *\r\n * Triggered when a toolbar is opened.\r\n */\r\nL.Draw.Event.TOOLBAROPENED = 'draw:toolbaropened';\r\n\r\n/**\r\n * @event draw:toolbarclosed: String\r\n *\r\n * Triggered when a toolbar is closed.\r\n */\r\nL.Draw.Event.TOOLBARCLOSED = 'draw:toolbarclosed';\r\n\r\n/**\r\n * @event draw:markercontext: String\r\n *\r\n * Triggered when a marker is right clicked.\r\n */\r\nL.Draw.Event.MARKERCONTEXT = 'draw:markercontext';","L.Draw = L.Draw || {};\r\n\r\n/**\r\n * @class L.Draw.Feature\r\n * @aka Draw.Feature\r\n */\r\nL.Draw.Feature = L.Handler.extend({\r\n\r\n\t// @method initialize(): void\r\n\tinitialize: function (map, options) {\r\n\t\tthis._map = map;\r\n\t\tthis._container = map._container;\r\n\t\tthis._overlayPane = map._panes.overlayPane;\r\n\t\tthis._popupPane = map._panes.popupPane;\r\n\r\n\t\t// Merge default shapeOptions options with custom shapeOptions\r\n\t\tif (options && options.shapeOptions) {\r\n\t\t\toptions.shapeOptions = L.Util.extend({}, this.options.shapeOptions, options.shapeOptions);\r\n\t\t}\r\n\t\tL.setOptions(this, options);\r\n\r\n\t\tvar version = L.version.split('.');\r\n\t\t//If Version is >= 1.2.0\r\n\t\tif (parseInt(version[0], 10) === 1 && parseInt(version[1], 10) >= 2) {\r\n\t\t\tL.Draw.Feature.include(L.Evented.prototype);\r\n\t\t} else {\r\n\t\t\tL.Draw.Feature.include(L.Mixin.Events);\r\n\t\t}\r\n\t},\r\n\r\n\t// @method enable(): void\r\n\t// Enables this handler\r\n\tenable: function () {\r\n\t\tif (this._enabled) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tL.Handler.prototype.enable.call(this);\r\n\r\n\t\tthis.fire('enabled', {handler: this.type});\r\n\r\n\t\tthis._map.fire(L.Draw.Event.DRAWSTART, {layerType: this.type});\r\n\t},\r\n\r\n\t// @method disable(): void\r\n\tdisable: function () {\r\n\t\tif (!this._enabled) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tL.Handler.prototype.disable.call(this);\r\n\r\n\t\tthis._map.fire(L.Draw.Event.DRAWSTOP, {layerType: this.type});\r\n\r\n\t\tthis.fire('disabled', {handler: this.type});\r\n\t},\r\n\r\n\t// @method addHooks(): void\r\n\t// Add's event listeners to this handler\r\n\taddHooks: function () {\r\n\t\tvar map = this._map;\r\n\r\n\t\tif (map) {\r\n\t\t\tL.DomUtil.disableTextSelection();\r\n\r\n\t\t\tmap.getContainer().focus();\r\n\r\n\t\t\tthis._tooltip = new L.Draw.Tooltip(this._map);\r\n\r\n\t\t\tL.DomEvent.on(this._container, 'keyup', this._cancelDrawing, this);\r\n\t\t}\r\n\t},\r\n\r\n\t// @method removeHooks(): void\r\n\t// Removes event listeners from this handler\r\n\tremoveHooks: function () {\r\n\t\tif (this._map) {\r\n\t\t\tL.DomUtil.enableTextSelection();\r\n\r\n\t\t\tthis._tooltip.dispose();\r\n\t\t\tthis._tooltip = null;\r\n\r\n\t\t\tL.DomEvent.off(this._container, 'keyup', this._cancelDrawing, this);\r\n\t\t}\r\n\t},\r\n\r\n\t// @method setOptions(object): void\r\n\t// Sets new options to this handler\r\n\tsetOptions: function (options) {\r\n\t\tL.setOptions(this, options);\r\n\t},\r\n\r\n\t_fireCreatedEvent: function (layer) {\r\n\t\tthis._map.fire(L.Draw.Event.CREATED, {layer: layer, layerType: this.type});\r\n\t},\r\n\r\n\t// Cancel drawing when the escape key is pressed\r\n\t_cancelDrawing: function (e) {\r\n\t\tif (e.keyCode === 27) {\r\n\t\t\tthis._map.fire('draw:canceled', {layerType: this.type});\r\n\t\t\tthis.disable();\r\n\t\t}\r\n\t}\r\n});\r\n","/**\r\n * @class L.Draw.Polyline\r\n * @aka Draw.Polyline\r\n * @inherits L.Draw.Feature\r\n */\r\nL.Draw.Polyline = L.Draw.Feature.extend({\r\n\tstatics: {\r\n\t\tTYPE: 'polyline'\r\n\t},\r\n\r\n\tPoly: L.Polyline,\r\n\r\n\toptions: {\r\n\t\tallowIntersection: true,\r\n\t\trepeatMode: false,\r\n\t\tdrawError: {\r\n\t\t\tcolor: '#b00b00',\r\n\t\t\ttimeout: 2500\r\n\t\t},\r\n\t\ticon: new L.DivIcon({\r\n\t\t\ticonSize: new L.Point(8, 8),\r\n\t\t\tclassName: 'leaflet-div-icon leaflet-editing-icon'\r\n\t\t}),\r\n\t\ttouchIcon: new L.DivIcon({\r\n\t\t\ticonSize: new L.Point(20, 20),\r\n\t\t\tclassName: 'leaflet-div-icon leaflet-editing-icon leaflet-touch-icon'\r\n\t\t}),\r\n\t\tguidelineDistance: 20,\r\n\t\tmaxGuideLineLength: 4000,\r\n\t\tshapeOptions: {\r\n\t\t\tstroke: true,\r\n\t\t\tcolor: '#3388ff',\r\n\t\t\tweight: 4,\r\n\t\t\topacity: 0.5,\r\n\t\t\tfill: false,\r\n\t\t\tclickable: true\r\n\t\t},\r\n\t\tmetric: true, // Whether to use the metric measurement system or imperial\r\n\t\tfeet: true, // When not metric, to use feet instead of yards for display.\r\n\t\tnautic: false, // When not metric, not feet use nautic mile for display\r\n\t\tshowLength: true, // Whether to display distance in the tooltip\r\n\t\tzIndexOffset: 2000, // This should be > than the highest z-index any map layers\r\n\t\tfactor: 1, // To change distance calculation\r\n\t\tmaxPoints: 0 // Once this number of points are placed, finish shape\r\n\t},\r\n\r\n\t// @method initialize(): void\r\n\tinitialize: function (map, options) {\r\n\t\t// if touch, switch to touch icon\r\n\t\tif (L.Browser.touch) {\r\n\t\t\tthis.options.icon = this.options.touchIcon;\r\n\t\t}\r\n\r\n\t\t// Need to set this here to ensure the correct message is used.\r\n\t\tthis.options.drawError.message = L.drawLocal.draw.handlers.polyline.error;\r\n\r\n\t\t// Merge default drawError options with custom options\r\n\t\tif (options && options.drawError) {\r\n\t\t\toptions.drawError = L.Util.extend({}, this.options.drawError, options.drawError);\r\n\t\t}\r\n\r\n\t\t// Save the type so super can fire, need to do this as cannot do this.TYPE :(\r\n\t\tthis.type = L.Draw.Polyline.TYPE;\r\n\r\n\t\tL.Draw.Feature.prototype.initialize.call(this, map, options);\r\n\t},\r\n\r\n\t// @method addHooks(): void\r\n\t// Add listener hooks to this handler\r\n\taddHooks: function () {\r\n\t\tL.Draw.Feature.prototype.addHooks.call(this);\r\n\t\tif (this._map) {\r\n\t\t\tthis._markers = [];\r\n\r\n\t\t\tthis._markerGroup = new L.LayerGroup();\r\n\t\t\tthis._map.addLayer(this._markerGroup);\r\n\r\n\t\t\tthis._poly = new L.Polyline([], this.options.shapeOptions);\r\n\r\n\t\t\tthis._tooltip.updateContent(this._getTooltipText());\r\n\r\n\t\t\t// Make a transparent marker that will used to catch click events. These click\r\n\t\t\t// events will create the vertices. We need to do this so we can ensure that\r\n\t\t\t// we can create vertices over other map layers (markers, vector layers). We\r\n\t\t\t// also do not want to trigger any click handlers of objects we are clicking on\r\n\t\t\t// while drawing.\r\n\t\t\tif (!this._mouseMarker) {\r\n\t\t\t\tthis._mouseMarker = L.marker(this._map.getCenter(), {\r\n\t\t\t\t\ticon: L.divIcon({\r\n\t\t\t\t\t\tclassName: 'leaflet-mouse-marker',\r\n\t\t\t\t\t\ticonAnchor: [20, 20],\r\n\t\t\t\t\t\ticonSize: [40, 40]\r\n\t\t\t\t\t}),\r\n\t\t\t\t\topacity: 0,\r\n\t\t\t\t\tzIndexOffset: this.options.zIndexOffset\r\n\t\t\t\t});\r\n\t\t\t}\r\n\r\n\t\t\tthis._mouseMarker\r\n\t\t\t\t.on('mouseout', this._onMouseOut, this)\r\n\t\t\t\t.on('mousemove', this._onMouseMove, this) // Necessary to prevent 0.8 stutter\r\n\t\t\t\t.on('mousedown', this._onMouseDown, this)\r\n\t\t\t\t.on('mouseup', this._onMouseUp, this) // Necessary for 0.8 compatibility\r\n\t\t\t\t.addTo(this._map);\r\n\r\n\t\t\tthis._map\r\n\t\t\t\t.on('mouseup', this._onMouseUp, this) // Necessary for 0.7 compatibility\r\n\t\t\t\t.on('mousemove', this._onMouseMove, this)\r\n\t\t\t\t.on('zoomlevelschange', this._onZoomEnd, this)\r\n\t\t\t\t.on('touchstart', this._onTouch, this)\r\n\t\t\t\t.on('zoomend', this._onZoomEnd, this);\r\n\r\n\t\t}\r\n\t},\r\n\r\n\t// @method removeHooks(): void\r\n\t// Remove listener hooks from this handler.\r\n\tremoveHooks: function () {\r\n\t\tL.Draw.Feature.prototype.removeHooks.call(this);\r\n\r\n\t\tthis._clearHideErrorTimeout();\r\n\r\n\t\tthis._cleanUpShape();\r\n\r\n\t\t// remove markers from map\r\n\t\tthis._map.removeLayer(this._markerGroup);\r\n\t\tdelete this._markerGroup;\r\n\t\tdelete this._markers;\r\n\r\n\t\tthis._map.removeLayer(this._poly);\r\n\t\tdelete this._poly;\r\n\r\n\t\tthis._mouseMarker\r\n\t\t\t.off('mousedown', this._onMouseDown, this)\r\n\t\t\t.off('mouseout', this._onMouseOut, this)\r\n\t\t\t.off('mouseup', this._onMouseUp, this)\r\n\t\t\t.off('mousemove', this._onMouseMove, this);\r\n\t\tthis._map.removeLayer(this._mouseMarker);\r\n\t\tdelete this._mouseMarker;\r\n\r\n\t\t// clean up DOM\r\n\t\tthis._clearGuides();\r\n\r\n\t\tthis._map\r\n\t\t\t.off('mouseup', this._onMouseUp, this)\r\n\t\t\t.off('mousemove', this._onMouseMove, this)\r\n\t\t\t.off('zoomlevelschange', this._onZoomEnd, this)\r\n\t\t\t.off('zoomend', this._onZoomEnd, this)\r\n\t\t\t.off('touchstart', this._onTouch, this)\r\n\t\t\t.off('click', this._onTouch, this);\r\n\t},\r\n\r\n\t// @method deleteLastVertex(): void\r\n\t// Remove the last vertex from the polyline, removes polyline from map if only one point exists.\r\n\tdeleteLastVertex: function () {\r\n\t\tif (this._markers.length <= 1) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tvar lastMarker = this._markers.pop(),\r\n\t\t\tpoly = this._poly,\r\n\t\t\t// Replaces .spliceLatLngs()\r\n\t\t\tlatlngs = poly.getLatLngs(),\r\n\t\t\tlatlng = latlngs.splice(-1, 1)[0];\r\n\t\tthis._poly.setLatLngs(latlngs);\r\n\r\n\t\tthis._markerGroup.removeLayer(lastMarker);\r\n\r\n\t\tif (poly.getLatLngs().length < 2) {\r\n\t\t\tthis._map.removeLayer(poly);\r\n\t\t}\r\n\r\n\t\tthis._vertexChanged(latlng, false);\r\n\t},\r\n\r\n\t// @method addVertex(): void\r\n\t// Add a vertex to the end of the polyline\r\n\taddVertex: function (latlng) {\r\n\t\tvar markersLength = this._markers.length;\r\n\t\t// markersLength must be greater than or equal to 2 before intersections can occur\r\n\t\tif (markersLength >= 2 && !this.options.allowIntersection && this._poly.newLatLngIntersects(latlng)) {\r\n\t\t\tthis._showErrorTooltip();\r\n\t\t\treturn;\r\n\t\t}\r\n\t\telse if (this._errorShown) {\r\n\t\t\tthis._hideErrorTooltip();\r\n\t\t}\r\n\r\n\t\tthis._markers.push(this._createMarker(latlng));\r\n\r\n\t\tthis._poly.addLatLng(latlng);\r\n\r\n\t\tif (this._poly.getLatLngs().length === 2) {\r\n\t\t\tthis._map.addLayer(this._poly);\r\n\t\t}\r\n\r\n\t\tthis._vertexChanged(latlng, true);\r\n\t},\r\n\r\n\t// @method completeShape(): void\r\n\t// Closes the polyline between the first and last points\r\n\tcompleteShape: function () {\r\n\t\tif (this._markers.length <= 1 || !this._shapeIsValid()) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tthis._fireCreatedEvent();\r\n\t\tthis.disable();\r\n\r\n\t\tif (this.options.repeatMode) {\r\n\t\t\tthis.enable();\r\n\t\t}\r\n\t},\r\n\r\n\t_finishShape: function () {\r\n\t\tvar latlngs = this._poly._defaultShape ? this._poly._defaultShape() : this._poly.getLatLngs();\r\n\t\tvar intersects = this._poly.newLatLngIntersects(latlngs[latlngs.length - 1]);\r\n\r\n\t\tif ((!this.options.allowIntersection && intersects) || !this._shapeIsValid()) {\r\n\t\t\tthis._showErrorTooltip();\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tthis._fireCreatedEvent();\r\n\t\tthis.disable();\r\n\t\tif (this.options.repeatMode) {\r\n\t\t\tthis.enable();\r\n\t\t}\r\n\t},\r\n\r\n\t// Called to verify the shape is valid when the user tries to finish it\r\n\t// Return false if the shape is not valid\r\n\t_shapeIsValid: function () {\r\n\t\treturn true;\r\n\t},\r\n\r\n\t_onZoomEnd: function () {\r\n\t\tif (this._markers !== null) {\r\n\t\t\tthis._updateGuide();\r\n\t\t}\r\n\t},\r\n\r\n\t_onMouseMove: function (e) {\r\n\t\tvar newPos = this._map.mouseEventToLayerPoint(e.originalEvent);\r\n\t\tvar latlng = this._map.layerPointToLatLng(newPos);\r\n\r\n\t\t// Save latlng\r\n\t\t// should this be moved to _updateGuide() ?\r\n\t\tthis._currentLatLng = latlng;\r\n\r\n\t\tthis._updateTooltip(latlng);\r\n\r\n\t\t// Update the guide line\r\n\t\tthis._updateGuide(newPos);\r\n\r\n\t\t// Update the mouse marker position\r\n\t\tthis._mouseMarker.setLatLng(latlng);\r\n\r\n\t\tL.DomEvent.preventDefault(e.originalEvent);\r\n\t},\r\n\r\n\t_vertexChanged: function (latlng, added) {\r\n\t\tthis._map.fire(L.Draw.Event.DRAWVERTEX, {layers: this._markerGroup});\r\n\t\tthis._updateFinishHandler();\r\n\r\n\t\tthis._updateRunningMeasure(latlng, added);\r\n\r\n\t\tthis._clearGuides();\r\n\r\n\t\tthis._updateTooltip();\r\n\t},\r\n\r\n\t_onMouseDown: function (e) {\r\n\t\tif (!this._clickHandled && !this._touchHandled && !this._disableMarkers) {\r\n\t\t\tthis._onMouseMove(e);\r\n\t\t\tthis._clickHandled = true;\r\n\t\t\tthis._disableNewMarkers();\r\n\t\t\tvar originalEvent = e.originalEvent;\r\n\t\t\tvar clientX = originalEvent.clientX;\r\n\t\t\tvar clientY = originalEvent.clientY;\r\n\t\t\tthis._startPoint.call(this, clientX, clientY);\r\n\t\t}\r\n\t},\r\n\r\n\t_startPoint: function (clientX, clientY) {\r\n\t\tthis._mouseDownOrigin = L.point(clientX, clientY);\r\n\t},\r\n\r\n\t_onMouseUp: function (e) {\r\n\t\tvar originalEvent = e.originalEvent;\r\n\t\tvar clientX = originalEvent.clientX;\r\n\t\tvar clientY = originalEvent.clientY;\r\n\t\tthis._endPoint.call(this, clientX, clientY, e);\r\n\t\tthis._clickHandled = null;\r\n\t},\r\n\r\n\t_endPoint: function (clientX, clientY, e) {\r\n\t\tif (this._mouseDownOrigin) {\r\n\t\t\tvar dragCheckDistance = L.point(clientX, clientY)\r\n\t\t\t\t.distanceTo(this._mouseDownOrigin);\r\n\t\t\tvar lastPtDistance = this._calculateFinishDistance(e.latlng);\r\n\t\t\tif (this.options.maxPoints > 1 && this.options.maxPoints == this._markers.length + 1) {\r\n\t\t\t\tthis.addVertex(e.latlng);\r\n\t\t\t\tthis._finishShape();\r\n\t\t\t} else if (lastPtDistance < 10 && L.Browser.touch) {\r\n\t\t\t\tthis._finishShape();\r\n\t\t\t} else if (Math.abs(dragCheckDistance) < 9 * (window.devicePixelRatio || 1)) {\r\n\t\t\t\tthis.addVertex(e.latlng);\r\n\t\t\t}\r\n\t\t\tthis._enableNewMarkers(); // after a short pause, enable new markers\r\n\t\t}\r\n\t\tthis._mouseDownOrigin = null;\r\n\t},\r\n\r\n\t// ontouch prevented by clickHandled flag because some browsers fire both click/touch events,\r\n\t// causing unwanted behavior\r\n\t_onTouch: function (e) {\r\n\t\tvar originalEvent = e.originalEvent;\r\n\t\tvar clientX;\r\n\t\tvar clientY;\r\n\t\tif (originalEvent.touches && originalEvent.touches[0] && !this._clickHandled && !this._touchHandled && !this._disableMarkers) {\r\n\t\t\tclientX = originalEvent.touches[0].clientX;\r\n\t\t\tclientY = originalEvent.touches[0].clientY;\r\n\t\t\tthis._disableNewMarkers();\r\n\t\t\tthis._touchHandled = true;\r\n\t\t\tthis._startPoint.call(this, clientX, clientY);\r\n\t\t\tthis._endPoint.call(this, clientX, clientY, e);\r\n\t\t\tthis._touchHandled = null;\r\n\t\t}\r\n\t\tthis._clickHandled = null;\r\n\t},\r\n\r\n\t_onMouseOut: function () {\r\n\t\tif (this._tooltip) {\r\n\t\t\tthis._tooltip._onMouseOut.call(this._tooltip);\r\n\t\t}\r\n\t},\r\n\r\n\t// calculate if we are currently within close enough distance\r\n\t// of the closing point (first point for shapes, last point for lines)\r\n\t// this is semi-ugly code but the only reliable way i found to get the job done\r\n\t// note: calculating point.distanceTo between mouseDownOrigin and last marker did NOT work\r\n\t_calculateFinishDistance: function (potentialLatLng) {\r\n\t\tvar lastPtDistance;\r\n\t\tif (this._markers.length > 0) {\r\n\t\t\tvar finishMarker;\r\n\t\t\tif (this.type === L.Draw.Polyline.TYPE) {\r\n\t\t\t\tfinishMarker = this._markers[this._markers.length - 1];\r\n\t\t\t} else if (this.type === L.Draw.Polygon.TYPE) {\r\n\t\t\t\tfinishMarker = this._markers[0];\r\n\t\t\t} else {\r\n\t\t\t\treturn Infinity;\r\n\t\t\t}\r\n\t\t\tvar lastMarkerPoint = this._map.latLngToContainerPoint(finishMarker.getLatLng()),\r\n\t\t\t\tpotentialMarker = new L.Marker(potentialLatLng, {\r\n\t\t\t\t\ticon: this.options.icon,\r\n\t\t\t\t\tzIndexOffset: this.options.zIndexOffset * 2\r\n\t\t\t\t});\r\n\t\t\tvar potentialMarkerPint = this._map.latLngToContainerPoint(potentialMarker.getLatLng());\r\n\t\t\tlastPtDistance = lastMarkerPoint.distanceTo(potentialMarkerPint);\r\n\t\t} else {\r\n\t\t\tlastPtDistance = Infinity;\r\n\t\t}\r\n\t\treturn lastPtDistance;\r\n\t},\r\n\r\n\t_updateFinishHandler: function () {\r\n\t\tvar markerCount = this._markers.length;\r\n\t\t// The last marker should have a click handler to close the polyline\r\n\t\tif (markerCount > 1) {\r\n\t\t\tthis._markers[markerCount - 1].on('click', this._finishShape, this);\r\n\t\t}\r\n\r\n\t\t// Remove the old marker click handler (as only the last point should close the polyline)\r\n\t\tif (markerCount > 2) {\r\n\t\t\tthis._markers[markerCount - 2].off('click', this._finishShape, this);\r\n\t\t}\r\n\t},\r\n\r\n\t_createMarker: function (latlng) {\r\n\t\tvar marker = new L.Marker(latlng, {\r\n\t\t\ticon: this.options.icon,\r\n\t\t\tzIndexOffset: this.options.zIndexOffset * 2\r\n\t\t});\r\n\r\n\t\tthis._markerGroup.addLayer(marker);\r\n\r\n\t\treturn marker;\r\n\t},\r\n\r\n\t_updateGuide: function (newPos) {\r\n\t\tvar markerCount = this._markers ? this._markers.length : 0;\r\n\r\n\t\tif (markerCount > 0) {\r\n\t\t\tnewPos = newPos || this._map.latLngToLayerPoint(this._currentLatLng);\r\n\r\n\t\t\t// draw the guide line\r\n\t\t\tthis._clearGuides();\r\n\t\t\tthis._drawGuide(\r\n\t\t\t\tthis._map.latLngToLayerPoint(this._markers[markerCount - 1].getLatLng()),\r\n\t\t\t\tnewPos\r\n\t\t\t);\r\n\t\t}\r\n\t},\r\n\r\n\t_updateTooltip: function (latLng) {\r\n\t\tvar text = this._getTooltipText();\r\n\r\n\t\tif (latLng) {\r\n\t\t\tthis._tooltip.updatePosition(latLng);\r\n\t\t}\r\n\r\n\t\tif (!this._errorShown) {\r\n\t\t\tthis._tooltip.updateContent(text);\r\n\t\t}\r\n\t},\r\n\r\n\t_drawGuide: function (pointA, pointB) {\r\n\t\tvar length = Math.floor(Math.sqrt(Math.pow((pointB.x - pointA.x), 2) + Math.pow((pointB.y - pointA.y), 2))),\r\n\t\t\tguidelineDistance = this.options.guidelineDistance,\r\n\t\t\tmaxGuideLineLength = this.options.maxGuideLineLength,\r\n\t\t\t// Only draw a guideline with a max length\r\n\t\t\ti = length > maxGuideLineLength ? length - maxGuideLineLength : guidelineDistance,\r\n\t\t\tfraction,\r\n\t\t\tdashPoint,\r\n\t\t\tdash;\r\n\r\n\t\t//create the guides container if we haven't yet\r\n\t\tif (!this._guidesContainer) {\r\n\t\t\tthis._guidesContainer = L.DomUtil.create('div', 'leaflet-draw-guides', this._overlayPane);\r\n\t\t}\r\n\r\n\t\t//draw a dash every GuildeLineDistance\r\n\t\tfor (; i < length; i += this.options.guidelineDistance) {\r\n\t\t\t//work out fraction along line we are\r\n\t\t\tfraction = i / length;\r\n\r\n\t\t\t//calculate new x,y point\r\n\t\t\tdashPoint = {\r\n\t\t\t\tx: Math.floor((pointA.x * (1 - fraction)) + (fraction * pointB.x)),\r\n\t\t\t\ty: Math.floor((pointA.y * (1 - fraction)) + (fraction * pointB.y))\r\n\t\t\t};\r\n\r\n\t\t\t//add guide dash to guide container\r\n\t\t\tdash = L.DomUtil.create('div', 'leaflet-draw-guide-dash', this._guidesContainer);\r\n\t\t\tdash.style.backgroundColor =\r\n\t\t\t\t!this._errorShown ? this.options.shapeOptions.color : this.options.drawError.color;\r\n\r\n\t\t\tL.DomUtil.setPosition(dash, dashPoint);\r\n\t\t}\r\n\t},\r\n\r\n\t_updateGuideColor: function (color) {\r\n\t\tif (this._guidesContainer) {\r\n\t\t\tfor (var i = 0, l = this._guidesContainer.childNodes.length; i < l; i++) {\r\n\t\t\t\tthis._guidesContainer.childNodes[i].style.backgroundColor = color;\r\n\t\t\t}\r\n\t\t}\r\n\t},\r\n\r\n\t// removes all child elements (guide dashes) from the guides container\r\n\t_clearGuides: function () {\r\n\t\tif (this._guidesContainer) {\r\n\t\t\twhile (this._guidesContainer.firstChild) {\r\n\t\t\t\tthis._guidesContainer.removeChild(this._guidesContainer.firstChild);\r\n\t\t\t}\r\n\t\t}\r\n\t},\r\n\r\n\t_getTooltipText: function () {\r\n\t\tvar showLength = this.options.showLength,\r\n\t\t\tlabelText, distanceStr;\r\n\t\tif (this._markers.length === 0) {\r\n\t\t\tlabelText = {\r\n\t\t\t\ttext: L.drawLocal.draw.handlers.polyline.tooltip.start\r\n\t\t\t};\r\n\t\t} else {\r\n\t\t\tdistanceStr = showLength ? this._getMeasurementString() : '';\r\n\r\n\t\t\tif (this._markers.length === 1) {\r\n\t\t\t\tlabelText = {\r\n\t\t\t\t\ttext: L.drawLocal.draw.handlers.polyline.tooltip.cont,\r\n\t\t\t\t\tsubtext: distanceStr\r\n\t\t\t\t};\r\n\t\t\t} else {\r\n\t\t\t\tlabelText = {\r\n\t\t\t\t\ttext: L.drawLocal.draw.handlers.polyline.tooltip.end,\r\n\t\t\t\t\tsubtext: distanceStr\r\n\t\t\t\t};\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn labelText;\r\n\t},\r\n\r\n\t_updateRunningMeasure: function (latlng, added) {\r\n\t\tvar markersLength = this._markers.length,\r\n\t\t\tpreviousMarkerIndex, distance;\r\n\r\n\t\tif (this._markers.length === 1) {\r\n\t\t\tthis._measurementRunningTotal = 0;\r\n\t\t} else {\r\n\t\t\tpreviousMarkerIndex = markersLength - (added ? 2 : 1);\r\n\r\n\t\t\t// Calculate the distance based on the version\r\n\t\t\tif (L.GeometryUtil.isVersion07x()) {\r\n\t\t\t\tdistance = latlng.distanceTo(this._markers[previousMarkerIndex].getLatLng()) * (this.options.factor || 1);\r\n\t\t\t} else {\r\n\t\t\t\tdistance = this._map.distance(latlng, this._markers[previousMarkerIndex].getLatLng()) * (this.options.factor || 1);\r\n\t\t\t}\r\n\r\n\t\t\tthis._measurementRunningTotal += distance * (added ? 1 : -1);\r\n\t\t}\r\n\t},\r\n\r\n\t_getMeasurementString: function () {\r\n\t\tvar currentLatLng = this._currentLatLng,\r\n\t\t\tpreviousLatLng = this._markers[this._markers.length - 1].getLatLng(),\r\n\t\t\tdistance;\r\n\r\n\t\t// Calculate the distance from the last fixed point to the mouse position based on the version\r\n\t\tif (L.GeometryUtil.isVersion07x()) {\r\n\t\t\tdistance = previousLatLng && currentLatLng && currentLatLng.distanceTo ? this._measurementRunningTotal + currentLatLng.distanceTo(previousLatLng) * (this.options.factor || 1) : this._measurementRunningTotal || 0;\r\n\t\t} else {\r\n\t\t\tdistance = previousLatLng && currentLatLng ? this._measurementRunningTotal + this._map.distance(currentLatLng, previousLatLng) * (this.options.factor || 1) : this._measurementRunningTotal || 0;\r\n\t\t}\r\n\r\n\t\treturn L.GeometryUtil.readableDistance(distance, this.options.metric, this.options.feet, this.options.nautic, this.options.precision);\r\n\t},\r\n\r\n\t_showErrorTooltip: function () {\r\n\t\tthis._errorShown = true;\r\n\r\n\t\t// Update tooltip\r\n\t\tthis._tooltip\r\n\t\t\t.showAsError()\r\n\t\t\t.updateContent({text: this.options.drawError.message});\r\n\r\n\t\t// Update shape\r\n\t\tthis._updateGuideColor(this.options.drawError.color);\r\n\t\tthis._poly.setStyle({color: this.options.drawError.color});\r\n\r\n\t\t// Hide the error after 2 seconds\r\n\t\tthis._clearHideErrorTimeout();\r\n\t\tthis._hideErrorTimeout = setTimeout(L.Util.bind(this._hideErrorTooltip, this), this.options.drawError.timeout);\r\n\t},\r\n\r\n\t_hideErrorTooltip: function () {\r\n\t\tthis._errorShown = false;\r\n\r\n\t\tthis._clearHideErrorTimeout();\r\n\r\n\t\t// Revert tooltip\r\n\t\tthis._tooltip\r\n\t\t\t.removeError()\r\n\t\t\t.updateContent(this._getTooltipText());\r\n\r\n\t\t// Revert shape\r\n\t\tthis._updateGuideColor(this.options.shapeOptions.color);\r\n\t\tthis._poly.setStyle({color: this.options.shapeOptions.color});\r\n\t},\r\n\r\n\t_clearHideErrorTimeout: function () {\r\n\t\tif (this._hideErrorTimeout) {\r\n\t\t\tclearTimeout(this._hideErrorTimeout);\r\n\t\t\tthis._hideErrorTimeout = null;\r\n\t\t}\r\n\t},\r\n\r\n\t// disable new markers temporarily;\r\n\t// this is to prevent duplicated touch/click events in some browsers\r\n\t_disableNewMarkers: function () {\r\n\t\tthis._disableMarkers = true;\r\n\t},\r\n\r\n\t// see _disableNewMarkers\r\n\t_enableNewMarkers: function () {\r\n\t\tsetTimeout(function () {\r\n\t\t\tthis._disableMarkers = false;\r\n\t\t}.bind(this), 50);\r\n\t},\r\n\r\n\t_cleanUpShape: function () {\r\n\t\tif (this._markers.length > 1) {\r\n\t\t\tthis._markers[this._markers.length - 1].off('click', this._finishShape, this);\r\n\t\t}\r\n\t},\r\n\r\n\t_fireCreatedEvent: function () {\r\n\t\tvar poly = new this.Poly(this._poly.getLatLngs(), this.options.shapeOptions);\r\n\t\tL.Draw.Feature.prototype._fireCreatedEvent.call(this, poly);\r\n\t}\r\n});\r\n","/**\r\n * @class L.Draw.Polygon\r\n * @aka Draw.Polygon\r\n * @inherits L.Draw.Polyline\r\n */\r\nL.Draw.Polygon = L.Draw.Polyline.extend({\r\n\tstatics: {\r\n\t\tTYPE: 'polygon'\r\n\t},\r\n\r\n\tPoly: L.Polygon,\r\n\r\n\toptions: {\r\n\t\tshowArea: false,\r\n\t\tshowLength: false,\r\n\t\tshapeOptions: {\r\n\t\t\tstroke: true,\r\n\t\t\tcolor: '#3388ff',\r\n\t\t\tweight: 4,\r\n\t\t\topacity: 0.5,\r\n\t\t\tfill: true,\r\n\t\t\tfillColor: null, //same as color by default\r\n\t\t\tfillOpacity: 0.2,\r\n\t\t\tclickable: true\r\n\t\t},\r\n\t\t// Whether to use the metric measurement system (truthy) or not (falsy).\r\n\t\t// Also defines the units to use for the metric system as an array of\r\n\t\t// strings (e.g. `['ha', 'm']`).\r\n\t\tmetric: true,\r\n\t\tfeet: true, // When not metric, to use feet instead of yards for display.\r\n\t\tnautic: false, // When not metric, not feet use nautic mile for display\r\n\t\t// Defines the precision for each type of unit (e.g. {km: 2, ft: 0}\r\n\t\tprecision: {}\r\n\t},\r\n\r\n\t// @method initialize(): void\r\n\tinitialize: function (map, options) {\r\n\t\tL.Draw.Polyline.prototype.initialize.call(this, map, options);\r\n\r\n\t\t// Save the type so super can fire, need to do this as cannot do this.TYPE :(\r\n\t\tthis.type = L.Draw.Polygon.TYPE;\r\n\t},\r\n\r\n\t_updateFinishHandler: function () {\r\n\t\tvar markerCount = this._markers.length;\r\n\r\n\t\t// The first marker should have a click handler to close the polygon\r\n\t\tif (markerCount === 1) {\r\n\t\t\tthis._markers[0].on('click', this._finishShape, this);\r\n\t\t}\r\n\r\n\t\t// Add and update the double click handler\r\n\t\tif (markerCount > 2) {\r\n\t\t\tthis._markers[markerCount - 1].on('dblclick', this._finishShape, this);\r\n\t\t\t// Only need to remove handler if has been added before\r\n\t\t\tif (markerCount > 3) {\r\n\t\t\t\tthis._markers[markerCount - 2].off('dblclick', this._finishShape, this);\r\n\t\t\t}\r\n\t\t}\r\n\t},\r\n\r\n\t_getTooltipText: function () {\r\n\t\tvar text, subtext;\r\n\r\n\t\tif (this._markers.length === 0) {\r\n\t\t\ttext = L.drawLocal.draw.handlers.polygon.tooltip.start;\r\n\t\t} else if (this._markers.length < 3) {\r\n\t\t\ttext = L.drawLocal.draw.handlers.polygon.tooltip.cont;\r\n\t\t\tsubtext = this._getMeasurementString();\r\n\t\t} else {\r\n\t\t\ttext = L.drawLocal.draw.handlers.polygon.tooltip.end;\r\n\t\t\tsubtext = this._getMeasurementString();\r\n\t\t}\r\n\r\n\t\treturn {\r\n\t\t\ttext: text,\r\n\t\t\tsubtext: subtext\r\n\t\t};\r\n\t},\r\n\r\n\t_getMeasurementString: function () {\r\n\t\tvar area = this._area,\r\n\t\t\tmeasurementString = '';\r\n\r\n\r\n\t\tif (!area && !this.options.showLength) {\r\n\t\t\treturn null;\r\n\t\t}\r\n\r\n\t\tif (this.options.showLength) {\r\n\t\t\tmeasurementString = L.Draw.Polyline.prototype._getMeasurementString.call(this);\r\n\t\t}\r\n\r\n\t\tif (area) {\r\n\t\t\tmeasurementString += '
' + L.GeometryUtil.readableArea(area, this.options.metric, this.options.precision);\r\n\t\t}\r\n\r\n\t\treturn measurementString;\r\n\t},\r\n\r\n\t_shapeIsValid: function () {\r\n\t\treturn this._markers.length >= 3;\r\n\t},\r\n\r\n\t_vertexChanged: function (latlng, added) {\r\n\t\tvar latLngs;\r\n\r\n\t\t// Check to see if we should show the area\r\n\t\tif (!this.options.allowIntersection && this.options.showArea) {\r\n\t\t\tlatLngs = this._poly.getLatLngs();\r\n\r\n\t\t\tthis._area = L.GeometryUtil.geodesicArea(latLngs);\r\n\t\t}\r\n\r\n\t\tL.Draw.Polyline.prototype._vertexChanged.call(this, latlng, added);\r\n\t},\r\n\r\n\t_cleanUpShape: function () {\r\n\t\tvar markerCount = this._markers.length;\r\n\r\n\t\tif (markerCount > 0) {\r\n\t\t\tthis._markers[0].off('click', this._finishShape, this);\r\n\r\n\t\t\tif (markerCount > 2) {\r\n\t\t\t\tthis._markers[markerCount - 1].off('dblclick', this._finishShape, this);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n});\r\n","L.SimpleShape = {};\r\n/**\r\n * @class L.Draw.SimpleShape\r\n * @aka Draw.SimpleShape\r\n * @inherits L.Draw.Feature\r\n */\r\nL.Draw.SimpleShape = L.Draw.Feature.extend({\r\n\toptions: {\r\n\t\trepeatMode: false\r\n\t},\r\n\r\n\t// @method initialize(): void\r\n\tinitialize: function (map, options) {\r\n\t\tthis._endLabelText = L.drawLocal.draw.handlers.simpleshape.tooltip.end;\r\n\r\n\t\tL.Draw.Feature.prototype.initialize.call(this, map, options);\r\n\t},\r\n\r\n\t// @method addHooks(): void\r\n\t// Add listener hooks to this handler.\r\n\taddHooks: function () {\r\n\t\tL.Draw.Feature.prototype.addHooks.call(this);\r\n\t\tif (this._map) {\r\n\t\t\tthis._mapDraggable = this._map.dragging.enabled();\r\n\r\n\t\t\tif (this._mapDraggable) {\r\n\t\t\t\tthis._map.dragging.disable();\r\n\t\t\t}\r\n\r\n\t\t\t//TODO refactor: move cursor to styles\r\n\t\t\tthis._container.style.cursor = 'crosshair';\r\n\r\n\t\t\tthis._tooltip.updateContent({text: this._initialLabelText});\r\n\r\n\t\t\tthis._map\r\n\t\t\t\t.on('mousedown', this._onMouseDown, this)\r\n\t\t\t\t.on('mousemove', this._onMouseMove, this)\r\n\t\t\t\t.on('touchstart', this._onMouseDown, this)\r\n\t\t\t\t.on('touchmove', this._onMouseMove, this);\r\n\r\n\t\t\t// we should prevent default, otherwise default behavior (scrolling) will fire,\r\n\t\t\t// and that will cause document.touchend to fire and will stop the drawing\r\n\t\t\t// (circle, rectangle) in touch mode.\r\n\t\t\t// (update): we have to send passive now to prevent scroll, because by default it is {passive: true} now, which means,\r\n\t\t\t// handler can't event.preventDefault\r\n\t\t\t// check the news https://developers.google.com/web/updates/2016/06/passive-event-listeners\r\n\t\t\tdocument.addEventListener('touchstart', L.DomEvent.preventDefault, {passive: false});\r\n\t\t}\r\n\t},\r\n\r\n\t// @method removeHooks(): void\r\n\t// Remove listener hooks from this handler.\r\n\tremoveHooks: function () {\r\n\t\tL.Draw.Feature.prototype.removeHooks.call(this);\r\n\t\tif (this._map) {\r\n\t\t\tif (this._mapDraggable) {\r\n\t\t\t\tthis._map.dragging.enable();\r\n\t\t\t}\r\n\r\n\t\t\t//TODO refactor: move cursor to styles\r\n\t\t\tthis._container.style.cursor = '';\r\n\r\n\t\t\tthis._map\r\n\t\t\t\t.off('mousedown', this._onMouseDown, this)\r\n\t\t\t\t.off('mousemove', this._onMouseMove, this)\r\n\t\t\t\t.off('touchstart', this._onMouseDown, this)\r\n\t\t\t\t.off('touchmove', this._onMouseMove, this);\r\n\r\n\t\t\tL.DomEvent.off(document, 'mouseup', this._onMouseUp, this);\r\n\t\t\tL.DomEvent.off(document, 'touchend', this._onMouseUp, this);\r\n\r\n\t\t\tdocument.removeEventListener('touchstart', L.DomEvent.preventDefault);\r\n\r\n\t\t\t// If the box element doesn't exist they must not have moved the mouse, so don't need to destroy/return\r\n\t\t\tif (this._shape) {\r\n\t\t\t\tthis._map.removeLayer(this._shape);\r\n\t\t\t\tdelete this._shape;\r\n\t\t\t}\r\n\t\t}\r\n\t\tthis._isDrawing = false;\r\n\t},\r\n\r\n\t_getTooltipText: function () {\r\n\t\treturn {\r\n\t\t\ttext: this._endLabelText\r\n\t\t};\r\n\t},\r\n\r\n\t_onMouseDown: function (e) {\r\n\t\tthis._isDrawing = true;\r\n\t\tthis._startLatLng = e.latlng;\r\n\r\n\t\tL.DomEvent\r\n\t\t\t.on(document, 'mouseup', this._onMouseUp, this)\r\n\t\t\t.on(document, 'touchend', this._onMouseUp, this)\r\n\t\t\t.preventDefault(e.originalEvent);\r\n\t},\r\n\r\n\t_onMouseMove: function (e) {\r\n\t\tvar latlng = e.latlng;\r\n\r\n\t\tthis._tooltip.updatePosition(latlng);\r\n\t\tif (this._isDrawing) {\r\n\t\t\tthis._tooltip.updateContent(this._getTooltipText());\r\n\t\t\tthis._drawShape(latlng);\r\n\t\t}\r\n\t},\r\n\r\n\t_onMouseUp: function () {\r\n\t\tif (this._shape) {\r\n\t\t\tthis._fireCreatedEvent();\r\n\t\t}\r\n\r\n\t\tthis.disable();\r\n\t\tif (this.options.repeatMode) {\r\n\t\t\tthis.enable();\r\n\t\t}\r\n\t}\r\n});\r\n","/**\r\n * @class L.Draw.Rectangle\r\n * @aka Draw.Rectangle\r\n * @inherits L.Draw.SimpleShape\r\n */\r\nL.Draw.Rectangle = L.Draw.SimpleShape.extend({\r\n\tstatics: {\r\n\t\tTYPE: 'rectangle'\r\n\t},\r\n\r\n\toptions: {\r\n\t\tshapeOptions: {\r\n\t\t\tstroke: true,\r\n\t\t\tcolor: '#3388ff',\r\n\t\t\tweight: 4,\r\n\t\t\topacity: 0.5,\r\n\t\t\tfill: true,\r\n\t\t\tfillColor: null, //same as color by default\r\n\t\t\tfillOpacity: 0.2,\r\n\t\t\tclickable: true\r\n\t\t},\r\n\t\tshowArea: true, //Whether to show the area in the tooltip\r\n\t\tmetric: true // Whether to use the metric measurement system or imperial\r\n\t},\r\n\r\n\t// @method initialize(): void\r\n\tinitialize: function (map, options) {\r\n\t\t// Save the type so super can fire, need to do this as cannot do this.TYPE :(\r\n\t\tthis.type = L.Draw.Rectangle.TYPE;\r\n\r\n\t\tthis._initialLabelText = L.drawLocal.draw.handlers.rectangle.tooltip.start;\r\n\r\n\t\tL.Draw.SimpleShape.prototype.initialize.call(this, map, options);\r\n\t},\r\n\r\n\t// @method disable(): void\r\n\tdisable: function () {\r\n\t\tif (!this._enabled) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tthis._isCurrentlyTwoClickDrawing = false;\r\n\t\tL.Draw.SimpleShape.prototype.disable.call(this);\r\n\t},\r\n\r\n\t_onMouseUp: function (e) {\r\n\t\tif (!this._shape && !this._isCurrentlyTwoClickDrawing) {\r\n\t\t\tthis._isCurrentlyTwoClickDrawing = true;\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\t// Make sure closing click is on map\r\n\t\tif (this._isCurrentlyTwoClickDrawing && !_hasAncestor(e.target, 'leaflet-pane')) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tL.Draw.SimpleShape.prototype._onMouseUp.call(this);\r\n\t},\r\n\r\n\t_drawShape: function (latlng) {\r\n\t\tif (!this._shape) {\r\n\t\t\tthis._shape = new L.Rectangle(new L.LatLngBounds(this._startLatLng, latlng), this.options.shapeOptions);\r\n\t\t\tthis._map.addLayer(this._shape);\r\n\t\t} else {\r\n\t\t\tthis._shape.setBounds(new L.LatLngBounds(this._startLatLng, latlng));\r\n\t\t}\r\n\t},\r\n\r\n\t_fireCreatedEvent: function () {\r\n\t\tvar rectangle = new L.Rectangle(this._shape.getBounds(), this.options.shapeOptions);\r\n\t\tL.Draw.SimpleShape.prototype._fireCreatedEvent.call(this, rectangle);\r\n\t},\r\n\r\n\t_getTooltipText: function () {\r\n\t\tvar tooltipText = L.Draw.SimpleShape.prototype._getTooltipText.call(this),\r\n\t\t\tshape = this._shape,\r\n\t\t\tshowArea = this.options.showArea,\r\n\t\t\tlatLngs, area, subtext;\r\n\r\n\t\tif (shape) {\r\n\t\t\tlatLngs = this._shape._defaultShape ? this._shape._defaultShape() : this._shape.getLatLngs();\r\n\t\t\tarea = L.GeometryUtil.geodesicArea(latLngs);\r\n\t\t\tsubtext = showArea ? L.GeometryUtil.readableArea(area, this.options.metric) : '';\r\n\t\t}\r\n\r\n\t\treturn {\r\n\t\t\ttext: tooltipText.text,\r\n\t\t\tsubtext: subtext\r\n\t\t};\r\n\t}\r\n});\r\n\r\nfunction _hasAncestor(el, cls) {\r\n\twhile ((el = el.parentElement) && !el.classList.contains(cls)) {\r\n\t\t;\r\n\t}\r\n\treturn el;\r\n}\r\n","/**\r\n * @class L.Draw.Marker\r\n * @aka Draw.Marker\r\n * @inherits L.Draw.Feature\r\n */\r\nL.Draw.Marker = L.Draw.Feature.extend({\r\n\tstatics: {\r\n\t\tTYPE: 'marker'\r\n\t},\r\n\r\n\toptions: {\r\n\t\ticon: new L.Icon.Default(),\r\n\t\trepeatMode: false,\r\n\t\tzIndexOffset: 2000 // This should be > than the highest z-index any markers\r\n\t},\r\n\r\n\t// @method initialize(): void\r\n\tinitialize: function (map, options) {\r\n\t\t// Save the type so super can fire, need to do this as cannot do this.TYPE :(\r\n\t\tthis.type = L.Draw.Marker.TYPE;\r\n\r\n\t\tthis._initialLabelText = L.drawLocal.draw.handlers.marker.tooltip.start;\r\n\r\n\t\tL.Draw.Feature.prototype.initialize.call(this, map, options);\r\n\t},\r\n\r\n\t// @method addHooks(): void\r\n\t// Add listener hooks to this handler.\r\n\taddHooks: function () {\r\n\t\tL.Draw.Feature.prototype.addHooks.call(this);\r\n\r\n\t\tif (this._map) {\r\n\t\t\tthis._tooltip.updateContent({text: this._initialLabelText});\r\n\r\n\t\t\t// Same mouseMarker as in Draw.Polyline\r\n\t\t\tif (!this._mouseMarker) {\r\n\t\t\t\tthis._mouseMarker = L.marker(this._map.getCenter(), {\r\n\t\t\t\t\ticon: L.divIcon({\r\n\t\t\t\t\t\tclassName: 'leaflet-mouse-marker',\r\n\t\t\t\t\t\ticonAnchor: [20, 20],\r\n\t\t\t\t\t\ticonSize: [40, 40]\r\n\t\t\t\t\t}),\r\n\t\t\t\t\topacity: 0,\r\n\t\t\t\t\tzIndexOffset: this.options.zIndexOffset\r\n\t\t\t\t});\r\n\t\t\t}\r\n\r\n\t\t\tthis._mouseMarker\r\n\t\t\t\t.on('click', this._onClick, this)\r\n\t\t\t\t.addTo(this._map);\r\n\r\n\t\t\tthis._map.on('mousemove', this._onMouseMove, this);\r\n\t\t\tthis._map.on('click', this._onTouch, this);\r\n\t\t}\r\n\t},\r\n\r\n\t// @method removeHooks(): void\r\n\t// Remove listener hooks from this handler.\r\n\tremoveHooks: function () {\r\n\t\tL.Draw.Feature.prototype.removeHooks.call(this);\r\n\r\n\t\tif (this._map) {\r\n\t\t\tthis._map\r\n\t\t\t\t.off('click', this._onClick, this)\r\n\t\t\t\t.off('click', this._onTouch, this);\r\n\t\t\tif (this._marker) {\r\n\t\t\t\tthis._marker.off('click', this._onClick, this);\r\n\t\t\t\tthis._map\r\n\t\t\t\t\t.removeLayer(this._marker);\r\n\t\t\t\tdelete this._marker;\r\n\t\t\t}\r\n\r\n\t\t\tthis._mouseMarker.off('click', this._onClick, this);\r\n\t\t\tthis._map.removeLayer(this._mouseMarker);\r\n\t\t\tdelete this._mouseMarker;\r\n\r\n\t\t\tthis._map.off('mousemove', this._onMouseMove, this);\r\n\t\t}\r\n\t},\r\n\r\n\t_onMouseMove: function (e) {\r\n\t\tvar latlng = e.latlng;\r\n\r\n\t\tthis._tooltip.updatePosition(latlng);\r\n\t\tthis._mouseMarker.setLatLng(latlng);\r\n\r\n\t\tif (!this._marker) {\r\n\t\t\tthis._marker = this._createMarker(latlng);\r\n\t\t\t// Bind to both marker and map to make sure we get the click event.\r\n\t\t\tthis._marker.on('click', this._onClick, this);\r\n\t\t\tthis._map\r\n\t\t\t\t.on('click', this._onClick, this)\r\n\t\t\t\t.addLayer(this._marker);\r\n\t\t}\r\n\t\telse {\r\n\t\t\tlatlng = this._mouseMarker.getLatLng();\r\n\t\t\tthis._marker.setLatLng(latlng);\r\n\t\t}\r\n\t},\r\n\r\n\t_createMarker: function (latlng) {\r\n\t\treturn new L.Marker(latlng, {\r\n\t\t\ticon: this.options.icon,\r\n\t\t\tzIndexOffset: this.options.zIndexOffset\r\n\t\t});\r\n\t},\r\n\r\n\t_onClick: function () {\r\n\t\tthis._fireCreatedEvent();\r\n\r\n\t\tthis.disable();\r\n\t\tif (this.options.repeatMode) {\r\n\t\t\tthis.enable();\r\n\t\t}\r\n\t},\r\n\r\n\t_onTouch: function (e) {\r\n\t\t// called on click & tap, only really does any thing on tap\r\n\t\tthis._onMouseMove(e); // creates & places marker\r\n\t\tthis._onClick(); // permanently places marker & ends interaction\r\n\t},\r\n\r\n\t_fireCreatedEvent: function () {\r\n\t\tvar marker = new L.Marker.Touch(this._marker.getLatLng(), {icon: this.options.icon});\r\n\t\tL.Draw.Feature.prototype._fireCreatedEvent.call(this, marker);\r\n\t}\r\n});\r\n","/**\r\n * @class L.Draw.CircleMarker\r\n * @aka Draw.CircleMarker\r\n * @inherits L.Draw.Marker\r\n */\r\nL.Draw.CircleMarker = L.Draw.Marker.extend({\r\n\tstatics: {\r\n\t\tTYPE: 'circlemarker'\r\n\t},\r\n\r\n\toptions: {\r\n\t\tstroke: true,\r\n\t\tcolor: '#3388ff',\r\n\t\tweight: 4,\r\n\t\topacity: 0.5,\r\n\t\tfill: true,\r\n\t\tfillColor: null, //same as color by default\r\n\t\tfillOpacity: 0.2,\r\n\t\tclickable: true,\r\n\t\tzIndexOffset: 2000 // This should be > than the highest z-index any markers\r\n\t},\r\n\r\n\t// @method initialize(): void\r\n\tinitialize: function (map, options) {\r\n\t\t// Save the type so super can fire, need to do this as cannot do this.TYPE :(\r\n\t\tthis.type = L.Draw.CircleMarker.TYPE;\r\n\r\n\t\tthis._initialLabelText = L.drawLocal.draw.handlers.circlemarker.tooltip.start;\r\n\r\n\t\tL.Draw.Feature.prototype.initialize.call(this, map, options);\r\n\t},\r\n\r\n\r\n\t_fireCreatedEvent: function () {\r\n\t\tvar circleMarker = new L.CircleMarker(this._marker.getLatLng(), this.options);\r\n\t\tL.Draw.Feature.prototype._fireCreatedEvent.call(this, circleMarker);\r\n\t},\r\n\r\n\t_createMarker: function (latlng) {\r\n\t\treturn new L.CircleMarker(latlng, this.options);\r\n\t}\r\n});\r\n","/**\r\n * @class L.Draw.Circle\r\n * @aka Draw.Circle\r\n * @inherits L.Draw.SimpleShape\r\n */\r\nL.Draw.Circle = L.Draw.SimpleShape.extend({\r\n\tstatics: {\r\n\t\tTYPE: 'circle'\r\n\t},\r\n\r\n\toptions: {\r\n\t\tshapeOptions: {\r\n\t\t\tstroke: true,\r\n\t\t\tcolor: '#3388ff',\r\n\t\t\tweight: 4,\r\n\t\t\topacity: 0.5,\r\n\t\t\tfill: true,\r\n\t\t\tfillColor: null, //same as color by default\r\n\t\t\tfillOpacity: 0.2,\r\n\t\t\tclickable: true\r\n\t\t},\r\n\t\tshowRadius: true,\r\n\t\tmetric: true, // Whether to use the metric measurement system or imperial\r\n\t\tfeet: true, // When not metric, use feet instead of yards for display\r\n\t\tnautic: false // When not metric, not feet use nautic mile for display\r\n\t},\r\n\r\n\t// @method initialize(): void\r\n\tinitialize: function (map, options) {\r\n\t\t// Save the type so super can fire, need to do this as cannot do this.TYPE :(\r\n\t\tthis.type = L.Draw.Circle.TYPE;\r\n\r\n\t\tthis._initialLabelText = L.drawLocal.draw.handlers.circle.tooltip.start;\r\n\r\n\t\tL.Draw.SimpleShape.prototype.initialize.call(this, map, options);\r\n\t},\r\n\r\n\t_drawShape: function (latlng) {\r\n\t\t// Calculate the distance based on the version\r\n\t\tif (L.GeometryUtil.isVersion07x()) {\r\n\t\t\tvar distance = this._startLatLng.distanceTo(latlng);\r\n\t\t} else {\r\n\t\t\tvar distance = this._map.distance(this._startLatLng, latlng);\r\n\t\t}\r\n\r\n\t\tif (!this._shape) {\r\n\t\t\tthis._shape = new L.Circle(this._startLatLng, distance, this.options.shapeOptions);\r\n\t\t\tthis._map.addLayer(this._shape);\r\n\t\t} else {\r\n\t\t\tthis._shape.setRadius(distance);\r\n\t\t}\r\n\t},\r\n\r\n\t_fireCreatedEvent: function () {\r\n\t\tvar circle = new L.Circle(this._startLatLng, this._shape.getRadius(), this.options.shapeOptions);\r\n\t\tL.Draw.SimpleShape.prototype._fireCreatedEvent.call(this, circle);\r\n\t},\r\n\r\n\t_onMouseMove: function (e) {\r\n\t\tvar latlng = e.latlng,\r\n\t\t\tshowRadius = this.options.showRadius,\r\n\t\t\tuseMetric = this.options.metric,\r\n\t\t\tradius;\r\n\r\n\t\tthis._tooltip.updatePosition(latlng);\r\n\t\tif (this._isDrawing) {\r\n\t\t\tthis._drawShape(latlng);\r\n\r\n\t\t\t// Get the new radius (rounded to 1 dp)\r\n\t\t\tradius = this._shape.getRadius().toFixed(1);\r\n\r\n\t\t\tvar subtext = '';\r\n\t\t\tif (showRadius) {\r\n\t\t\t\tsubtext = L.drawLocal.draw.handlers.circle.radius + ': ' +\r\n\t\t\t\t\tL.GeometryUtil.readableDistance(radius, useMetric, this.options.feet, this.options.nautic);\r\n\t\t\t}\r\n\t\t\tthis._tooltip.updateContent({\r\n\t\t\t\ttext: this._endLabelText,\r\n\t\t\t\tsubtext: subtext\r\n\t\t\t});\r\n\t\t}\r\n\t}\r\n});\r\n","L.Edit = L.Edit || {};\r\n\r\n/**\r\n * @class L.Edit.Marker\r\n * @aka Edit.Marker\r\n */\r\nL.Edit.Marker = L.Handler.extend({\r\n\t// @method initialize(): void\r\n\tinitialize: function (marker, options) {\r\n\t\tthis._marker = marker;\r\n\t\tL.setOptions(this, options);\r\n\t},\r\n\r\n\t// @method addHooks(): void\r\n\t// Add listener hooks to this handler\r\n\taddHooks: function () {\r\n\t\tvar marker = this._marker;\r\n\r\n\t\tmarker.dragging.enable();\r\n\t\tmarker.on('dragend', this._onDragEnd, marker);\r\n\t\tthis._toggleMarkerHighlight();\r\n\t},\r\n\r\n\t// @method removeHooks(): void\r\n\t// Remove listener hooks from this handler\r\n\tremoveHooks: function () {\r\n\t\tvar marker = this._marker;\r\n\r\n\t\tmarker.dragging.disable();\r\n\t\tmarker.off('dragend', this._onDragEnd, marker);\r\n\t\tthis._toggleMarkerHighlight();\r\n\t},\r\n\r\n\t_onDragEnd: function (e) {\r\n\t\tvar layer = e.target;\r\n\t\tlayer.edited = true;\r\n\t\tthis._map.fire(L.Draw.Event.EDITMOVE, {layer: layer});\r\n\t},\r\n\r\n\t_toggleMarkerHighlight: function () {\r\n\t\tvar icon = this._marker._icon;\r\n\r\n\t\t// Don't do anything if this layer is a marker but doesn't have an icon. Markers\r\n\t\t// should usually have icons. If using Leaflet.draw with Leaflet.markercluster there\r\n\t\t// is a chance that a marker doesn't.\r\n\t\tif (!icon) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\t// This is quite naughty, but I don't see another way of doing it. (short of setting a new icon)\r\n\t\ticon.style.display = 'none';\r\n\r\n\t\tif (L.DomUtil.hasClass(icon, 'leaflet-edit-marker-selected')) {\r\n\t\t\tL.DomUtil.removeClass(icon, 'leaflet-edit-marker-selected');\r\n\t\t\t// Offset as the border will make the icon move.\r\n\t\t\tthis._offsetMarker(icon, -4);\r\n\r\n\t\t} else {\r\n\t\t\tL.DomUtil.addClass(icon, 'leaflet-edit-marker-selected');\r\n\t\t\t// Offset as the border will make the icon move.\r\n\t\t\tthis._offsetMarker(icon, 4);\r\n\t\t}\r\n\r\n\t\ticon.style.display = '';\r\n\t},\r\n\r\n\t_offsetMarker: function (icon, offset) {\r\n\t\tvar iconMarginTop = parseInt(icon.style.marginTop, 10) - offset,\r\n\t\t\ticonMarginLeft = parseInt(icon.style.marginLeft, 10) - offset;\r\n\r\n\t\ticon.style.marginTop = iconMarginTop + 'px';\r\n\t\ticon.style.marginLeft = iconMarginLeft + 'px';\r\n\t}\r\n});\r\n\r\nL.Marker.addInitHook(function () {\r\n\tif (L.Edit.Marker) {\r\n\t\tthis.editing = new L.Edit.Marker(this);\r\n\r\n\t\tif (this.options.editable) {\r\n\t\t\tthis.editing.enable();\r\n\t\t}\r\n\t}\r\n});\r\n","L.Edit = L.Edit || {};\r\n\r\n/**\r\n * @class L.Edit.Polyline\r\n * @aka L.Edit.Poly\r\n * @aka Edit.Poly\r\n */\r\nL.Edit.Poly = L.Handler.extend({\r\n\t// @method initialize(): void\r\n\tinitialize: function (poly) {\r\n\r\n\t\tthis.latlngs = [poly._latlngs];\r\n\t\tif (poly._holes) {\r\n\t\t\tthis.latlngs = this.latlngs.concat(poly._holes);\r\n\t\t}\r\n\r\n\t\tthis._poly = poly;\r\n\r\n\t\tthis._poly.on('revert-edited', this._updateLatLngs, this);\r\n\t},\r\n\r\n\t// Compatibility method to normalize Poly* objects\r\n\t// between 0.7.x and 1.0+\r\n\t_defaultShape: function () {\r\n\t\tif (!L.Polyline._flat) {\r\n\t\t\treturn this._poly._latlngs;\r\n\t\t}\r\n\t\treturn L.Polyline._flat(this._poly._latlngs) ? this._poly._latlngs : this._poly._latlngs[0];\r\n\t},\r\n\r\n\t_eachVertexHandler: function (callback) {\r\n\t\tfor (var i = 0; i < this._verticesHandlers.length; i++) {\r\n\t\t\tcallback(this._verticesHandlers[i]);\r\n\t\t}\r\n\t},\r\n\r\n\t// @method addHooks(): void\r\n\t// Add listener hooks to this handler\r\n\taddHooks: function () {\r\n\t\tthis._initHandlers();\r\n\t\tthis._eachVertexHandler(function (handler) {\r\n\t\t\thandler.addHooks();\r\n\t\t});\r\n\t},\r\n\r\n\t// @method removeHooks(): void\r\n\t// Remove listener hooks from this handler\r\n\tremoveHooks: function () {\r\n\t\tthis._eachVertexHandler(function (handler) {\r\n\t\t\thandler.removeHooks();\r\n\t\t});\r\n\t},\r\n\r\n\t// @method updateMarkers(): void\r\n\t// Fire an update for each vertex handler\r\n\tupdateMarkers: function () {\r\n\t\tthis._eachVertexHandler(function (handler) {\r\n\t\t\thandler.updateMarkers();\r\n\t\t});\r\n\t},\r\n\r\n\t_initHandlers: function () {\r\n\t\tthis._verticesHandlers = [];\r\n\t\tfor (var i = 0; i < this.latlngs.length; i++) {\r\n\t\t\tthis._verticesHandlers.push(new L.Edit.PolyVerticesEdit(this._poly, this.latlngs[i], this._poly.options.poly));\r\n\t\t}\r\n\t},\r\n\r\n\t_updateLatLngs: function (e) {\r\n\t\tthis.latlngs = [e.layer._latlngs];\r\n\t\tif (e.layer._holes) {\r\n\t\t\tthis.latlngs = this.latlngs.concat(e.layer._holes);\r\n\t\t}\r\n\t}\r\n\r\n});\r\n\r\n/**\r\n * @class L.Edit.PolyVerticesEdit\r\n * @aka Edit.PolyVerticesEdit\r\n */\r\nL.Edit.PolyVerticesEdit = L.Handler.extend({\r\n\toptions: {\r\n\t\ticon: new L.DivIcon({\r\n\t\t\ticonSize: new L.Point(8, 8),\r\n\t\t\tclassName: 'leaflet-div-icon leaflet-editing-icon'\r\n\t\t}),\r\n\t\ttouchIcon: new L.DivIcon({\r\n\t\t\ticonSize: new L.Point(20, 20),\r\n\t\t\tclassName: 'leaflet-div-icon leaflet-editing-icon leaflet-touch-icon'\r\n\t\t}),\r\n\t\tdrawError: {\r\n\t\t\tcolor: '#b00b00',\r\n\t\t\ttimeout: 1000\r\n\t\t}\r\n\r\n\r\n\t},\r\n\r\n\t// @method intialize(): void\r\n\tinitialize: function (poly, latlngs, options) {\r\n\t\t// if touch, switch to touch icon\r\n\t\tif (L.Browser.touch) {\r\n\t\t\tthis.options.icon = this.options.touchIcon;\r\n\t\t}\r\n\t\tthis._poly = poly;\r\n\r\n\t\tif (options && options.drawError) {\r\n\t\t\toptions.drawError = L.Util.extend({}, this.options.drawError, options.drawError);\r\n\t\t}\r\n\r\n\t\tthis._latlngs = latlngs;\r\n\r\n\t\tL.setOptions(this, options);\r\n\t},\r\n\r\n\t// Compatibility method to normalize Poly* objects\r\n\t// between 0.7.x and 1.0+\r\n\t_defaultShape: function () {\r\n\t\tif (!L.Polyline._flat) {\r\n\t\t\treturn this._latlngs;\r\n\t\t}\r\n\t\treturn L.Polyline._flat(this._latlngs) ? this._latlngs : this._latlngs[0];\r\n\t},\r\n\r\n\t// @method addHooks(): void\r\n\t// Add listener hooks to this handler.\r\n\taddHooks: function () {\r\n\t\tvar poly = this._poly;\r\n\t\tvar path = poly._path;\r\n\r\n\t\tif (!(poly instanceof L.Polygon)) {\r\n\t\t\tpoly.options.fill = false;\r\n\t\t\tif (poly.options.editing) {\r\n\t\t\t\tpoly.options.editing.fill = false;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (path) {\r\n\t\t\tif (poly.options.editing && poly.options.editing.className) {\r\n\t\t\t\tif (poly.options.original.className) {\r\n\t\t\t\t\tpoly.options.original.className.split(' ').forEach(function (className) {\r\n\t\t\t\t\t\tL.DomUtil.removeClass(path, className);\r\n\t\t\t\t\t});\r\n\t\t\t\t}\r\n\t\t\t\tpoly.options.editing.className.split(' ').forEach(function (className) {\r\n\t\t\t\t\tL.DomUtil.addClass(path, className);\r\n\t\t\t\t});\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tpoly.setStyle(poly.options.editing);\r\n\r\n\t\tif (this._poly._map) {\r\n\r\n\t\t\tthis._map = this._poly._map; // Set map\r\n\r\n\t\t\tif (!this._markerGroup) {\r\n\t\t\t\tthis._initMarkers();\r\n\t\t\t}\r\n\t\t\tthis._poly._map.addLayer(this._markerGroup);\r\n\t\t}\r\n\t},\r\n\r\n\t// @method removeHooks(): void\r\n\t// Remove listener hooks from this handler.\r\n\tremoveHooks: function () {\r\n\t\tvar poly = this._poly;\r\n\t\tvar path = poly._path;\r\n\r\n\t\tif (path) {\r\n\t\t\tif (poly.options.editing && poly.options.editing.className) {\r\n\t\t\t\tpoly.options.editing.className.split(' ').forEach(function (className) {\r\n\t\t\t\t\tL.DomUtil.removeClass(path, className);\r\n\t\t\t\t});\r\n\t\t\t\tif (poly.options.original.className) {\r\n\t\t\t\t\tpoly.options.original.className.split(' ').forEach(function (className) {\r\n\t\t\t\t\t\tL.DomUtil.addClass(path, className);\r\n\t\t\t\t\t});\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tpoly.setStyle(poly.options.original);\r\n\r\n\t\tif (poly._map) {\r\n\t\t\tpoly._map.removeLayer(this._markerGroup);\r\n\t\t\tdelete this._markerGroup;\r\n\t\t\tdelete this._markers;\r\n\t\t}\r\n\t},\r\n\r\n\t// @method updateMarkers(): void\r\n\t// Clear markers and update their location\r\n\tupdateMarkers: function () {\r\n\t\tthis._markerGroup.clearLayers();\r\n\t\tthis._initMarkers();\r\n\t},\r\n\r\n\t_initMarkers: function () {\r\n\t\tif (!this._markerGroup) {\r\n\t\t\tthis._markerGroup = new L.LayerGroup();\r\n\t\t}\r\n\t\tthis._markers = [];\r\n\r\n\t\tvar latlngs = this._defaultShape(),\r\n\t\t\ti, j, len, marker;\r\n\r\n\t\tfor (i = 0, len = latlngs.length; i < len; i++) {\r\n\r\n\t\t\tmarker = this._createMarker(latlngs[i], i);\r\n\t\t\tmarker.on('click', this._onMarkerClick, this);\r\n\t\t\tmarker.on('contextmenu', this._onContextMenu, this);\r\n\t\t\tthis._markers.push(marker);\r\n\t\t}\r\n\r\n\t\tvar markerLeft, markerRight;\r\n\r\n\t\tfor (i = 0, j = len - 1; i < len; j = i++) {\r\n\t\t\tif (i === 0 && !(L.Polygon && (this._poly instanceof L.Polygon))) {\r\n\t\t\t\tcontinue;\r\n\t\t\t}\r\n\r\n\t\t\tmarkerLeft = this._markers[j];\r\n\t\t\tmarkerRight = this._markers[i];\r\n\r\n\t\t\tthis._createMiddleMarker(markerLeft, markerRight);\r\n\t\t\tthis._updatePrevNext(markerLeft, markerRight);\r\n\t\t}\r\n\t},\r\n\r\n\t_createMarker: function (latlng, index) {\r\n\t\t// Extending L.Marker in TouchEvents.js to include touch.\r\n\t\tvar marker = new L.Marker.Touch(latlng, {\r\n\t\t\tdraggable: true,\r\n\t\t\ticon: this.options.icon,\r\n\t\t});\r\n\r\n\t\tmarker._origLatLng = latlng;\r\n\t\tmarker._index = index;\r\n\r\n\t\tmarker\r\n\t\t\t.on('dragstart', this._onMarkerDragStart, this)\r\n\t\t\t.on('drag', this._onMarkerDrag, this)\r\n\t\t\t.on('dragend', this._fireEdit, this)\r\n\t\t\t.on('touchmove', this._onTouchMove, this)\r\n\t\t\t.on('touchend', this._fireEdit, this)\r\n\t\t\t.on('MSPointerMove', this._onTouchMove, this)\r\n\t\t\t.on('MSPointerUp', this._fireEdit, this);\r\n\r\n\t\tthis._markerGroup.addLayer(marker);\r\n\r\n\t\treturn marker;\r\n\t},\r\n\r\n\t_onMarkerDragStart: function () {\r\n\t\tthis._poly.fire('editstart');\r\n\t},\r\n\r\n\t_spliceLatLngs: function () {\r\n\t\tvar latlngs = this._defaultShape();\r\n\t\tvar removed = [].splice.apply(latlngs, arguments);\r\n\t\tthis._poly._convertLatLngs(latlngs, true);\r\n\t\tthis._poly.redraw();\r\n\t\treturn removed;\r\n\t},\r\n\r\n\t_removeMarker: function (marker) {\r\n\t\tvar i = marker._index;\r\n\r\n\t\tthis._markerGroup.removeLayer(marker);\r\n\t\tthis._markers.splice(i, 1);\r\n\t\tthis._spliceLatLngs(i, 1);\r\n\t\tthis._updateIndexes(i, -1);\r\n\r\n\t\tmarker\r\n\t\t\t.off('dragstart', this._onMarkerDragStart, this)\r\n\t\t\t.off('drag', this._onMarkerDrag, this)\r\n\t\t\t.off('dragend', this._fireEdit, this)\r\n\t\t\t.off('touchmove', this._onMarkerDrag, this)\r\n\t\t\t.off('touchend', this._fireEdit, this)\r\n\t\t\t.off('click', this._onMarkerClick, this)\r\n\t\t\t.off('MSPointerMove', this._onTouchMove, this)\r\n\t\t\t.off('MSPointerUp', this._fireEdit, this);\r\n\t},\r\n\r\n\t_fireEdit: function () {\r\n\t\tthis._poly.edited = true;\r\n\t\tthis._poly.fire('edit');\r\n\t\tthis._poly._map.fire(L.Draw.Event.EDITVERTEX, {layers: this._markerGroup, poly: this._poly});\r\n\t},\r\n\r\n\t_onMarkerDrag: function (e) {\r\n\t\tvar marker = e.target;\r\n\t\tvar poly = this._poly;\r\n\r\n\t\tvar oldOrigLatLng = L.LatLngUtil.cloneLatLng(marker._origLatLng);\r\n\t\tL.extend(marker._origLatLng, marker._latlng);\r\n\t\tif (poly.options.poly) {\r\n\t\t\tvar tooltip = poly._map._editTooltip; // Access the tooltip\r\n\r\n\t\t\t// If we don't allow intersections and the polygon intersects\r\n\t\t\tif (!poly.options.poly.allowIntersection && poly.intersects()) {\r\n\t\t\t\tL.extend(marker._origLatLng, oldOrigLatLng);\r\n\t\t\t\tmarker.setLatLng(oldOrigLatLng);\r\n\t\t\t\tvar originalColor = poly.options.color;\r\n\t\t\t\tpoly.setStyle({color: this.options.drawError.color});\r\n\t\t\t\tif (tooltip) {\r\n\t\t\t\t\ttooltip.updateContent({\r\n\t\t\t\t\t\ttext: L.drawLocal.draw.handlers.polyline.error\r\n\t\t\t\t\t});\r\n\t\t\t\t}\r\n\r\n\t\t\t\t// Reset everything back to normal after a second\r\n\t\t\t\tsetTimeout(function () {\r\n\t\t\t\t\tpoly.setStyle({color: originalColor});\r\n\t\t\t\t\tif (tooltip) {\r\n\t\t\t\t\t\ttooltip.updateContent({\r\n\t\t\t\t\t\t\ttext: L.drawLocal.edit.handlers.edit.tooltip.text,\r\n\t\t\t\t\t\t\tsubtext: L.drawLocal.edit.handlers.edit.tooltip.subtext\r\n\t\t\t\t\t\t});\r\n\t\t\t\t\t}\r\n\t\t\t\t}, 1000);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (marker._middleLeft) {\r\n\t\t\tmarker._middleLeft.setLatLng(this._getMiddleLatLng(marker._prev, marker));\r\n\t\t}\r\n\t\tif (marker._middleRight) {\r\n\t\t\tmarker._middleRight.setLatLng(this._getMiddleLatLng(marker, marker._next));\r\n\t\t}\r\n\r\n\t\t//refresh the bounds when draging\r\n\t\tthis._poly._bounds._southWest = L.latLng(Infinity, Infinity);\r\n\t\tthis._poly._bounds._northEast = L.latLng(-Infinity, -Infinity);\r\n\t\tvar latlngs = this._poly.getLatLngs();\r\n\t\tthis._poly._convertLatLngs(latlngs, true);\r\n\t\tthis._poly.redraw();\r\n\t\tthis._poly.fire('editdrag');\r\n\t},\r\n\r\n\t_onMarkerClick: function (e) {\r\n\r\n\t\tvar minPoints = L.Polygon && (this._poly instanceof L.Polygon) ? 4 : 3,\r\n\t\t\tmarker = e.target;\r\n\r\n\t\t// If removing this point would create an invalid polyline/polygon don't remove\r\n\t\tif (this._defaultShape().length < minPoints) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\t// remove the marker\r\n\t\tthis._removeMarker(marker);\r\n\r\n\t\t// update prev/next links of adjacent markers\r\n\t\tthis._updatePrevNext(marker._prev, marker._next);\r\n\r\n\t\t// remove ghost markers near the removed marker\r\n\t\tif (marker._middleLeft) {\r\n\t\t\tthis._markerGroup.removeLayer(marker._middleLeft);\r\n\t\t}\r\n\t\tif (marker._middleRight) {\r\n\t\t\tthis._markerGroup.removeLayer(marker._middleRight);\r\n\t\t}\r\n\r\n\t\t// create a ghost marker in place of the removed one\r\n\t\tif (marker._prev && marker._next) {\r\n\t\t\tthis._createMiddleMarker(marker._prev, marker._next);\r\n\r\n\t\t} else if (!marker._prev) {\r\n\t\t\tmarker._next._middleLeft = null;\r\n\r\n\t\t} else if (!marker._next) {\r\n\t\t\tmarker._prev._middleRight = null;\r\n\t\t}\r\n\r\n\t\tthis._fireEdit();\r\n\t},\r\n\r\n\t_onContextMenu: function (e) {\r\n\t\tvar marker = e.target;\r\n\t\tvar poly = this._poly;\r\n\t\tthis._poly._map.fire(L.Draw.Event.MARKERCONTEXT, {marker: marker, layers: this._markerGroup, poly: this._poly});\r\n\t\tL.DomEvent.stopPropagation;\r\n\t},\r\n\r\n\t_onTouchMove: function (e) {\r\n\r\n\t\tvar layerPoint = this._map.mouseEventToLayerPoint(e.originalEvent.touches[0]),\r\n\t\t\tlatlng = this._map.layerPointToLatLng(layerPoint),\r\n\t\t\tmarker = e.target;\r\n\r\n\t\tL.extend(marker._origLatLng, latlng);\r\n\r\n\t\tif (marker._middleLeft) {\r\n\t\t\tmarker._middleLeft.setLatLng(this._getMiddleLatLng(marker._prev, marker));\r\n\t\t}\r\n\t\tif (marker._middleRight) {\r\n\t\t\tmarker._middleRight.setLatLng(this._getMiddleLatLng(marker, marker._next));\r\n\t\t}\r\n\r\n\t\tthis._poly.redraw();\r\n\t\tthis.updateMarkers();\r\n\t},\r\n\r\n\t_updateIndexes: function (index, delta) {\r\n\t\tthis._markerGroup.eachLayer(function (marker) {\r\n\t\t\tif (marker._index > index) {\r\n\t\t\t\tmarker._index += delta;\r\n\t\t\t}\r\n\t\t});\r\n\t},\r\n\r\n\t_createMiddleMarker: function (marker1, marker2) {\r\n\t\tvar latlng = this._getMiddleLatLng(marker1, marker2),\r\n\t\t\tmarker = this._createMarker(latlng),\r\n\t\t\tonClick,\r\n\t\t\tonDragStart,\r\n\t\t\tonDragEnd;\r\n\r\n\t\tmarker.setOpacity(0.6);\r\n\r\n\t\tmarker1._middleRight = marker2._middleLeft = marker;\r\n\r\n\t\tonDragStart = function () {\r\n\t\t\tmarker.off('touchmove', onDragStart, this);\r\n\t\t\tvar i = marker2._index;\r\n\r\n\t\t\tmarker._index = i;\r\n\r\n\t\t\tmarker\r\n\t\t\t\t.off('click', onClick, this)\r\n\t\t\t\t.on('click', this._onMarkerClick, this);\r\n\r\n\t\t\tlatlng.lat = marker.getLatLng().lat;\r\n\t\t\tlatlng.lng = marker.getLatLng().lng;\r\n\t\t\tthis._spliceLatLngs(i, 0, latlng);\r\n\t\t\tthis._markers.splice(i, 0, marker);\r\n\r\n\t\t\tmarker.setOpacity(1);\r\n\r\n\t\t\tthis._updateIndexes(i, 1);\r\n\t\t\tmarker2._index++;\r\n\t\t\tthis._updatePrevNext(marker1, marker);\r\n\t\t\tthis._updatePrevNext(marker, marker2);\r\n\r\n\t\t\tthis._poly.fire('editstart');\r\n\t\t};\r\n\r\n\t\tonDragEnd = function () {\r\n\t\t\tmarker.off('dragstart', onDragStart, this);\r\n\t\t\tmarker.off('dragend', onDragEnd, this);\r\n\t\t\tmarker.off('touchmove', onDragStart, this);\r\n\r\n\t\t\tthis._createMiddleMarker(marker1, marker);\r\n\t\t\tthis._createMiddleMarker(marker, marker2);\r\n\t\t};\r\n\r\n\t\tonClick = function () {\r\n\t\t\tonDragStart.call(this);\r\n\t\t\tonDragEnd.call(this);\r\n\t\t\tthis._fireEdit();\r\n\t\t};\r\n\r\n\t\tmarker\r\n\t\t\t.on('click', onClick, this)\r\n\t\t\t.on('dragstart', onDragStart, this)\r\n\t\t\t.on('dragend', onDragEnd, this)\r\n\t\t\t.on('touchmove', onDragStart, this);\r\n\r\n\t\tthis._markerGroup.addLayer(marker);\r\n\t},\r\n\r\n\t_updatePrevNext: function (marker1, marker2) {\r\n\t\tif (marker1) {\r\n\t\t\tmarker1._next = marker2;\r\n\t\t}\r\n\t\tif (marker2) {\r\n\t\t\tmarker2._prev = marker1;\r\n\t\t}\r\n\t},\r\n\r\n\t_getMiddleLatLng: function (marker1, marker2) {\r\n\t\tvar map = this._poly._map,\r\n\t\t\tp1 = map.project(marker1.getLatLng()),\r\n\t\t\tp2 = map.project(marker2.getLatLng());\r\n\r\n\t\treturn map.unproject(p1._add(p2)._divideBy(2));\r\n\t}\r\n});\r\n\r\nL.Polyline.addInitHook(function () {\r\n\r\n\t// Check to see if handler has already been initialized. This is to support versions of Leaflet that still have L.Handler.PolyEdit\r\n\tif (this.editing) {\r\n\t\treturn;\r\n\t}\r\n\r\n\tif (L.Edit.Poly) {\r\n\r\n\t\tthis.editing = new L.Edit.Poly(this);\r\n\r\n\t\tif (this.options.editable) {\r\n\t\t\tthis.editing.enable();\r\n\t\t}\r\n\t}\r\n\r\n\tthis.on('add', function () {\r\n\t\tif (this.editing && this.editing.enabled()) {\r\n\t\t\tthis.editing.addHooks();\r\n\t\t}\r\n\t});\r\n\r\n\tthis.on('remove', function () {\r\n\t\tif (this.editing && this.editing.enabled()) {\r\n\t\t\tthis.editing.removeHooks();\r\n\t\t}\r\n\t});\r\n});\r\n","L.Edit = L.Edit || {};\r\n/**\r\n * @class L.Edit.SimpleShape\r\n * @aka Edit.SimpleShape\r\n */\r\nL.Edit.SimpleShape = L.Handler.extend({\r\n\toptions: {\r\n\t\tmoveIcon: new L.DivIcon({\r\n\t\t\ticonSize: new L.Point(8, 8),\r\n\t\t\tclassName: 'leaflet-div-icon leaflet-editing-icon leaflet-edit-move'\r\n\t\t}),\r\n\t\tresizeIcon: new L.DivIcon({\r\n\t\t\ticonSize: new L.Point(8, 8),\r\n\t\t\tclassName: 'leaflet-div-icon leaflet-editing-icon leaflet-edit-resize'\r\n\t\t}),\r\n\t\ttouchMoveIcon: new L.DivIcon({\r\n\t\t\ticonSize: new L.Point(20, 20),\r\n\t\t\tclassName: 'leaflet-div-icon leaflet-editing-icon leaflet-edit-move leaflet-touch-icon'\r\n\t\t}),\r\n\t\ttouchResizeIcon: new L.DivIcon({\r\n\t\t\ticonSize: new L.Point(20, 20),\r\n\t\t\tclassName: 'leaflet-div-icon leaflet-editing-icon leaflet-edit-resize leaflet-touch-icon'\r\n\t\t}),\r\n\t},\r\n\r\n\t// @method intialize(): void\r\n\tinitialize: function (shape, options) {\r\n\t\t// if touch, switch to touch icon\r\n\t\tif (L.Browser.touch) {\r\n\t\t\tthis.options.moveIcon = this.options.touchMoveIcon;\r\n\t\t\tthis.options.resizeIcon = this.options.touchResizeIcon;\r\n\t\t}\r\n\r\n\t\tthis._shape = shape;\r\n\t\tL.Util.setOptions(this, options);\r\n\t},\r\n\r\n\t// @method addHooks(): void\r\n\t// Add listener hooks to this handler\r\n\taddHooks: function () {\r\n\t\tvar shape = this._shape;\r\n\t\tif (this._shape._map) {\r\n\t\t\tthis._map = this._shape._map;\r\n\t\t\tshape.setStyle(shape.options.editing);\r\n\r\n\t\t\tif (shape._map) {\r\n\t\t\t\tthis._map = shape._map;\r\n\t\t\t\tif (!this._markerGroup) {\r\n\t\t\t\t\tthis._initMarkers();\r\n\t\t\t\t}\r\n\t\t\t\tthis._map.addLayer(this._markerGroup);\r\n\t\t\t}\r\n\t\t}\r\n\t},\r\n\r\n\t// @method removeHooks(): void\r\n\t// Remove listener hooks from this handler\r\n\tremoveHooks: function () {\r\n\t\tvar shape = this._shape;\r\n\r\n\t\tshape.setStyle(shape.options.original);\r\n\r\n\t\tif (shape._map) {\r\n\t\t\tthis._unbindMarker(this._moveMarker);\r\n\r\n\t\t\tfor (var i = 0, l = this._resizeMarkers.length; i < l; i++) {\r\n\t\t\t\tthis._unbindMarker(this._resizeMarkers[i]);\r\n\t\t\t}\r\n\t\t\tthis._resizeMarkers = null;\r\n\r\n\t\t\tthis._map.removeLayer(this._markerGroup);\r\n\t\t\tdelete this._markerGroup;\r\n\t\t}\r\n\r\n\t\tthis._map = null;\r\n\t},\r\n\r\n\t// @method updateMarkers(): void\r\n\t// Remove the edit markers from this layer\r\n\tupdateMarkers: function () {\r\n\t\tthis._markerGroup.clearLayers();\r\n\t\tthis._initMarkers();\r\n\t},\r\n\r\n\t_initMarkers: function () {\r\n\t\tif (!this._markerGroup) {\r\n\t\t\tthis._markerGroup = new L.LayerGroup();\r\n\t\t}\r\n\r\n\t\t// Create center marker\r\n\t\tthis._createMoveMarker();\r\n\r\n\t\t// Create edge marker\r\n\t\tthis._createResizeMarker();\r\n\t},\r\n\r\n\t_createMoveMarker: function () {\r\n\t\t// Children override\r\n\t},\r\n\r\n\t_createResizeMarker: function () {\r\n\t\t// Children override\r\n\t},\r\n\r\n\t_createMarker: function (latlng, icon) {\r\n\t\t// Extending L.Marker in TouchEvents.js to include touch.\r\n\t\tvar marker = new L.Marker.Touch(latlng, {\r\n\t\t\tdraggable: true,\r\n\t\t\ticon: icon,\r\n\t\t\tzIndexOffset: 10\r\n\t\t});\r\n\r\n\t\tthis._bindMarker(marker);\r\n\r\n\t\tthis._markerGroup.addLayer(marker);\r\n\r\n\t\treturn marker;\r\n\t},\r\n\r\n\t_bindMarker: function (marker) {\r\n\t\tmarker\r\n\t\t\t.on('dragstart', this._onMarkerDragStart, this)\r\n\t\t\t.on('drag', this._onMarkerDrag, this)\r\n\t\t\t.on('dragend', this._onMarkerDragEnd, this)\r\n\t\t\t.on('touchstart', this._onTouchStart, this)\r\n\t\t\t.on('touchmove', this._onTouchMove, this)\r\n\t\t\t.on('MSPointerMove', this._onTouchMove, this)\r\n\t\t\t.on('touchend', this._onTouchEnd, this)\r\n\t\t\t.on('MSPointerUp', this._onTouchEnd, this);\r\n\t},\r\n\r\n\t_unbindMarker: function (marker) {\r\n\t\tmarker\r\n\t\t\t.off('dragstart', this._onMarkerDragStart, this)\r\n\t\t\t.off('drag', this._onMarkerDrag, this)\r\n\t\t\t.off('dragend', this._onMarkerDragEnd, this)\r\n\t\t\t.off('touchstart', this._onTouchStart, this)\r\n\t\t\t.off('touchmove', this._onTouchMove, this)\r\n\t\t\t.off('MSPointerMove', this._onTouchMove, this)\r\n\t\t\t.off('touchend', this._onTouchEnd, this)\r\n\t\t\t.off('MSPointerUp', this._onTouchEnd, this);\r\n\t},\r\n\r\n\t_onMarkerDragStart: function (e) {\r\n\t\tvar marker = e.target;\r\n\t\tmarker.setOpacity(0);\r\n\r\n\t\tthis._shape.fire('editstart');\r\n\t},\r\n\r\n\t_fireEdit: function () {\r\n\t\tthis._shape.edited = true;\r\n\t\tthis._shape.fire('edit');\r\n\t},\r\n\r\n\t_onMarkerDrag: function (e) {\r\n\t\tvar marker = e.target,\r\n\t\t\tlatlng = marker.getLatLng();\r\n\r\n\t\tif (marker === this._moveMarker) {\r\n\t\t\tthis._move(latlng);\r\n\t\t} else {\r\n\t\t\tthis._resize(latlng);\r\n\t\t}\r\n\r\n\t\tthis._shape.redraw();\r\n\t\tthis._shape.fire('editdrag');\r\n\t},\r\n\r\n\t_onMarkerDragEnd: function (e) {\r\n\t\tvar marker = e.target;\r\n\t\tmarker.setOpacity(1);\r\n\r\n\t\tthis._fireEdit();\r\n\t},\r\n\r\n\t_onTouchStart: function (e) {\r\n\t\tL.Edit.SimpleShape.prototype._onMarkerDragStart.call(this, e);\r\n\r\n\t\tif (typeof(this._getCorners) === 'function') {\r\n\t\t\t// Save a reference to the opposite point\r\n\t\t\tvar corners = this._getCorners(),\r\n\t\t\t\tmarker = e.target,\r\n\t\t\t\tcurrentCornerIndex = marker._cornerIndex;\r\n\r\n\t\t\tmarker.setOpacity(0);\r\n\r\n\t\t\t// Copyed from Edit.Rectangle.js line 23 _onMarkerDragStart()\r\n\t\t\t// Latlng is null otherwise.\r\n\t\t\tthis._oppositeCorner = corners[(currentCornerIndex + 2) % 4];\r\n\t\t\tthis._toggleCornerMarkers(0, currentCornerIndex);\r\n\t\t}\r\n\r\n\t\tthis._shape.fire('editstart');\r\n\t},\r\n\r\n\t_onTouchMove: function (e) {\r\n\t\tvar layerPoint = this._map.mouseEventToLayerPoint(e.originalEvent.touches[0]),\r\n\t\t\tlatlng = this._map.layerPointToLatLng(layerPoint),\r\n\t\t\tmarker = e.target;\r\n\r\n\t\tif (marker === this._moveMarker) {\r\n\t\t\tthis._move(latlng);\r\n\t\t} else {\r\n\t\t\tthis._resize(latlng);\r\n\t\t}\r\n\r\n\t\tthis._shape.redraw();\r\n\r\n\t\t// prevent touchcancel in IOS\r\n\t\t// e.preventDefault();\r\n\t\treturn false;\r\n\t},\r\n\r\n\t_onTouchEnd: function (e) {\r\n\t\tvar marker = e.target;\r\n\t\tmarker.setOpacity(1);\r\n\t\tthis.updateMarkers();\r\n\t\tthis._fireEdit();\r\n\t},\r\n\r\n\t_move: function () {\r\n\t\t// Children override\r\n\t},\r\n\r\n\t_resize: function () {\r\n\t\t// Children override\r\n\t}\r\n});\r\n","L.Edit = L.Edit || {};\r\n/**\r\n * @class L.Edit.Rectangle\r\n * @aka Edit.Rectangle\r\n * @inherits L.Edit.SimpleShape\r\n */\r\nL.Edit.Rectangle = L.Edit.SimpleShape.extend({\r\n\t_createMoveMarker: function () {\r\n\t\tvar bounds = this._shape.getBounds(),\r\n\t\t\tcenter = bounds.getCenter();\r\n\r\n\t\tthis._moveMarker = this._createMarker(center, this.options.moveIcon);\r\n\t},\r\n\r\n\t_createResizeMarker: function () {\r\n\t\tvar corners = this._getCorners();\r\n\r\n\t\tthis._resizeMarkers = [];\r\n\r\n\t\tfor (var i = 0, l = corners.length; i < l; i++) {\r\n\t\t\tthis._resizeMarkers.push(this._createMarker(corners[i], this.options.resizeIcon));\r\n\t\t\t// Monkey in the corner index as we will need to know this for dragging\r\n\t\t\tthis._resizeMarkers[i]._cornerIndex = i;\r\n\t\t}\r\n\t},\r\n\r\n\t_onMarkerDragStart: function (e) {\r\n\t\tL.Edit.SimpleShape.prototype._onMarkerDragStart.call(this, e);\r\n\r\n\t\t// Save a reference to the opposite point\r\n\t\tvar corners = this._getCorners(),\r\n\t\t\tmarker = e.target,\r\n\t\t\tcurrentCornerIndex = marker._cornerIndex;\r\n\r\n\t\tthis._oppositeCorner = corners[(currentCornerIndex + 2) % 4];\r\n\r\n\t\tthis._toggleCornerMarkers(0, currentCornerIndex);\r\n\t},\r\n\r\n\t_onMarkerDragEnd: function (e) {\r\n\t\tvar marker = e.target,\r\n\t\t\tbounds, center;\r\n\r\n\t\t// Reset move marker position to the center\r\n\t\tif (marker === this._moveMarker) {\r\n\t\t\tbounds = this._shape.getBounds();\r\n\t\t\tcenter = bounds.getCenter();\r\n\r\n\t\t\tmarker.setLatLng(center);\r\n\t\t}\r\n\r\n\t\tthis._toggleCornerMarkers(1);\r\n\r\n\t\tthis._repositionCornerMarkers();\r\n\r\n\t\tL.Edit.SimpleShape.prototype._onMarkerDragEnd.call(this, e);\r\n\t},\r\n\r\n\t_move: function (newCenter) {\r\n\t\tvar latlngs = this._shape._defaultShape ? this._shape._defaultShape() : this._shape.getLatLngs(),\r\n\t\t\tbounds = this._shape.getBounds(),\r\n\t\t\tcenter = bounds.getCenter(),\r\n\t\t\toffset, newLatLngs = [];\r\n\r\n\t\t// Offset the latlngs to the new center\r\n\t\tfor (var i = 0, l = latlngs.length; i < l; i++) {\r\n\t\t\toffset = [latlngs[i].lat - center.lat, latlngs[i].lng - center.lng];\r\n\t\t\tnewLatLngs.push([newCenter.lat + offset[0], newCenter.lng + offset[1]]);\r\n\t\t}\r\n\r\n\t\tthis._shape.setLatLngs(newLatLngs);\r\n\r\n\t\t// Reposition the resize markers\r\n\t\tthis._repositionCornerMarkers();\r\n\r\n\t\tthis._map.fire(L.Draw.Event.EDITMOVE, {layer: this._shape});\r\n\t},\r\n\r\n\t_resize: function (latlng) {\r\n\t\tvar bounds;\r\n\r\n\t\t// Update the shape based on the current position of this corner and the opposite point\r\n\t\tthis._shape.setBounds(L.latLngBounds(latlng, this._oppositeCorner));\r\n\r\n\t\t// Reposition the move marker\r\n\t\tbounds = this._shape.getBounds();\r\n\t\tthis._moveMarker.setLatLng(bounds.getCenter());\r\n\r\n\t\tthis._map.fire(L.Draw.Event.EDITRESIZE, {layer: this._shape});\r\n\t},\r\n\r\n\t_getCorners: function () {\r\n\t\tvar bounds = this._shape.getBounds(),\r\n\t\t\tnw = bounds.getNorthWest(),\r\n\t\t\tne = bounds.getNorthEast(),\r\n\t\t\tse = bounds.getSouthEast(),\r\n\t\t\tsw = bounds.getSouthWest();\r\n\r\n\t\treturn [nw, ne, se, sw];\r\n\t},\r\n\r\n\t_toggleCornerMarkers: function (opacity) {\r\n\t\tfor (var i = 0, l = this._resizeMarkers.length; i < l; i++) {\r\n\t\t\tthis._resizeMarkers[i].setOpacity(opacity);\r\n\t\t}\r\n\t},\r\n\r\n\t_repositionCornerMarkers: function () {\r\n\t\tvar corners = this._getCorners();\r\n\r\n\t\tfor (var i = 0, l = this._resizeMarkers.length; i < l; i++) {\r\n\t\t\tthis._resizeMarkers[i].setLatLng(corners[i]);\r\n\t\t}\r\n\t}\r\n});\r\n\r\nL.Rectangle.addInitHook(function () {\r\n\tif (L.Edit.Rectangle) {\r\n\t\tthis.editing = new L.Edit.Rectangle(this);\r\n\r\n\t\tif (this.options.editable) {\r\n\t\t\tthis.editing.enable();\r\n\t\t}\r\n\t}\r\n});\r\n","L.Edit = L.Edit || {};\r\n/**\r\n * @class L.Edit.CircleMarker\r\n * @aka Edit.Circle\r\n * @inherits L.Edit.SimpleShape\r\n */\r\nL.Edit.CircleMarker = L.Edit.SimpleShape.extend({\r\n\t_createMoveMarker: function () {\r\n\t\tvar center = this._shape.getLatLng();\r\n\t\tthis._map._editTooltip = new L.Draw.Tooltip(this._map);\r\n\t\tthis._moveMarker = this._createMarker(center, this.options.moveIcon);\r\n\t},\r\n\r\n\t_createResizeMarker: function () {\r\n\t\t// To avoid an undefined check in L.Edit.SimpleShape.removeHooks\r\n\t\tthis._resizeMarkers = [];\r\n\t},\r\n\r\n\t_move: function (latlng) {\r\n\t\tif (this._resizeMarkers.length) {\r\n\t\t\tvar resizemarkerPoint = this._getResizeMarkerPoint(latlng);\r\n\t\t\t// Move the resize marker\r\n\t\t\tthis._resizeMarkers[0].setLatLng(resizemarkerPoint);\r\n\t\t}\r\n\r\n\t\t// Move the circle\r\n\t\tthis._shape.setLatLng(latlng);\r\n\r\n\t\tthis._map.fire(L.Draw.Event.EDITMOVE, {layer: this._shape});\r\n\t},\r\n});\r\n\r\nL.CircleMarker.addInitHook(function () {\r\n\tif (L.Edit.CircleMarker) {\r\n\t\tthis.editing = new L.Edit.CircleMarker(this);\r\n\r\n\t\tif (this.options.editable) {\r\n\t\t\tthis.editing.enable();\r\n\t\t}\r\n\t}\r\n\r\n\tthis.on('add', function () {\r\n\t\tif (this.editing && this.editing.enabled()) {\r\n\t\t\tthis.editing.addHooks();\r\n\t\t}\r\n\t});\r\n\r\n\tthis.on('remove', function () {\r\n\t\tif (this.editing && this.editing.enabled()) {\r\n\t\t\tthis.editing.removeHooks();\r\n\t\t}\r\n\t});\r\n});\r\n","L.Edit = L.Edit || {};\r\n/**\r\n * @class L.Edit.Circle\r\n * @aka Edit.Circle\r\n * @inherits L.Edit.CircleMarker\r\n */\r\nL.Edit.Circle = L.Edit.CircleMarker.extend({\r\n\r\n\t_createResizeMarker: function () {\r\n\t\tvar center = this._shape.getLatLng(),\r\n\t\t\tresizemarkerPoint = this._getResizeMarkerPoint(center);\r\n\r\n\t\tthis._resizeMarkers = [];\r\n\t\tthis._resizeMarkers.push(this._createMarker(resizemarkerPoint, this.options.resizeIcon));\r\n\t},\r\n\r\n\t_getResizeMarkerPoint: function (latlng) {\r\n\t\t// From L.shape.getBounds()\r\n\t\tvar delta = this._shape._radius * Math.cos(Math.PI / 4),\r\n\t\t\tpoint = this._map.project(latlng);\r\n\t\treturn this._map.unproject([point.x + delta, point.y - delta]);\r\n\t},\r\n\r\n\t_resize: function (latlng) {\r\n\t\tvar moveLatLng = this._moveMarker.getLatLng();\r\n\r\n\t\t// Calculate the radius based on the version\r\n\t\tif (L.GeometryUtil.isVersion07x()) {\r\n\t\t\tradius = moveLatLng.distanceTo(latlng);\r\n\t\t} else {\r\n\t\t\tradius = this._map.distance(moveLatLng, latlng);\r\n\t\t}\r\n\t\tthis._shape.setRadius(radius);\r\n\r\n\t\tif (this._map.editTooltip) {\r\n\t\t\tthis._map._editTooltip.updatePosition(latlng);\r\n\t\t\tthis._map._editTooltip.updateContent({\r\n\t\t\t\ttext: L.drawLocal.edit.handlers.edit.tooltip.subtext + '
' + L.drawLocal.edit.handlers.edit.tooltip.text,\r\n\t\t\t\tsubtext: L.drawLocal.draw.handlers.circle.radius + ': ' +\r\n\t\t\t\tL.GeometryUtil.readableDistance(radius, true, this.options.feet, this.options.nautic)\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\tthis._shape.setRadius(radius);\r\n\r\n\t\tthis._map.fire(L.Draw.Event.EDITRESIZE, {layer: this._shape});\r\n\t}\r\n});\r\n\r\nL.Circle.addInitHook(function () {\r\n\tif (L.Edit.Circle) {\r\n\t\tthis.editing = new L.Edit.Circle(this);\r\n\r\n\t\tif (this.options.editable) {\r\n\t\t\tthis.editing.enable();\r\n\t\t}\r\n\t}\r\n});\r\n","L.Map.mergeOptions({\r\n\ttouchExtend: true\r\n});\r\n\r\n/**\r\n * @class L.Map.TouchExtend\r\n * @aka TouchExtend\r\n */\r\nL.Map.TouchExtend = L.Handler.extend({\r\n\r\n\t// @method initialize(): void\r\n\t// Sets TouchExtend private accessor variables\r\n\tinitialize: function (map) {\r\n\t\tthis._map = map;\r\n\t\tthis._container = map._container;\r\n\t\tthis._pane = map._panes.overlayPane;\r\n\t},\r\n\r\n\t// @method addHooks(): void\r\n\t// Adds dom listener events to the map container\r\n\taddHooks: function () {\r\n\t\tL.DomEvent.on(this._container, 'touchstart', this._onTouchStart, this);\r\n\t\tL.DomEvent.on(this._container, 'touchend', this._onTouchEnd, this);\r\n\t\tL.DomEvent.on(this._container, 'touchmove', this._onTouchMove, this);\r\n\t\tif (this._detectIE()) {\r\n\t\t\tL.DomEvent.on(this._container, 'MSPointerDown', this._onTouchStart, this);\r\n\t\t\tL.DomEvent.on(this._container, 'MSPointerUp', this._onTouchEnd, this);\r\n\t\t\tL.DomEvent.on(this._container, 'MSPointerMove', this._onTouchMove, this);\r\n\t\t\tL.DomEvent.on(this._container, 'MSPointerCancel', this._onTouchCancel, this);\r\n\r\n\t\t} else {\r\n\t\t\tL.DomEvent.on(this._container, 'touchcancel', this._onTouchCancel, this);\r\n\t\t\tL.DomEvent.on(this._container, 'touchleave', this._onTouchLeave, this);\r\n\t\t}\r\n\t},\r\n\r\n\t// @method removeHooks(): void\r\n\t// Removes dom listener events from the map container\r\n\tremoveHooks: function () {\r\n\t\tL.DomEvent.off(this._container, 'touchstart', this._onTouchStart, this);\r\n\t\tL.DomEvent.off(this._container, 'touchend', this._onTouchEnd, this);\r\n\t\tL.DomEvent.off(this._container, 'touchmove', this._onTouchMove, this);\r\n\t\tif (this._detectIE()) {\r\n\t\t\tL.DomEvent.off(this._container, 'MSPointerDown', this._onTouchStart, this);\r\n\t\t\tL.DomEvent.off(this._container, 'MSPointerUp', this._onTouchEnd, this);\r\n\t\t\tL.DomEvent.off(this._container, 'MSPointerMove', this._onTouchMove, this);\r\n\t\t\tL.DomEvent.off(this._container, 'MSPointerCancel', this._onTouchCancel, this);\r\n\t\t} else {\r\n\t\t\tL.DomEvent.off(this._container, 'touchcancel', this._onTouchCancel, this);\r\n\t\t\tL.DomEvent.off(this._container, 'touchleave', this._onTouchLeave, this);\r\n\t\t}\r\n\t},\r\n\r\n\t_touchEvent: function (e, type) {\r\n\t\t// #TODO: fix the pageX error that is do a bug in Android where a single touch triggers two click events\r\n\t\t// _filterClick is what leaflet uses as a workaround.\r\n\t\t// This is a problem with more things than just android. Another problem is touchEnd has no touches in\r\n\t\t// its touch list.\r\n\t\tvar touchEvent = {};\r\n\t\tif (typeof e.touches !== 'undefined') {\r\n\t\t\tif (!e.touches.length) {\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\t\t\ttouchEvent = e.touches[0];\r\n\t\t} else if (e.pointerType === 'touch') {\r\n\t\t\ttouchEvent = e;\r\n\t\t\tif (!this._filterClick(e)) {\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\t\t} else {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tvar containerPoint = this._map.mouseEventToContainerPoint(touchEvent),\r\n\t\t\tlayerPoint = this._map.mouseEventToLayerPoint(touchEvent),\r\n\t\t\tlatlng = this._map.layerPointToLatLng(layerPoint);\r\n\r\n\t\tthis._map.fire(type, {\r\n\t\t\tlatlng: latlng,\r\n\t\t\tlayerPoint: layerPoint,\r\n\t\t\tcontainerPoint: containerPoint,\r\n\t\t\tpageX: touchEvent.pageX,\r\n\t\t\tpageY: touchEvent.pageY,\r\n\t\t\toriginalEvent: e\r\n\t\t});\r\n\t},\r\n\r\n\t/** Borrowed from Leaflet and modified for bool ops **/\r\n\t_filterClick: function (e) {\r\n\t\tvar timeStamp = (e.timeStamp || e.originalEvent.timeStamp),\r\n\t\t\telapsed = L.DomEvent._lastClick && (timeStamp - L.DomEvent._lastClick);\r\n\r\n\t\t// are they closer together than 500ms yet more than 100ms?\r\n\t\t// Android typically triggers them ~300ms apart while multiple listeners\r\n\t\t// on the same event should be triggered far faster;\r\n\t\t// or check if click is simulated on the element, and if it is, reject any non-simulated events\r\n\t\tif ((elapsed && elapsed > 100 && elapsed < 500) || (e.target._simulatedClick && !e._simulated)) {\r\n\t\t\tL.DomEvent.stop(e);\r\n\t\t\treturn false;\r\n\t\t}\r\n\t\tL.DomEvent._lastClick = timeStamp;\r\n\t\treturn true;\r\n\t},\r\n\r\n\t_onTouchStart: function (e) {\r\n\t\tif (!this._map._loaded) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tvar type = 'touchstart';\r\n\t\tthis._touchEvent(e, type);\r\n\r\n\t},\r\n\r\n\t_onTouchEnd: function (e) {\r\n\t\tif (!this._map._loaded) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tvar type = 'touchend';\r\n\t\tthis._touchEvent(e, type);\r\n\t},\r\n\r\n\t_onTouchCancel: function (e) {\r\n\t\tif (!this._map._loaded) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tvar type = 'touchcancel';\r\n\t\tif (this._detectIE()) {\r\n\t\t\ttype = 'pointercancel';\r\n\t\t}\r\n\t\tthis._touchEvent(e, type);\r\n\t},\r\n\r\n\t_onTouchLeave: function (e) {\r\n\t\tif (!this._map._loaded) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tvar type = 'touchleave';\r\n\t\tthis._touchEvent(e, type);\r\n\t},\r\n\r\n\t_onTouchMove: function (e) {\r\n\t\tif (!this._map._loaded) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tvar type = 'touchmove';\r\n\t\tthis._touchEvent(e, type);\r\n\t},\r\n\r\n\t_detectIE: function () {\r\n\t\tvar ua = window.navigator.userAgent;\r\n\r\n\t\tvar msie = ua.indexOf('MSIE ');\r\n\t\tif (msie > 0) {\r\n\t\t\t// IE 10 or older => return version number\r\n\t\t\treturn parseInt(ua.substring(msie + 5, ua.indexOf('.', msie)), 10);\r\n\t\t}\r\n\r\n\t\tvar trident = ua.indexOf('Trident/');\r\n\t\tif (trident > 0) {\r\n\t\t\t// IE 11 => return version number\r\n\t\t\tvar rv = ua.indexOf('rv:');\r\n\t\t\treturn parseInt(ua.substring(rv + 3, ua.indexOf('.', rv)), 10);\r\n\t\t}\r\n\r\n\t\tvar edge = ua.indexOf('Edge/');\r\n\t\tif (edge > 0) {\r\n\t\t\t// IE 12 => return version number\r\n\t\t\treturn parseInt(ua.substring(edge + 5, ua.indexOf('.', edge)), 10);\r\n\t\t}\r\n\r\n\t\t// other browser\r\n\t\treturn false;\r\n\t}\r\n});\r\n\r\nL.Map.addInitHook('addHandler', 'touchExtend', L.Map.TouchExtend);\r\n\r\n\r\n/**\r\n * @class L.Marker.Touch\r\n * @aka Marker.Touch\r\n *\r\n * This isn't full Touch support. This is just to get markers to also support dom touch events after creation\r\n * #TODO: find a better way of getting markers to support touch.\r\n */\r\nL.Marker.Touch = L.Marker.extend({\r\n\r\n\t_initInteraction: function () {\r\n\t\tif (!this.addInteractiveTarget) {\r\n\t\t\t// 0.7.x support\r\n\t\t\treturn this._initInteractionLegacy();\r\n\t\t}\r\n\t\t// TODO this may need be updated to re-add touch events for 1.0+\r\n\t\treturn L.Marker.prototype._initInteraction.apply(this);\r\n\t},\r\n\r\n\t// This is an exact copy of https://github.com/Leaflet/Leaflet/blob/v0.7/src/layer/marker/Marker.js\r\n\t// with the addition of the touch events\r\n\t_initInteractionLegacy: function () {\r\n\r\n\t\tif (!this.options.clickable) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\t// TODO refactor into something shared with Map/Path/etc. to DRY it up\r\n\r\n\t\tvar icon = this._icon,\r\n\t\t\tevents = ['dblclick',\r\n\t\t\t\t'mousedown',\r\n\t\t\t\t'mouseover',\r\n\t\t\t\t'mouseout',\r\n\t\t\t\t'contextmenu',\r\n\t\t\t\t'touchstart',\r\n\t\t\t\t'touchend',\r\n\t\t\t\t'touchmove'];\r\n\t\tif (this._detectIE) {\r\n\t\t\tevents.concat(['MSPointerDown',\r\n\t\t\t\t'MSPointerUp',\r\n\t\t\t\t'MSPointerMove',\r\n\t\t\t\t'MSPointerCancel']);\r\n\t\t} else {\r\n\t\t\tevents.concat(['touchcancel']);\r\n\t\t}\r\n\r\n\t\tL.DomUtil.addClass(icon, 'leaflet-clickable');\r\n\t\tL.DomEvent.on(icon, 'click', this._onMouseClick, this);\r\n\t\tL.DomEvent.on(icon, 'keypress', this._onKeyPress, this);\r\n\r\n\t\tfor (var i = 0; i < events.length; i++) {\r\n\t\t\tL.DomEvent.on(icon, events[i], this._fireMouseEvent, this);\r\n\t\t}\r\n\r\n\t\tif (L.Handler.MarkerDrag) {\r\n\t\t\tthis.dragging = new L.Handler.MarkerDrag(this);\r\n\r\n\t\t\tif (this.options.draggable) {\r\n\t\t\t\tthis.dragging.enable();\r\n\t\t\t}\r\n\t\t}\r\n\t},\r\n\r\n\t_detectIE: function () {\r\n\t\tvar ua = window.navigator.userAgent;\r\n\r\n\t\tvar msie = ua.indexOf('MSIE ');\r\n\t\tif (msie > 0) {\r\n\t\t\t// IE 10 or older => return version number\r\n\t\t\treturn parseInt(ua.substring(msie + 5, ua.indexOf('.', msie)), 10);\r\n\t\t}\r\n\r\n\t\tvar trident = ua.indexOf('Trident/');\r\n\t\tif (trident > 0) {\r\n\t\t\t// IE 11 => return version number\r\n\t\t\tvar rv = ua.indexOf('rv:');\r\n\t\t\treturn parseInt(ua.substring(rv + 3, ua.indexOf('.', rv)), 10);\r\n\t\t}\r\n\r\n\t\tvar edge = ua.indexOf('Edge/');\r\n\t\tif (edge > 0) {\r\n\t\t\t// IE 12 => return version number\r\n\t\t\treturn parseInt(ua.substring(edge + 5, ua.indexOf('.', edge)), 10);\r\n\t\t}\r\n\r\n\t\t// other browser\r\n\t\treturn false;\r\n\t}\r\n});\r\n","/**\r\n * @class L.LatLngUtil\r\n * @aka LatLngUtil\r\n */\r\nL.LatLngUtil = {\r\n\t// Clones a LatLngs[], returns [][]\r\n\r\n\t// @method cloneLatLngs(LatLngs[]): L.LatLngs[]\r\n\t// Clone the latLng point or points or nested points and return an array with those points\r\n\tcloneLatLngs: function (latlngs) {\r\n\t\tvar clone = [];\r\n\t\tfor (var i = 0, l = latlngs.length; i < l; i++) {\r\n\t\t\t// Check for nested array (Polyline/Polygon)\r\n\t\t\tif (Array.isArray(latlngs[i])) {\r\n\t\t\t\tclone.push(L.LatLngUtil.cloneLatLngs(latlngs[i]));\r\n\t\t\t} else {\r\n\t\t\t\tclone.push(this.cloneLatLng(latlngs[i]));\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn clone;\r\n\t},\r\n\r\n\t// @method cloneLatLng(LatLng): L.LatLng\r\n\t// Clone the latLng and return a new LatLng object.\r\n\tcloneLatLng: function (latlng) {\r\n\t\treturn L.latLng(latlng.lat, latlng.lng);\r\n\t}\r\n};\r\n","(function () {\r\n\r\n\tvar defaultPrecision = {\r\n\t\tkm: 2,\r\n\t\tha: 2,\r\n\t\tm: 0,\r\n\t\tmi: 2,\r\n\t\tac: 2,\r\n\t\tyd: 0,\r\n\t\tft: 0,\r\n\t\tnm: 2\r\n\t};\r\n\r\n\r\n\t/**\r\n\t * @class L.GeometryUtil\r\n\t * @aka GeometryUtil\r\n\t */\r\n\tL.GeometryUtil = L.extend(L.GeometryUtil || {}, {\r\n\t\t// Ported from the OpenLayers implementation. See https://github.com/openlayers/openlayers/blob/master/lib/OpenLayers/Geometry/LinearRing.js#L270\r\n\r\n\t\t// @method geodesicArea(): number\r\n\t\tgeodesicArea: function (latLngs) {\r\n\t\t\tvar pointsCount = latLngs.length,\r\n\t\t\t\tarea = 0.0,\r\n\t\t\t\td2r = Math.PI / 180,\r\n\t\t\t\tp1, p2;\r\n\r\n\t\t\tif (pointsCount > 2) {\r\n\t\t\t\tfor (var i = 0; i < pointsCount; i++) {\r\n\t\t\t\t\tp1 = latLngs[i];\r\n\t\t\t\t\tp2 = latLngs[(i + 1) % pointsCount];\r\n\t\t\t\t\tarea += ((p2.lng - p1.lng) * d2r) *\r\n\t\t\t\t\t\t(2 + Math.sin(p1.lat * d2r) + Math.sin(p2.lat * d2r));\r\n\t\t\t\t}\r\n\t\t\t\tarea = area * 6378137.0 * 6378137.0 / 2.0;\r\n\t\t\t}\r\n\r\n\t\t\treturn Math.abs(area);\r\n\t\t},\r\n\r\n\t\t// @method formattedNumber(n, precision): string\r\n\t\t// Returns n in specified number format (if defined) and precision\r\n\t\tformattedNumber: function (n, precision) {\r\n\t\t\tvar formatted = parseFloat(n).toFixed(precision),\r\n\t\t\t\tformat = L.drawLocal.format && L.drawLocal.format.numeric,\r\n\t\t\t\tdelimiters = format && format.delimiters,\r\n\t\t\t\tthousands = delimiters && delimiters.thousands,\r\n\t\t\t\tdecimal = delimiters && delimiters.decimal;\r\n\r\n\t\t\tif (thousands || decimal) {\r\n\t\t\t\tvar splitValue = formatted.split('.');\r\n\t\t\t\tformatted = thousands ? splitValue[0].replace(/(\\d)(?=(\\d{3})+(?!\\d))/g, '$1' + thousands) : splitValue[0];\r\n\t\t\t\tdecimal = decimal || '.';\r\n\t\t\t\tif (splitValue.length > 1) {\r\n\t\t\t\t\tformatted = formatted + decimal + splitValue[1];\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\treturn formatted;\r\n\t\t},\r\n\r\n\t\t// @method readableArea(area, isMetric, precision): string\r\n\t\t// Returns a readable area string in yards or metric.\r\n\t\t// The value will be rounded as defined by the precision option object.\r\n\t\treadableArea: function (area, isMetric, precision) {\r\n\t\t\tvar areaStr,\r\n\t\t\t\tunits,\r\n\t\t\t\tprecision = L.Util.extend({}, defaultPrecision, precision);\r\n\r\n\t\t\tif (isMetric) {\r\n\t\t\t\tunits = ['ha', 'm'];\r\n\t\t\t\ttype = typeof isMetric;\r\n\t\t\t\tif (type === 'string') {\r\n\t\t\t\t\tunits = [isMetric];\r\n\t\t\t\t} else if (type !== 'boolean') {\r\n\t\t\t\t\tunits = isMetric;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif (area >= 1000000 && units.indexOf('km') !== -1) {\r\n\t\t\t\t\tareaStr = L.GeometryUtil.formattedNumber(area * 0.000001, precision['km']) + ' km²';\r\n\t\t\t\t} else if (area >= 10000 && units.indexOf('ha') !== -1) {\r\n\t\t\t\t\tareaStr = L.GeometryUtil.formattedNumber(area * 0.0001, precision['ha']) + ' ha';\r\n\t\t\t\t} else {\r\n\t\t\t\t\tareaStr = L.GeometryUtil.formattedNumber(area, precision['m']) + ' m²';\r\n\t\t\t\t}\r\n\t\t\t} else {\r\n\t\t\t\tarea /= 0.836127; // Square yards in 1 meter\r\n\r\n\t\t\t\tif (area >= 3097600) { //3097600 square yards in 1 square mile\r\n\t\t\t\t\tareaStr = L.GeometryUtil.formattedNumber(area / 3097600, precision['mi']) + ' mi²';\r\n\t\t\t\t} else if (area >= 4840) { //4840 square yards in 1 acre\r\n\t\t\t\t\tareaStr = L.GeometryUtil.formattedNumber(area / 4840, precision['ac']) + ' acres';\r\n\t\t\t\t} else {\r\n\t\t\t\t\tareaStr = L.GeometryUtil.formattedNumber(area, precision['yd']) + ' yd²';\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\treturn areaStr;\r\n\t\t},\r\n\r\n\t\t// @method readableDistance(distance, units): string\r\n\t\t// Converts a metric distance to one of [ feet, nauticalMile, metric or yards ] string\r\n\t\t//\r\n\t\t// @alternative\r\n\t\t// @method readableDistance(distance, isMetric, useFeet, isNauticalMile, precision): string\r\n\t\t// Converts metric distance to distance string.\r\n\t\t// The value will be rounded as defined by the precision option object.\r\n\t\treadableDistance: function (distance, isMetric, isFeet, isNauticalMile, precision) {\r\n\t\t\tvar distanceStr,\r\n\t\t\t\tunits,\r\n\t\t\t\tprecision = L.Util.extend({}, defaultPrecision, precision);\r\n\r\n\t\t\tif (isMetric) {\r\n\t\t\t\tunits = typeof isMetric == 'string' ? isMetric : 'metric';\r\n\t\t\t} else if (isFeet) {\r\n\t\t\t\tunits = 'feet';\r\n\t\t\t} else if (isNauticalMile) {\r\n\t\t\t\tunits = 'nauticalMile';\r\n\t\t\t} else {\r\n\t\t\t\tunits = 'yards';\r\n\t\t\t}\r\n\r\n\t\t\tswitch (units) {\r\n\t\t\t\tcase 'metric':\r\n\t\t\t\t\t// show metres when distance is < 1km, then show km\r\n\t\t\t\t\tif (distance > 1000) {\r\n\t\t\t\t\t\tdistanceStr = L.GeometryUtil.formattedNumber(distance / 1000, precision['km']) + ' km';\r\n\t\t\t\t\t} else {\r\n\t\t\t\t\t\tdistanceStr = L.GeometryUtil.formattedNumber(distance, precision['m']) + ' m';\r\n\t\t\t\t\t}\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase 'feet':\r\n\t\t\t\t\tdistance *= 1.09361 * 3;\r\n\t\t\t\t\tdistanceStr = L.GeometryUtil.formattedNumber(distance, precision['ft']) + ' ft';\r\n\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase 'nauticalMile':\r\n\t\t\t\t\tdistance *= 0.53996;\r\n\t\t\t\t\tdistanceStr = L.GeometryUtil.formattedNumber(distance / 1000, precision['nm']) + ' nm';\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase 'yards':\r\n\t\t\t\tdefault:\r\n\t\t\t\t\tdistance *= 1.09361;\r\n\r\n\t\t\t\t\tif (distance > 1760) {\r\n\t\t\t\t\t\tdistanceStr = L.GeometryUtil.formattedNumber(distance / 1760, precision['mi']) + ' miles';\r\n\t\t\t\t\t} else {\r\n\t\t\t\t\t\tdistanceStr = L.GeometryUtil.formattedNumber(distance, precision['yd']) + ' yd';\r\n\t\t\t\t\t}\r\n\t\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t\treturn distanceStr;\r\n\t\t},\r\n\r\n\t\t// @method isVersion07x(): boolean\r\n\t\t// Returns true if the Leaflet version is 0.7.x, false otherwise.\r\n\t\tisVersion07x: function () {\r\n\t\t\tvar version = L.version.split('.');\r\n\t\t\t//If Version is == 0.7.*\r\n\t\t\treturn parseInt(version[0], 10) === 0 && parseInt(version[1], 10) === 7;\r\n\t\t},\r\n\t});\r\n\r\n})();\r\n","/**\r\n * @class L.LineUtil\r\n * @aka Util\r\n * @aka L.Utils\r\n */\r\nL.Util.extend(L.LineUtil, {\r\n\r\n\t// @method segmentsIntersect(): boolean\r\n\t// Checks to see if two line segments intersect. Does not handle degenerate cases.\r\n\t// http://compgeom.cs.uiuc.edu/~jeffe/teaching/373/notes/x06-sweepline.pdf\r\n\tsegmentsIntersect: function (/*Point*/ p, /*Point*/ p1, /*Point*/ p2, /*Point*/ p3) {\r\n\t\treturn this._checkCounterclockwise(p, p2, p3) !==\r\n\t\t\tthis._checkCounterclockwise(p1, p2, p3) &&\r\n\t\t\tthis._checkCounterclockwise(p, p1, p2) !==\r\n\t\t\tthis._checkCounterclockwise(p, p1, p3);\r\n\t},\r\n\r\n\t// check to see if points are in counterclockwise order\r\n\t_checkCounterclockwise: function (/*Point*/ p, /*Point*/ p1, /*Point*/ p2) {\r\n\t\treturn (p2.y - p.y) * (p1.x - p.x) > (p1.y - p.y) * (p2.x - p.x);\r\n\t}\r\n});\r\n","/**\r\n * @class L.Polyline\r\n * @aka Polyline\r\n */\r\nL.Polyline.include({\r\n\r\n\t// @method intersects(): boolean\r\n\t// Check to see if this polyline has any linesegments that intersect.\r\n\t// NOTE: does not support detecting intersection for degenerate cases.\r\n\tintersects: function () {\r\n\t\tvar points = this._getProjectedPoints(),\r\n\t\t\tlen = points ? points.length : 0,\r\n\t\t\ti, p, p1;\r\n\r\n\t\tif (this._tooFewPointsForIntersection()) {\r\n\t\t\treturn false;\r\n\t\t}\r\n\r\n\t\tfor (i = len - 1; i >= 3; i--) {\r\n\t\t\tp = points[i - 1];\r\n\t\t\tp1 = points[i];\r\n\r\n\r\n\t\t\tif (this._lineSegmentsIntersectsRange(p, p1, i - 2)) {\r\n\t\t\t\treturn true;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn false;\r\n\t},\r\n\r\n\t// @method newLatLngIntersects(): boolean\r\n\t// Check for intersection if new latlng was added to this polyline.\r\n\t// NOTE: does not support detecting intersection for degenerate cases.\r\n\tnewLatLngIntersects: function (latlng, skipFirst) {\r\n\t\t// Cannot check a polyline for intersecting lats/lngs when not added to the map\r\n\t\tif (!this._map) {\r\n\t\t\treturn false;\r\n\t\t}\r\n\r\n\t\treturn this.newPointIntersects(this._map.latLngToLayerPoint(latlng), skipFirst);\r\n\t},\r\n\r\n\t// @method newPointIntersects(): boolean\r\n\t// Check for intersection if new point was added to this polyline.\r\n\t// newPoint must be a layer point.\r\n\t// NOTE: does not support detecting intersection for degenerate cases.\r\n\tnewPointIntersects: function (newPoint, skipFirst) {\r\n\t\tvar points = this._getProjectedPoints(),\r\n\t\t\tlen = points ? points.length : 0,\r\n\t\t\tlastPoint = points ? points[len - 1] : null,\r\n\t\t\t// The previous previous line segment. Previous line segment doesn't need testing.\r\n\t\t\tmaxIndex = len - 2;\r\n\r\n\t\tif (this._tooFewPointsForIntersection(1)) {\r\n\t\t\treturn false;\r\n\t\t}\r\n\r\n\t\treturn this._lineSegmentsIntersectsRange(lastPoint, newPoint, maxIndex, skipFirst ? 1 : 0);\r\n\t},\r\n\r\n\t// Polylines with 2 sides can only intersect in cases where points are collinear (we don't support detecting these).\r\n\t// Cannot have intersection when < 3 line segments (< 4 points)\r\n\t_tooFewPointsForIntersection: function (extraPoints) {\r\n\t\tvar points = this._getProjectedPoints(),\r\n\t\t\tlen = points ? points.length : 0;\r\n\t\t// Increment length by extraPoints if present\r\n\t\tlen += extraPoints || 0;\r\n\r\n\t\treturn !points || len <= 3;\r\n\t},\r\n\r\n\t// Checks a line segment intersections with any line segments before its predecessor.\r\n\t// Don't need to check the predecessor as will never intersect.\r\n\t_lineSegmentsIntersectsRange: function (p, p1, maxIndex, minIndex) {\r\n\t\tvar points = this._getProjectedPoints(),\r\n\t\t\tp2, p3;\r\n\r\n\t\tminIndex = minIndex || 0;\r\n\r\n\t\t// Check all previous line segments (beside the immediately previous) for intersections\r\n\t\tfor (var j = maxIndex; j > minIndex; j--) {\r\n\t\t\tp2 = points[j - 1];\r\n\t\t\tp3 = points[j];\r\n\r\n\t\t\tif (L.LineUtil.segmentsIntersect(p, p1, p2, p3)) {\r\n\t\t\t\treturn true;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn false;\r\n\t},\r\n\r\n\t_getProjectedPoints: function () {\r\n\t\tif (!this._defaultShape) {\r\n\t\t\treturn this._originalPoints;\r\n\t\t}\r\n\t\tvar points = [],\r\n\t\t\t_shape = this._defaultShape();\r\n\r\n\t\tfor (var i = 0; i < _shape.length; i++) {\r\n\t\t\tpoints.push(this._map.latLngToLayerPoint(_shape[i]));\r\n\t\t}\r\n\t\treturn points;\r\n\t}\r\n});\r\n","/**\r\n * @class L.Polygon\r\n * @aka Polygon\r\n */\r\nL.Polygon.include({\r\n\r\n\t// @method intersects(): boolean\r\n\t// Checks a polygon for any intersecting line segments. Ignores holes.\r\n\tintersects: function () {\r\n\t\tvar polylineIntersects,\r\n\t\t\tpoints = this._getProjectedPoints(),\r\n\t\t\tlen, firstPoint, lastPoint, maxIndex;\r\n\r\n\t\tif (this._tooFewPointsForIntersection()) {\r\n\t\t\treturn false;\r\n\t\t}\r\n\r\n\t\tpolylineIntersects = L.Polyline.prototype.intersects.call(this);\r\n\r\n\t\t// If already found an intersection don't need to check for any more.\r\n\t\tif (polylineIntersects) {\r\n\t\t\treturn true;\r\n\t\t}\r\n\r\n\t\tlen = points.length;\r\n\t\tfirstPoint = points[0];\r\n\t\tlastPoint = points[len - 1];\r\n\t\tmaxIndex = len - 2;\r\n\r\n\t\t// Check the line segment between last and first point. Don't need to check the first line segment (minIndex = 1)\r\n\t\treturn this._lineSegmentsIntersectsRange(lastPoint, firstPoint, maxIndex, 1);\r\n\t}\r\n});\r\n","/**\r\n * @class L.Control.Draw\r\n * @aka L.Draw\r\n */\r\nL.Control.Draw = L.Control.extend({\r\n\r\n\t// Options\r\n\toptions: {\r\n\t\tposition: 'topleft',\r\n\t\tdraw: {},\r\n\t\tedit: false\r\n\t},\r\n\r\n\t// @method initialize(): void\r\n\t// Initializes draw control, toolbars from the options\r\n\tinitialize: function (options) {\r\n\t\tif (L.version < '0.7') {\r\n\t\t\tthrow new Error('Leaflet.draw 0.2.3+ requires Leaflet 0.7.0+. Download latest from https://github.com/Leaflet/Leaflet/');\r\n\t\t}\r\n\r\n\t\tL.Control.prototype.initialize.call(this, options);\r\n\r\n\t\tvar toolbar;\r\n\r\n\t\tthis._toolbars = {};\r\n\r\n\t\t// Initialize toolbars\r\n\t\tif (L.DrawToolbar && this.options.draw) {\r\n\t\t\ttoolbar = new L.DrawToolbar(this.options.draw);\r\n\r\n\t\t\tthis._toolbars[L.DrawToolbar.TYPE] = toolbar;\r\n\r\n\t\t\t// Listen for when toolbar is enabled\r\n\t\t\tthis._toolbars[L.DrawToolbar.TYPE].on('enable', this._toolbarEnabled, this);\r\n\t\t}\r\n\r\n\t\tif (L.EditToolbar && this.options.edit) {\r\n\t\t\ttoolbar = new L.EditToolbar(this.options.edit);\r\n\r\n\t\t\tthis._toolbars[L.EditToolbar.TYPE] = toolbar;\r\n\r\n\t\t\t// Listen for when toolbar is enabled\r\n\t\t\tthis._toolbars[L.EditToolbar.TYPE].on('enable', this._toolbarEnabled, this);\r\n\t\t}\r\n\t\tL.toolbar = this; //set global var for editing the toolbar\r\n\t},\r\n\r\n\t// @method onAdd(): container\r\n\t// Adds the toolbar container to the map\r\n\tonAdd: function (map) {\r\n\t\tvar container = L.DomUtil.create('div', 'leaflet-draw'),\r\n\t\t\taddedTopClass = false,\r\n\t\t\ttopClassName = 'leaflet-draw-toolbar-top',\r\n\t\t\ttoolbarContainer;\r\n\r\n\t\tfor (var toolbarId in this._toolbars) {\r\n\t\t\tif (this._toolbars.hasOwnProperty(toolbarId)) {\r\n\t\t\t\ttoolbarContainer = this._toolbars[toolbarId].addToolbar(map);\r\n\r\n\t\t\t\tif (toolbarContainer) {\r\n\t\t\t\t\t// Add class to the first toolbar to remove the margin\r\n\t\t\t\t\tif (!addedTopClass) {\r\n\t\t\t\t\t\tif (!L.DomUtil.hasClass(toolbarContainer, topClassName)) {\r\n\t\t\t\t\t\t\tL.DomUtil.addClass(toolbarContainer.childNodes[0], topClassName);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\taddedTopClass = true;\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tcontainer.appendChild(toolbarContainer);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn container;\r\n\t},\r\n\r\n\t// @method onRemove(): void\r\n\t// Removes the toolbars from the map toolbar container\r\n\tonRemove: function () {\r\n\t\tfor (var toolbarId in this._toolbars) {\r\n\t\t\tif (this._toolbars.hasOwnProperty(toolbarId)) {\r\n\t\t\t\tthis._toolbars[toolbarId].removeToolbar();\r\n\t\t\t}\r\n\t\t}\r\n\t},\r\n\r\n\t// @method setDrawingOptions(options): void\r\n\t// Sets options to all toolbar instances\r\n\tsetDrawingOptions: function (options) {\r\n\t\tfor (var toolbarId in this._toolbars) {\r\n\t\t\tif (this._toolbars[toolbarId] instanceof L.DrawToolbar) {\r\n\t\t\t\tthis._toolbars[toolbarId].setOptions(options);\r\n\t\t\t}\r\n\t\t}\r\n\t},\r\n\r\n\t_toolbarEnabled: function (e) {\r\n\t\tvar enabledToolbar = e.target;\r\n\r\n\t\tfor (var toolbarId in this._toolbars) {\r\n\t\t\tif (this._toolbars[toolbarId] !== enabledToolbar) {\r\n\t\t\t\tthis._toolbars[toolbarId].disable();\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n});\r\n\r\nL.Map.mergeOptions({\r\n\tdrawControlTooltips: true,\r\n\tdrawControl: false\r\n});\r\n\r\nL.Map.addInitHook(function () {\r\n\tif (this.options.drawControl) {\r\n\t\tthis.drawControl = new L.Control.Draw();\r\n\t\tthis.addControl(this.drawControl);\r\n\t}\r\n});\r\n","/**\r\n * @class L.Draw.Toolbar\r\n * @aka Toolbar\r\n *\r\n * The toolbar class of the API — it is used to create the ui\r\n * This will be depreciated\r\n *\r\n * @example\r\n *\r\n * ```js\r\n * var toolbar = L.Toolbar();\r\n * toolbar.addToolbar(map);\r\n * ```\r\n *\r\n * ### Disabling a toolbar\r\n *\r\n * If you do not want a particular toolbar in your app you can turn it off by setting the toolbar to false.\r\n *\r\n * ```js\r\n * var drawControl = new L.Control.Draw({\r\n * draw: false,\r\n * edit: {\r\n * featureGroup: editableLayers\r\n * }\r\n * });\r\n * ```\r\n *\r\n * ### Disabling a toolbar item\r\n *\r\n * If you want to turn off a particular toolbar item, set it to false. The following disables drawing polygons and\r\n * markers. It also turns off the ability to edit layers.\r\n *\r\n * ```js\r\n * var drawControl = new L.Control.Draw({\r\n * draw: {\r\n * polygon: false,\r\n * marker: false\r\n * },\r\n * edit: {\r\n * featureGroup: editableLayers,\r\n * edit: false\r\n * }\r\n * });\r\n * ```\r\n */\r\nL.Toolbar = L.Class.extend({\r\n\t// @section Methods for modifying the toolbar\r\n\r\n\t// @method initialize(options): void\r\n\t// Toolbar constructor\r\n\tinitialize: function (options) {\r\n\t\tL.setOptions(this, options);\r\n\r\n\t\tthis._modes = {};\r\n\t\tthis._actionButtons = [];\r\n\t\tthis._activeMode = null;\r\n\r\n\t\tvar version = L.version.split('.');\r\n\t\t//If Version is >= 1.2.0\r\n\t\tif (parseInt(version[0], 10) === 1 && parseInt(version[1], 10) >= 2) {\r\n\t\t\tL.Toolbar.include(L.Evented.prototype);\r\n\t\t} else {\r\n\t\t\tL.Toolbar.include(L.Mixin.Events);\r\n\t\t}\r\n\t},\r\n\r\n\t// @method enabled(): boolean\r\n\t// Gets a true/false of whether the toolbar is enabled\r\n\tenabled: function () {\r\n\t\treturn this._activeMode !== null;\r\n\t},\r\n\r\n\t// @method disable(): void\r\n\t// Disables the toolbar\r\n\tdisable: function () {\r\n\t\tif (!this.enabled()) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tthis._activeMode.handler.disable();\r\n\t},\r\n\r\n\t// @method addToolbar(map): L.DomUtil\r\n\t// Adds the toolbar to the map and returns the toolbar dom element\r\n\taddToolbar: function (map) {\r\n\t\tvar container = L.DomUtil.create('div', 'leaflet-draw-section'),\r\n\t\t\tbuttonIndex = 0,\r\n\t\t\tbuttonClassPrefix = this._toolbarClass || '',\r\n\t\t\tmodeHandlers = this.getModeHandlers(map),\r\n\t\t\ti;\r\n\r\n\t\tthis._toolbarContainer = L.DomUtil.create('div', 'leaflet-draw-toolbar leaflet-bar');\r\n\t\tthis._map = map;\r\n\r\n\t\tfor (i = 0; i < modeHandlers.length; i++) {\r\n\t\t\tif (modeHandlers[i].enabled) {\r\n\t\t\t\tthis._initModeHandler(\r\n\t\t\t\t\tmodeHandlers[i].handler,\r\n\t\t\t\t\tthis._toolbarContainer,\r\n\t\t\t\t\tbuttonIndex++,\r\n\t\t\t\t\tbuttonClassPrefix,\r\n\t\t\t\t\tmodeHandlers[i].title\r\n\t\t\t\t);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// if no buttons were added, do not add the toolbar\r\n\t\tif (!buttonIndex) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\t// Save button index of the last button, -1 as we would have ++ after the last button\r\n\t\tthis._lastButtonIndex = --buttonIndex;\r\n\r\n\t\t// Create empty actions part of the toolbar\r\n\t\tthis._actionsContainer = L.DomUtil.create('ul', 'leaflet-draw-actions');\r\n\r\n\t\t// Add draw and cancel containers to the control container\r\n\t\tcontainer.appendChild(this._toolbarContainer);\r\n\t\tcontainer.appendChild(this._actionsContainer);\r\n\r\n\t\treturn container;\r\n\t},\r\n\r\n\t// @method removeToolbar(): void\r\n\t// Removes the toolbar and drops the handler event listeners\r\n\tremoveToolbar: function () {\r\n\t\t// Dispose each handler\r\n\t\tfor (var handlerId in this._modes) {\r\n\t\t\tif (this._modes.hasOwnProperty(handlerId)) {\r\n\t\t\t\t// Unbind handler button\r\n\t\t\t\tthis._disposeButton(\r\n\t\t\t\t\tthis._modes[handlerId].button,\r\n\t\t\t\t\tthis._modes[handlerId].handler.enable,\r\n\t\t\t\t\tthis._modes[handlerId].handler\r\n\t\t\t\t);\r\n\r\n\t\t\t\t// Make sure is disabled\r\n\t\t\t\tthis._modes[handlerId].handler.disable();\r\n\r\n\t\t\t\t// Unbind handler\r\n\t\t\t\tthis._modes[handlerId].handler\r\n\t\t\t\t\t.off('enabled', this._handlerActivated, this)\r\n\t\t\t\t\t.off('disabled', this._handlerDeactivated, this);\r\n\t\t\t}\r\n\t\t}\r\n\t\tthis._modes = {};\r\n\r\n\t\t// Dispose the actions toolbar\r\n\t\tfor (var i = 0, l = this._actionButtons.length; i < l; i++) {\r\n\t\t\tthis._disposeButton(\r\n\t\t\t\tthis._actionButtons[i].button,\r\n\t\t\t\tthis._actionButtons[i].callback,\r\n\t\t\t\tthis\r\n\t\t\t);\r\n\t\t}\r\n\t\tthis._actionButtons = [];\r\n\t\tthis._actionsContainer = null;\r\n\t},\r\n\r\n\t_initModeHandler: function (handler, container, buttonIndex, classNamePredix, buttonTitle) {\r\n\t\tvar type = handler.type;\r\n\r\n\t\tthis._modes[type] = {};\r\n\r\n\t\tthis._modes[type].handler = handler;\r\n\r\n\t\tthis._modes[type].button = this._createButton({\r\n\t\t\ttype: type,\r\n\t\t\ttitle: buttonTitle,\r\n\t\t\tclassName: classNamePredix + '-' + type,\r\n\t\t\tcontainer: container,\r\n\t\t\tcallback: this._modes[type].handler.enable,\r\n\t\t\tcontext: this._modes[type].handler\r\n\t\t});\r\n\r\n\t\tthis._modes[type].buttonIndex = buttonIndex;\r\n\r\n\t\tthis._modes[type].handler\r\n\t\t\t.on('enabled', this._handlerActivated, this)\r\n\t\t\t.on('disabled', this._handlerDeactivated, this);\r\n\t},\r\n\r\n\t/* Detect iOS based on browser User Agent, based on:\r\n\t * http://stackoverflow.com/a/9039885 */\r\n\t_detectIOS: function () {\r\n\t\tvar iOS = (/iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream);\r\n\t\treturn iOS;\r\n\t},\r\n\r\n\t_createButton: function (options) {\r\n\r\n\t\tvar link = L.DomUtil.create('a', options.className || '', options.container);\r\n\t\t// Screen reader tag\r\n\t\tvar sr = L.DomUtil.create('span', 'sr-only', options.container);\r\n\r\n\t\tlink.href = '#';\r\n\t\tlink.appendChild(sr);\r\n\r\n\t\tif (options.title) {\r\n\t\t\tlink.title = options.title;\r\n\t\t\tsr.innerHTML = options.title;\r\n\t\t}\r\n\r\n\t\tif (options.text) {\r\n\t\t\tlink.innerHTML = options.text;\r\n\t\t\tsr.innerHTML = options.text;\r\n\t\t}\r\n\r\n\t\t/* iOS does not use click events */\r\n\t\tvar buttonEvent = this._detectIOS() ? 'touchstart' : 'click';\r\n\r\n\t\tL.DomEvent\r\n\t\t\t.on(link, 'click', L.DomEvent.stopPropagation)\r\n\t\t\t.on(link, 'mousedown', L.DomEvent.stopPropagation)\r\n\t\t\t.on(link, 'dblclick', L.DomEvent.stopPropagation)\r\n\t\t\t.on(link, 'touchstart', L.DomEvent.stopPropagation)\r\n\t\t\t.on(link, 'click', L.DomEvent.preventDefault)\r\n\t\t\t.on(link, buttonEvent, options.callback, options.context);\r\n\r\n\t\treturn link;\r\n\t},\r\n\r\n\t_disposeButton: function (button, callback) {\r\n\t\t/* iOS does not use click events */\r\n\t\tvar buttonEvent = this._detectIOS() ? 'touchstart' : 'click';\r\n\r\n\t\tL.DomEvent\r\n\t\t\t.off(button, 'click', L.DomEvent.stopPropagation)\r\n\t\t\t.off(button, 'mousedown', L.DomEvent.stopPropagation)\r\n\t\t\t.off(button, 'dblclick', L.DomEvent.stopPropagation)\r\n\t\t\t.off(button, 'touchstart', L.DomEvent.stopPropagation)\r\n\t\t\t.off(button, 'click', L.DomEvent.preventDefault)\r\n\t\t\t.off(button, buttonEvent, callback);\r\n\t},\r\n\r\n\t_handlerActivated: function (e) {\r\n\t\t// Disable active mode (if present)\r\n\t\tthis.disable();\r\n\r\n\t\t// Cache new active feature\r\n\t\tthis._activeMode = this._modes[e.handler];\r\n\r\n\t\tL.DomUtil.addClass(this._activeMode.button, 'leaflet-draw-toolbar-button-enabled');\r\n\r\n\t\tthis._showActionsToolbar();\r\n\r\n\t\tthis.fire('enable');\r\n\t},\r\n\r\n\t_handlerDeactivated: function () {\r\n\t\tthis._hideActionsToolbar();\r\n\r\n\t\tL.DomUtil.removeClass(this._activeMode.button, 'leaflet-draw-toolbar-button-enabled');\r\n\r\n\t\tthis._activeMode = null;\r\n\r\n\t\tthis.fire('disable');\r\n\t},\r\n\r\n\t_createActions: function (handler) {\r\n\t\tvar container = this._actionsContainer,\r\n\t\t\tbuttons = this.getActions(handler),\r\n\t\t\tl = buttons.length,\r\n\t\t\tli, di, dl, button;\r\n\r\n\t\t// Dispose the actions toolbar (todo: dispose only not used buttons)\r\n\t\tfor (di = 0, dl = this._actionButtons.length; di < dl; di++) {\r\n\t\t\tthis._disposeButton(this._actionButtons[di].button, this._actionButtons[di].callback);\r\n\t\t}\r\n\t\tthis._actionButtons = [];\r\n\r\n\t\t// Remove all old buttons\r\n\t\twhile (container.firstChild) {\r\n\t\t\tcontainer.removeChild(container.firstChild);\r\n\t\t}\r\n\r\n\t\tfor (var i = 0; i < l; i++) {\r\n\t\t\tif ('enabled' in buttons[i] && !buttons[i].enabled) {\r\n\t\t\t\tcontinue;\r\n\t\t\t}\r\n\r\n\t\t\tli = L.DomUtil.create('li', '', container);\r\n\r\n\t\t\tbutton = this._createButton({\r\n\t\t\t\ttitle: buttons[i].title,\r\n\t\t\t\ttext: buttons[i].text,\r\n\t\t\t\tcontainer: li,\r\n\t\t\t\tcallback: buttons[i].callback,\r\n\t\t\t\tcontext: buttons[i].context\r\n\t\t\t});\r\n\r\n\t\t\tthis._actionButtons.push({\r\n\t\t\t\tbutton: button,\r\n\t\t\t\tcallback: buttons[i].callback\r\n\t\t\t});\r\n\t\t}\r\n\t},\r\n\r\n\t_showActionsToolbar: function () {\r\n\t\tvar buttonIndex = this._activeMode.buttonIndex,\r\n\t\t\tlastButtonIndex = this._lastButtonIndex,\r\n\t\t\ttoolbarPosition = this._activeMode.button.offsetTop - 1;\r\n\r\n\t\t// Recreate action buttons on every click\r\n\t\tthis._createActions(this._activeMode.handler);\r\n\r\n\t\t// Correctly position the cancel button\r\n\t\tthis._actionsContainer.style.top = toolbarPosition + 'px';\r\n\r\n\t\tif (buttonIndex === 0) {\r\n\t\t\tL.DomUtil.addClass(this._toolbarContainer, 'leaflet-draw-toolbar-notop');\r\n\t\t\tL.DomUtil.addClass(this._actionsContainer, 'leaflet-draw-actions-top');\r\n\t\t}\r\n\r\n\t\tif (buttonIndex === lastButtonIndex) {\r\n\t\t\tL.DomUtil.addClass(this._toolbarContainer, 'leaflet-draw-toolbar-nobottom');\r\n\t\t\tL.DomUtil.addClass(this._actionsContainer, 'leaflet-draw-actions-bottom');\r\n\t\t}\r\n\r\n\t\tthis._actionsContainer.style.display = 'block';\r\n\t\tthis._map.fire(L.Draw.Event.TOOLBAROPENED);\r\n\t},\r\n\r\n\t_hideActionsToolbar: function () {\r\n\t\tthis._actionsContainer.style.display = 'none';\r\n\r\n\t\tL.DomUtil.removeClass(this._toolbarContainer, 'leaflet-draw-toolbar-notop');\r\n\t\tL.DomUtil.removeClass(this._toolbarContainer, 'leaflet-draw-toolbar-nobottom');\r\n\t\tL.DomUtil.removeClass(this._actionsContainer, 'leaflet-draw-actions-top');\r\n\t\tL.DomUtil.removeClass(this._actionsContainer, 'leaflet-draw-actions-bottom');\r\n\t\tthis._map.fire(L.Draw.Event.TOOLBARCLOSED);\r\n\t}\r\n});\r\n","L.Draw = L.Draw || {};\r\n/**\r\n * @class L.Draw.Tooltip\r\n * @aka Tooltip\r\n *\r\n * The tooltip class — it is used to display the tooltip while drawing\r\n * This will be depreciated\r\n *\r\n * @example\r\n *\r\n * ```js\r\n * var tooltip = L.Draw.Tooltip();\r\n * ```\r\n *\r\n */\r\nL.Draw.Tooltip = L.Class.extend({\r\n\r\n\t// @section Methods for modifying draw state\r\n\r\n\t// @method initialize(map): void\r\n\t// Tooltip constructor\r\n\tinitialize: function (map) {\r\n\t\tthis._map = map;\r\n\t\tthis._popupPane = map._panes.popupPane;\r\n\t\tthis._visible = false;\r\n\r\n\t\tthis._container = map.options.drawControlTooltips ?\r\n\t\t\tL.DomUtil.create('div', 'leaflet-draw-tooltip', this._popupPane) : null;\r\n\t\tthis._singleLineLabel = false;\r\n\r\n\t\tthis._map.on('mouseout', this._onMouseOut, this);\r\n\t},\r\n\r\n\t// @method dispose(): void\r\n\t// Remove Tooltip DOM and unbind events\r\n\tdispose: function () {\r\n\t\tthis._map.off('mouseout', this._onMouseOut, this);\r\n\r\n\t\tif (this._container) {\r\n\t\t\tthis._popupPane.removeChild(this._container);\r\n\t\t\tthis._container = null;\r\n\t\t}\r\n\t},\r\n\r\n\t// @method updateContent(labelText): this\r\n\t// Changes the tooltip text to string in function call\r\n\tupdateContent: function (labelText) {\r\n\t\tif (!this._container) {\r\n\t\t\treturn this;\r\n\t\t}\r\n\t\tlabelText.subtext = labelText.subtext || '';\r\n\r\n\t\t// update the vertical position (only if changed)\r\n\t\tif (labelText.subtext.length === 0 && !this._singleLineLabel) {\r\n\t\t\tL.DomUtil.addClass(this._container, 'leaflet-draw-tooltip-single');\r\n\t\t\tthis._singleLineLabel = true;\r\n\t\t}\r\n\t\telse if (labelText.subtext.length > 0 && this._singleLineLabel) {\r\n\t\t\tL.DomUtil.removeClass(this._container, 'leaflet-draw-tooltip-single');\r\n\t\t\tthis._singleLineLabel = false;\r\n\t\t}\r\n\r\n\t\tthis._container.innerHTML =\r\n\t\t\t(labelText.subtext.length > 0 ?\r\n\t\t\t\t'' + labelText.subtext + '' + '
' : '') +\r\n\t\t\t'' + labelText.text + '';\r\n\r\n\t\tif (!labelText.text && !labelText.subtext) {\r\n\t\t\tthis._visible = false;\r\n\t\t\tthis._container.style.visibility = 'hidden';\r\n\t\t} else {\r\n\t\t\tthis._visible = true;\r\n\t\t\tthis._container.style.visibility = 'inherit';\r\n\t\t}\r\n\r\n\t\treturn this;\r\n\t},\r\n\r\n\t// @method updatePosition(latlng): this\r\n\t// Changes the location of the tooltip\r\n\tupdatePosition: function (latlng) {\r\n\t\tvar pos = this._map.latLngToLayerPoint(latlng),\r\n\t\t\ttooltipContainer = this._container;\r\n\r\n\t\tif (this._container) {\r\n\t\t\tif (this._visible) {\r\n\t\t\t\ttooltipContainer.style.visibility = 'inherit';\r\n\t\t\t}\r\n\t\t\tL.DomUtil.setPosition(tooltipContainer, pos);\r\n\t\t}\r\n\r\n\t\treturn this;\r\n\t},\r\n\r\n\t// @method showAsError(): this\r\n\t// Applies error class to tooltip\r\n\tshowAsError: function () {\r\n\t\tif (this._container) {\r\n\t\t\tL.DomUtil.addClass(this._container, 'leaflet-error-draw-tooltip');\r\n\t\t}\r\n\t\treturn this;\r\n\t},\r\n\r\n\t// @method removeError(): this\r\n\t// Removes the error class from the tooltip\r\n\tremoveError: function () {\r\n\t\tif (this._container) {\r\n\t\t\tL.DomUtil.removeClass(this._container, 'leaflet-error-draw-tooltip');\r\n\t\t}\r\n\t\treturn this;\r\n\t},\r\n\r\n\t_onMouseOut: function () {\r\n\t\tif (this._container) {\r\n\t\t\tthis._container.style.visibility = 'hidden';\r\n\t\t}\r\n\t}\r\n});\r\n","/**\r\n * @class L.DrawToolbar\r\n * @aka Toolbar\r\n */\r\nL.DrawToolbar = L.Toolbar.extend({\r\n\r\n\tstatics: {\r\n\t\tTYPE: 'draw'\r\n\t},\r\n\r\n\toptions: {\r\n\t\tpolyline: {},\r\n\t\tpolygon: {},\r\n\t\trectangle: {},\r\n\t\tcircle: {},\r\n\t\tmarker: {},\r\n\t\tcirclemarker: {}\r\n\t},\r\n\r\n\t// @method initialize(): void\r\n\tinitialize: function (options) {\r\n\t\t// Ensure that the options are merged correctly since L.extend is only shallow\r\n\t\tfor (var type in this.options) {\r\n\t\t\tif (this.options.hasOwnProperty(type)) {\r\n\t\t\t\tif (options[type]) {\r\n\t\t\t\t\toptions[type] = L.extend({}, this.options[type], options[type]);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tthis._toolbarClass = 'leaflet-draw-draw';\r\n\t\tL.Toolbar.prototype.initialize.call(this, options);\r\n\t},\r\n\r\n\t// @method getModeHandlers(): object\r\n\t// Get mode handlers information\r\n\tgetModeHandlers: function (map) {\r\n\t\treturn [\r\n\t\t\t{\r\n\t\t\t\tenabled: this.options.polyline,\r\n\t\t\t\thandler: new L.Draw.Polyline(map, this.options.polyline),\r\n\t\t\t\ttitle: L.drawLocal.draw.toolbar.buttons.polyline\r\n\t\t\t},\r\n\t\t\t{\r\n\t\t\t\tenabled: this.options.polygon,\r\n\t\t\t\thandler: new L.Draw.Polygon(map, this.options.polygon),\r\n\t\t\t\ttitle: L.drawLocal.draw.toolbar.buttons.polygon\r\n\t\t\t},\r\n\t\t\t{\r\n\t\t\t\tenabled: this.options.rectangle,\r\n\t\t\t\thandler: new L.Draw.Rectangle(map, this.options.rectangle),\r\n\t\t\t\ttitle: L.drawLocal.draw.toolbar.buttons.rectangle\r\n\t\t\t},\r\n\t\t\t{\r\n\t\t\t\tenabled: this.options.circle,\r\n\t\t\t\thandler: new L.Draw.Circle(map, this.options.circle),\r\n\t\t\t\ttitle: L.drawLocal.draw.toolbar.buttons.circle\r\n\t\t\t},\r\n\t\t\t{\r\n\t\t\t\tenabled: this.options.marker,\r\n\t\t\t\thandler: new L.Draw.Marker(map, this.options.marker),\r\n\t\t\t\ttitle: L.drawLocal.draw.toolbar.buttons.marker\r\n\t\t\t},\r\n\t\t\t{\r\n\t\t\t\tenabled: this.options.circlemarker,\r\n\t\t\t\thandler: new L.Draw.CircleMarker(map, this.options.circlemarker),\r\n\t\t\t\ttitle: L.drawLocal.draw.toolbar.buttons.circlemarker\r\n\t\t\t}\r\n\t\t];\r\n\t},\r\n\r\n\t// @method getActions(): object\r\n\t// Get action information\r\n\tgetActions: function (handler) {\r\n\t\treturn [\r\n\t\t\t{\r\n\t\t\t\tenabled: handler.completeShape,\r\n\t\t\t\ttitle: L.drawLocal.draw.toolbar.finish.title,\r\n\t\t\t\ttext: L.drawLocal.draw.toolbar.finish.text,\r\n\t\t\t\tcallback: handler.completeShape,\r\n\t\t\t\tcontext: handler\r\n\t\t\t},\r\n\t\t\t{\r\n\t\t\t\tenabled: handler.deleteLastVertex,\r\n\t\t\t\ttitle: L.drawLocal.draw.toolbar.undo.title,\r\n\t\t\t\ttext: L.drawLocal.draw.toolbar.undo.text,\r\n\t\t\t\tcallback: handler.deleteLastVertex,\r\n\t\t\t\tcontext: handler\r\n\t\t\t},\r\n\t\t\t{\r\n\t\t\t\ttitle: L.drawLocal.draw.toolbar.actions.title,\r\n\t\t\t\ttext: L.drawLocal.draw.toolbar.actions.text,\r\n\t\t\t\tcallback: this.disable,\r\n\t\t\t\tcontext: this\r\n\t\t\t}\r\n\t\t];\r\n\t},\r\n\r\n\t// @method setOptions(): void\r\n\t// Sets the options to the toolbar\r\n\tsetOptions: function (options) {\r\n\t\tL.setOptions(this, options);\r\n\r\n\t\tfor (var type in this._modes) {\r\n\t\t\tif (this._modes.hasOwnProperty(type) && options.hasOwnProperty(type)) {\r\n\t\t\t\tthis._modes[type].handler.setOptions(options[type]);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n});\r\n","/*L.Map.mergeOptions({\r\n editControl: true\r\n });*/\r\n/**\r\n * @class L.EditToolbar\r\n * @aka EditToolbar\r\n */\r\nL.EditToolbar = L.Toolbar.extend({\r\n\tstatics: {\r\n\t\tTYPE: 'edit'\r\n\t},\r\n\r\n\toptions: {\r\n\t\tedit: {\r\n\t\t\tselectedPathOptions: {\r\n\t\t\t\tdashArray: '10, 10',\r\n\r\n\t\t\t\tfill: true,\r\n\t\t\t\tfillColor: '#fe57a1',\r\n\t\t\t\tfillOpacity: 0.1,\r\n\r\n\t\t\t\t// Whether to user the existing layers color\r\n\t\t\t\tmaintainColor: false\r\n\t\t\t}\r\n\t\t},\r\n\t\tremove: {},\r\n\t\tpoly: null,\r\n\t\tfeatureGroup: null /* REQUIRED! TODO: perhaps if not set then all layers on the map are selectable? */\r\n\t},\r\n\r\n\t// @method intialize(): void\r\n\tinitialize: function (options) {\r\n\t\t// Need to set this manually since null is an acceptable value here\r\n\t\tif (options.edit) {\r\n\t\t\tif (typeof options.edit.selectedPathOptions === 'undefined') {\r\n\t\t\t\toptions.edit.selectedPathOptions = this.options.edit.selectedPathOptions;\r\n\t\t\t}\r\n\t\t\toptions.edit.selectedPathOptions = L.extend({}, this.options.edit.selectedPathOptions, options.edit.selectedPathOptions);\r\n\t\t}\r\n\r\n\t\tif (options.remove) {\r\n\t\t\toptions.remove = L.extend({}, this.options.remove, options.remove);\r\n\t\t}\r\n\r\n\t\tif (options.poly) {\r\n\t\t\toptions.poly = L.extend({}, this.options.poly, options.poly);\r\n\t\t}\r\n\r\n\t\tthis._toolbarClass = 'leaflet-draw-edit';\r\n\t\tL.Toolbar.prototype.initialize.call(this, options);\r\n\r\n\t\tthis._selectedFeatureCount = 0;\r\n\t},\r\n\r\n\t// @method getModeHandlers(): object\r\n\t// Get mode handlers information\r\n\tgetModeHandlers: function (map) {\r\n\t\tvar featureGroup = this.options.featureGroup;\r\n\t\treturn [\r\n\t\t\t{\r\n\t\t\t\tenabled: this.options.edit,\r\n\t\t\t\thandler: new L.EditToolbar.Edit(map, {\r\n\t\t\t\t\tfeatureGroup: featureGroup,\r\n\t\t\t\t\tselectedPathOptions: this.options.edit.selectedPathOptions,\r\n\t\t\t\t\tpoly: this.options.poly\r\n\t\t\t\t}),\r\n\t\t\t\ttitle: L.drawLocal.edit.toolbar.buttons.edit\r\n\t\t\t},\r\n\t\t\t{\r\n\t\t\t\tenabled: this.options.remove,\r\n\t\t\t\thandler: new L.EditToolbar.Delete(map, {\r\n\t\t\t\t\tfeatureGroup: featureGroup\r\n\t\t\t\t}),\r\n\t\t\t\ttitle: L.drawLocal.edit.toolbar.buttons.remove\r\n\t\t\t}\r\n\t\t];\r\n\t},\r\n\r\n\t// @method getActions(): object\r\n\t// Get actions information\r\n\tgetActions: function (handler) {\r\n\t\tvar actions = [\r\n\t\t\t{\r\n\t\t\t\ttitle: L.drawLocal.edit.toolbar.actions.save.title,\r\n\t\t\t\ttext: L.drawLocal.edit.toolbar.actions.save.text,\r\n\t\t\t\tcallback: this._save,\r\n\t\t\t\tcontext: this\r\n\t\t\t},\r\n\t\t\t{\r\n\t\t\t\ttitle: L.drawLocal.edit.toolbar.actions.cancel.title,\r\n\t\t\t\ttext: L.drawLocal.edit.toolbar.actions.cancel.text,\r\n\t\t\t\tcallback: this.disable,\r\n\t\t\t\tcontext: this\r\n\t\t\t}\r\n\t\t];\r\n\r\n\t\tif (handler.removeAllLayers) {\r\n\t\t\tactions.push({\r\n\t\t\t\ttitle: L.drawLocal.edit.toolbar.actions.clearAll.title,\r\n\t\t\t\ttext: L.drawLocal.edit.toolbar.actions.clearAll.text,\r\n\t\t\t\tcallback: this._clearAllLayers,\r\n\t\t\t\tcontext: this\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\treturn actions;\r\n\t},\r\n\r\n\t// @method addToolbar(map): L.DomUtil\r\n\t// Adds the toolbar to the map\r\n\taddToolbar: function (map) {\r\n\t\tvar container = L.Toolbar.prototype.addToolbar.call(this, map);\r\n\r\n\t\tthis._checkDisabled();\r\n\r\n\t\tthis.options.featureGroup.on('layeradd layerremove', this._checkDisabled, this);\r\n\r\n\t\treturn container;\r\n\t},\r\n\r\n\t// @method removeToolbar(): void\r\n\t// Removes the toolbar from the map\r\n\tremoveToolbar: function () {\r\n\t\tthis.options.featureGroup.off('layeradd layerremove', this._checkDisabled, this);\r\n\r\n\t\tL.Toolbar.prototype.removeToolbar.call(this);\r\n\t},\r\n\r\n\t// @method disable(): void\r\n\t// Disables the toolbar\r\n\tdisable: function () {\r\n\t\tif (!this.enabled()) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tthis._activeMode.handler.revertLayers();\r\n\r\n\t\tL.Toolbar.prototype.disable.call(this);\r\n\t},\r\n\r\n\t_save: function () {\r\n\t\tthis._activeMode.handler.save();\r\n\t\tif (this._activeMode) {\r\n\t\t\tthis._activeMode.handler.disable();\r\n\t\t}\r\n\t},\r\n\r\n\t_clearAllLayers: function () {\r\n\t\tthis._activeMode.handler.removeAllLayers();\r\n\t\tif (this._activeMode) {\r\n\t\t\tthis._activeMode.handler.disable();\r\n\t\t}\r\n\t},\r\n\r\n\t_checkDisabled: function () {\r\n\t\tvar featureGroup = this.options.featureGroup,\r\n\t\t\thasLayers = featureGroup.getLayers().length !== 0,\r\n\t\t\tbutton;\r\n\r\n\t\tif (this.options.edit) {\r\n\t\t\tbutton = this._modes[L.EditToolbar.Edit.TYPE].button;\r\n\r\n\t\t\tif (hasLayers) {\r\n\t\t\t\tL.DomUtil.removeClass(button, 'leaflet-disabled');\r\n\t\t\t} else {\r\n\t\t\t\tL.DomUtil.addClass(button, 'leaflet-disabled');\r\n\t\t\t}\r\n\r\n\t\t\tbutton.setAttribute(\r\n\t\t\t\t'title',\r\n\t\t\t\thasLayers ?\r\n\t\t\t\t\tL.drawLocal.edit.toolbar.buttons.edit\r\n\t\t\t\t\t: L.drawLocal.edit.toolbar.buttons.editDisabled\r\n\t\t\t);\r\n\t\t}\r\n\r\n\t\tif (this.options.remove) {\r\n\t\t\tbutton = this._modes[L.EditToolbar.Delete.TYPE].button;\r\n\r\n\t\t\tif (hasLayers) {\r\n\t\t\t\tL.DomUtil.removeClass(button, 'leaflet-disabled');\r\n\t\t\t} else {\r\n\t\t\t\tL.DomUtil.addClass(button, 'leaflet-disabled');\r\n\t\t\t}\r\n\r\n\t\t\tbutton.setAttribute(\r\n\t\t\t\t'title',\r\n\t\t\t\thasLayers ?\r\n\t\t\t\t\tL.drawLocal.edit.toolbar.buttons.remove\r\n\t\t\t\t\t: L.drawLocal.edit.toolbar.buttons.removeDisabled\r\n\t\t\t);\r\n\t\t}\r\n\t}\r\n});\r\n","/**\r\n * @class L.EditToolbar.Edit\r\n * @aka EditToolbar.Edit\r\n */\r\nL.EditToolbar.Edit = L.Handler.extend({\r\n\tstatics: {\r\n\t\tTYPE: 'edit'\r\n\t},\r\n\r\n\t// @method intialize(): void\r\n\tinitialize: function (map, options) {\r\n\t\tL.Handler.prototype.initialize.call(this, map);\r\n\r\n\t\tL.setOptions(this, options);\r\n\r\n\t\t// Store the selectable layer group for ease of access\r\n\t\tthis._featureGroup = options.featureGroup;\r\n\r\n\t\tif (!(this._featureGroup instanceof L.FeatureGroup)) {\r\n\t\t\tthrow new Error('options.featureGroup must be a L.FeatureGroup');\r\n\t\t}\r\n\r\n\t\tthis._uneditedLayerProps = {};\r\n\r\n\t\t// Save the type so super can fire, need to do this as cannot do this.TYPE :(\r\n\t\tthis.type = L.EditToolbar.Edit.TYPE;\r\n\r\n\t\tvar version = L.version.split('.');\r\n\t\t//If Version is >= 1.2.0\r\n\t\tif (parseInt(version[0], 10) === 1 && parseInt(version[1], 10) >= 2) {\r\n\t\t\tL.EditToolbar.Edit.include(L.Evented.prototype);\r\n\t\t} else {\r\n\t\t\tL.EditToolbar.Edit.include(L.Mixin.Events);\r\n\t\t}\r\n\t},\r\n\r\n\t// @method enable(): void\r\n\t// Enable the edit toolbar\r\n\tenable: function () {\r\n\t\tif (this._enabled || !this._hasAvailableLayers()) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tthis.fire('enabled', {handler: this.type});\r\n\t\t//this disable other handlers\r\n\r\n\t\tthis._map.fire(L.Draw.Event.EDITSTART, {handler: this.type});\r\n\t\t//allow drawLayer to be updated before beginning edition.\r\n\r\n\t\tL.Handler.prototype.enable.call(this);\r\n\t\tthis._featureGroup\r\n\t\t\t.on('layeradd', this._enableLayerEdit, this)\r\n\t\t\t.on('layerremove', this._disableLayerEdit, this);\r\n\t},\r\n\r\n\t// @method disable(): void\r\n\t// Disable the edit toolbar\r\n\tdisable: function () {\r\n\t\tif (!this._enabled) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tthis._featureGroup\r\n\t\t\t.off('layeradd', this._enableLayerEdit, this)\r\n\t\t\t.off('layerremove', this._disableLayerEdit, this);\r\n\t\tL.Handler.prototype.disable.call(this);\r\n\t\tthis._map.fire(L.Draw.Event.EDITSTOP, {handler: this.type});\r\n\t\tthis.fire('disabled', {handler: this.type});\r\n\t},\r\n\r\n\t// @method addHooks(): void\r\n\t// Add listener hooks for this handler\r\n\taddHooks: function () {\r\n\t\tvar map = this._map;\r\n\r\n\t\tif (map) {\r\n\t\t\tmap.getContainer().focus();\r\n\r\n\t\t\tthis._featureGroup.eachLayer(this._enableLayerEdit, this);\r\n\r\n\t\t\tthis._tooltip = new L.Draw.Tooltip(this._map);\r\n\t\t\tthis._tooltip.updateContent({\r\n\t\t\t\ttext: L.drawLocal.edit.handlers.edit.tooltip.text,\r\n\t\t\t\tsubtext: L.drawLocal.edit.handlers.edit.tooltip.subtext\r\n\t\t\t});\r\n\r\n\t\t\t// Quickly access the tooltip to update for intersection checking\r\n\t\t\tmap._editTooltip = this._tooltip;\r\n\r\n\t\t\tthis._updateTooltip();\r\n\r\n\t\t\tthis._map\r\n\t\t\t\t.on('mousemove', this._onMouseMove, this)\r\n\t\t\t\t.on('touchmove', this._onMouseMove, this)\r\n\t\t\t\t.on('MSPointerMove', this._onMouseMove, this)\r\n\t\t\t\t.on(L.Draw.Event.EDITVERTEX, this._updateTooltip, this);\r\n\t\t}\r\n\t},\r\n\r\n\t// @method removeHooks(): void\r\n\t// Remove listener hooks for this handler\r\n\tremoveHooks: function () {\r\n\t\tif (this._map) {\r\n\t\t\t// Clean up selected layers.\r\n\t\t\tthis._featureGroup.eachLayer(this._disableLayerEdit, this);\r\n\t\t\tthis._map._editTooltip.dispose();\r\n\t\t\tthis._map._editTooltip = null;\r\n\t\t\t// Clear the backups of the original layers\r\n\t\t\tthis._uneditedLayerProps = {};\r\n\r\n\t\t\tthis._tooltip.dispose();\r\n\t\t\tthis._tooltip = null;\r\n\r\n\t\t\tthis._map\r\n\t\t\t\t.off('mousemove', this._onMouseMove, this)\r\n\t\t\t\t.off('touchmove', this._onMouseMove, this)\r\n\t\t\t\t.off('MSPointerMove', this._onMouseMove, this)\r\n\t\t\t\t.off(L.Draw.Event.EDITVERTEX, this._updateTooltip, this);\r\n\t\t}\r\n\t},\r\n\r\n\t// @method revertLayers(): void\r\n\t// Revert each layer's geometry changes\r\n\trevertLayers: function () {\r\n\t\tthis._featureGroup.eachLayer(function (layer) {\r\n\t\t\tthis._revertLayer(layer);\r\n\t\t}, this);\r\n\t},\r\n\r\n\t// @method save(): void\r\n\t// Save the layer geometries\r\n\tsave: function () {\r\n\t\tvar editedLayers = new L.LayerGroup();\r\n\t\tthis._featureGroup.eachLayer(function (layer) {\r\n\t\t\tif (layer.edited) {\r\n\t\t\t\teditedLayers.addLayer(layer);\r\n\t\t\t\tlayer.edited = false;\r\n\t\t\t}\r\n\t\t});\r\n\t\tthis._map.fire(L.Draw.Event.EDITED, {layers: editedLayers});\r\n\t},\r\n\r\n\t_backupLayer: function (layer) {\r\n\t\tvar id = L.Util.stamp(layer);\r\n\r\n\t\tif (!this._uneditedLayerProps[id]) {\r\n\t\t\t// Polyline, Polygon or Rectangle\r\n\t\t\tif (layer instanceof L.Polyline || layer instanceof L.Polygon || layer instanceof L.Rectangle) {\r\n\t\t\t\tthis._uneditedLayerProps[id] = {\r\n\t\t\t\t\tlatlngs: L.LatLngUtil.cloneLatLngs(layer.getLatLngs())\r\n\t\t\t\t};\r\n\t\t\t} else if (layer instanceof L.Circle) {\r\n\t\t\t\tthis._uneditedLayerProps[id] = {\r\n\t\t\t\t\tlatlng: L.LatLngUtil.cloneLatLng(layer.getLatLng()),\r\n\t\t\t\t\tradius: layer.getRadius()\r\n\t\t\t\t};\r\n\t\t\t} else if (layer instanceof L.Marker || layer instanceof L.CircleMarker) { // Marker\r\n\t\t\t\tthis._uneditedLayerProps[id] = {\r\n\t\t\t\t\tlatlng: L.LatLngUtil.cloneLatLng(layer.getLatLng())\r\n\t\t\t\t};\r\n\t\t\t}\r\n\t\t}\r\n\t},\r\n\r\n\t_getTooltipText: function () {\r\n\t\treturn ({\r\n\t\t\ttext: L.drawLocal.edit.handlers.edit.tooltip.text,\r\n\t\t\tsubtext: L.drawLocal.edit.handlers.edit.tooltip.subtext\r\n\t\t});\r\n\t},\r\n\r\n\t_updateTooltip: function () {\r\n\t\tthis._tooltip.updateContent(this._getTooltipText());\r\n\t},\r\n\r\n\t_revertLayer: function (layer) {\r\n\t\tvar id = L.Util.stamp(layer);\r\n\t\tlayer.edited = false;\r\n\t\tif (this._uneditedLayerProps.hasOwnProperty(id)) {\r\n\t\t\t// Polyline, Polygon or Rectangle\r\n\t\t\tif (layer instanceof L.Polyline || layer instanceof L.Polygon || layer instanceof L.Rectangle) {\r\n\t\t\t\tlayer.setLatLngs(this._uneditedLayerProps[id].latlngs);\r\n\t\t\t} else if (layer instanceof L.Circle) {\r\n\t\t\t\tlayer.setLatLng(this._uneditedLayerProps[id].latlng);\r\n\t\t\t\tlayer.setRadius(this._uneditedLayerProps[id].radius);\r\n\t\t\t} else if (layer instanceof L.Marker || layer instanceof L.CircleMarker) { // Marker or CircleMarker\r\n\t\t\t\tlayer.setLatLng(this._uneditedLayerProps[id].latlng);\r\n\t\t\t}\r\n\r\n\t\t\tlayer.fire('revert-edited', {layer: layer});\r\n\t\t}\r\n\t},\r\n\r\n\t_enableLayerEdit: function (e) {\r\n\t\tvar layer = e.layer || e.target || e,\r\n\t\t\tpathOptions, poly;\r\n\r\n\t\t// Back up this layer (if haven't before)\r\n\t\tthis._backupLayer(layer);\r\n\r\n\t\tif (this.options.poly) {\r\n\t\t\tpoly = L.Util.extend({}, this.options.poly);\r\n\t\t\tlayer.options.poly = poly;\r\n\t\t}\r\n\r\n\t\t// Set different style for editing mode\r\n\t\tif (this.options.selectedPathOptions) {\r\n\t\t\tpathOptions = L.Util.extend({}, this.options.selectedPathOptions);\r\n\r\n\t\t\t// Use the existing color of the layer\r\n\t\t\tif (pathOptions.maintainColor) {\r\n\t\t\t\tpathOptions.color = layer.options.color;\r\n\t\t\t\tpathOptions.fillColor = layer.options.fillColor;\r\n\t\t\t}\r\n\r\n\t\t\tlayer.options.original = L.extend({}, layer.options);\r\n\t\t\tlayer.options.editing = pathOptions;\r\n\r\n\t\t}\r\n\r\n\t\tif (layer instanceof L.Marker) {\r\n\t\t\tif (layer.editing) {\r\n\t\t\t\tlayer.editing.enable();\r\n\t\t\t}\r\n\t\t\tlayer.dragging.enable();\r\n\t\t\tlayer\r\n\t\t\t\t.on('dragend', this._onMarkerDragEnd)\r\n\t\t\t\t// #TODO: remove when leaflet finally fixes their draggable so it's touch friendly again.\r\n\t\t\t\t.on('touchmove', this._onTouchMove, this)\r\n\t\t\t\t.on('MSPointerMove', this._onTouchMove, this)\r\n\t\t\t\t.on('touchend', this._onMarkerDragEnd, this)\r\n\t\t\t\t.on('MSPointerUp', this._onMarkerDragEnd, this);\r\n\t\t} else {\r\n\t\t\tlayer.editing.enable();\r\n\t\t}\r\n\t},\r\n\r\n\t_disableLayerEdit: function (e) {\r\n\t\tvar layer = e.layer || e.target || e;\r\n\r\n\t\tlayer.edited = false;\r\n\t\tif (layer.editing) {\r\n\t\t\tlayer.editing.disable();\r\n\t\t}\r\n\r\n\t\tdelete layer.options.editing;\r\n\t\tdelete layer.options.original;\r\n\t\t// Reset layer styles to that of before select\r\n\t\tif (this._selectedPathOptions) {\r\n\t\t\tif (layer instanceof L.Marker) {\r\n\t\t\t\tthis._toggleMarkerHighlight(layer);\r\n\t\t\t} else {\r\n\t\t\t\t// reset the layer style to what is was before being selected\r\n\t\t\t\tlayer.setStyle(layer.options.previousOptions);\r\n\t\t\t\t// remove the cached options for the layer object\r\n\t\t\t\tdelete layer.options.previousOptions;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (layer instanceof L.Marker) {\r\n\t\t\tlayer.dragging.disable();\r\n\t\t\tlayer\r\n\t\t\t\t.off('dragend', this._onMarkerDragEnd, this)\r\n\t\t\t\t.off('touchmove', this._onTouchMove, this)\r\n\t\t\t\t.off('MSPointerMove', this._onTouchMove, this)\r\n\t\t\t\t.off('touchend', this._onMarkerDragEnd, this)\r\n\t\t\t\t.off('MSPointerUp', this._onMarkerDragEnd, this);\r\n\t\t} else {\r\n\t\t\tlayer.editing.disable();\r\n\t\t}\r\n\t},\r\n\r\n\t_onMouseMove: function (e) {\r\n\t\tthis._tooltip.updatePosition(e.latlng);\r\n\t},\r\n\r\n\t_onMarkerDragEnd: function (e) {\r\n\t\tvar layer = e.target;\r\n\t\tlayer.edited = true;\r\n\t\tthis._map.fire(L.Draw.Event.EDITMOVE, {layer: layer});\r\n\t},\r\n\r\n\t_onTouchMove: function (e) {\r\n\t\tvar touchEvent = e.originalEvent.changedTouches[0],\r\n\t\t\tlayerPoint = this._map.mouseEventToLayerPoint(touchEvent),\r\n\t\t\tlatlng = this._map.layerPointToLatLng(layerPoint);\r\n\t\te.target.setLatLng(latlng);\r\n\t},\r\n\r\n\t_hasAvailableLayers: function () {\r\n\t\treturn this._featureGroup.getLayers().length !== 0;\r\n\t}\r\n});\r\n","/**\r\n * @class L.EditToolbar.Delete\r\n * @aka EditToolbar.Delete\r\n */\r\nL.EditToolbar.Delete = L.Handler.extend({\r\n\tstatics: {\r\n\t\tTYPE: 'remove' // not delete as delete is reserved in js\r\n\t},\r\n\r\n\t// @method intialize(): void\r\n\tinitialize: function (map, options) {\r\n\t\tL.Handler.prototype.initialize.call(this, map);\r\n\r\n\t\tL.Util.setOptions(this, options);\r\n\r\n\t\t// Store the selectable layer group for ease of access\r\n\t\tthis._deletableLayers = this.options.featureGroup;\r\n\r\n\t\tif (!(this._deletableLayers instanceof L.FeatureGroup)) {\r\n\t\t\tthrow new Error('options.featureGroup must be a L.FeatureGroup');\r\n\t\t}\r\n\r\n\t\t// Save the type so super can fire, need to do this as cannot do this.TYPE :(\r\n\t\tthis.type = L.EditToolbar.Delete.TYPE;\r\n\r\n\t\tvar version = L.version.split('.');\r\n\t\t//If Version is >= 1.2.0\r\n\t\tif (parseInt(version[0], 10) === 1 && parseInt(version[1], 10) >= 2) {\r\n\t\t\tL.EditToolbar.Delete.include(L.Evented.prototype);\r\n\t\t} else {\r\n\t\t\tL.EditToolbar.Delete.include(L.Mixin.Events);\r\n\t\t}\r\n\r\n\t},\r\n\r\n\t// @method enable(): void\r\n\t// Enable the delete toolbar\r\n\tenable: function () {\r\n\t\tif (this._enabled || !this._hasAvailableLayers()) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tthis.fire('enabled', {handler: this.type});\r\n\r\n\t\tthis._map.fire(L.Draw.Event.DELETESTART, {handler: this.type});\r\n\r\n\t\tL.Handler.prototype.enable.call(this);\r\n\r\n\t\tthis._deletableLayers\r\n\t\t\t.on('layeradd', this._enableLayerDelete, this)\r\n\t\t\t.on('layerremove', this._disableLayerDelete, this);\r\n\t},\r\n\r\n\t// @method disable(): void\r\n\t// Disable the delete toolbar\r\n\tdisable: function () {\r\n\t\tif (!this._enabled) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tthis._deletableLayers\r\n\t\t\t.off('layeradd', this._enableLayerDelete, this)\r\n\t\t\t.off('layerremove', this._disableLayerDelete, this);\r\n\r\n\t\tL.Handler.prototype.disable.call(this);\r\n\r\n\t\tthis._map.fire(L.Draw.Event.DELETESTOP, {handler: this.type});\r\n\r\n\t\tthis.fire('disabled', {handler: this.type});\r\n\t},\r\n\r\n\t// @method addHooks(): void\r\n\t// Add listener hooks to this handler\r\n\taddHooks: function () {\r\n\t\tvar map = this._map;\r\n\r\n\t\tif (map) {\r\n\t\t\tmap.getContainer().focus();\r\n\r\n\t\t\tthis._deletableLayers.eachLayer(this._enableLayerDelete, this);\r\n\t\t\tthis._deletedLayers = new L.LayerGroup();\r\n\r\n\t\t\tthis._tooltip = new L.Draw.Tooltip(this._map);\r\n\t\t\tthis._tooltip.updateContent({text: L.drawLocal.edit.handlers.remove.tooltip.text});\r\n\r\n\t\t\tthis._map.on('mousemove', this._onMouseMove, this);\r\n\t\t}\r\n\t},\r\n\r\n\t// @method removeHooks(): void\r\n\t// Remove listener hooks from this handler\r\n\tremoveHooks: function () {\r\n\t\tif (this._map) {\r\n\t\t\tthis._deletableLayers.eachLayer(this._disableLayerDelete, this);\r\n\t\t\tthis._deletedLayers = null;\r\n\r\n\t\t\tthis._tooltip.dispose();\r\n\t\t\tthis._tooltip = null;\r\n\r\n\t\t\tthis._map.off('mousemove', this._onMouseMove, this);\r\n\t\t}\r\n\t},\r\n\r\n\t// @method revertLayers(): void\r\n\t// Revert the deleted layers back to their prior state.\r\n\trevertLayers: function () {\r\n\t\t// Iterate of the deleted layers and add them back into the featureGroup\r\n\t\tthis._deletedLayers.eachLayer(function (layer) {\r\n\t\t\tthis._deletableLayers.addLayer(layer);\r\n\t\t\tlayer.fire('revert-deleted', {layer: layer});\r\n\t\t}, this);\r\n\t},\r\n\r\n\t// @method save(): void\r\n\t// Save deleted layers\r\n\tsave: function () {\r\n\t\tthis._map.fire(L.Draw.Event.DELETED, {layers: this._deletedLayers});\r\n\t},\r\n\r\n\t// @method removeAllLayers(): void\r\n\t// Remove all delateable layers\r\n\tremoveAllLayers: function () {\r\n\t\t// Iterate of the delateable layers and add remove them\r\n\t\tthis._deletableLayers.eachLayer(function (layer) {\r\n\t\t\tthis._removeLayer({layer: layer});\r\n\t\t}, this);\r\n\t\tthis.save();\r\n\t},\r\n\r\n\t_enableLayerDelete: function (e) {\r\n\t\tvar layer = e.layer || e.target || e;\r\n\r\n\t\tlayer.on('click', this._removeLayer, this);\r\n\t},\r\n\r\n\t_disableLayerDelete: function (e) {\r\n\t\tvar layer = e.layer || e.target || e;\r\n\r\n\t\tlayer.off('click', this._removeLayer, this);\r\n\r\n\t\t// Remove from the deleted layers so we can't accidentally revert if the user presses cancel\r\n\t\tthis._deletedLayers.removeLayer(layer);\r\n\t},\r\n\r\n\t_removeLayer: function (e) {\r\n\t\tvar layer = e.layer || e.target || e;\r\n\r\n\t\tthis._deletableLayers.removeLayer(layer);\r\n\r\n\t\tthis._deletedLayers.addLayer(layer);\r\n\r\n\t\tlayer.fire('deleted');\r\n\t},\r\n\r\n\t_onMouseMove: function (e) {\r\n\t\tthis._tooltip.updatePosition(e.latlng);\r\n\t},\r\n\r\n\t_hasAvailableLayers: function () {\r\n\t\treturn this._deletableLayers.getLayers().length !== 0;\r\n\t}\r\n});\r\n"]} \ No newline at end of file diff --git a/dist/leaflet.draw.css b/dist/leaflet.draw.css new file mode 100644 index 000000000..a01941060 --- /dev/null +++ b/dist/leaflet.draw.css @@ -0,0 +1,10 @@ +.leaflet-draw-section{position:relative}.leaflet-draw-toolbar{margin-top:12px}.leaflet-draw-toolbar-top{margin-top:0}.leaflet-draw-toolbar-notop a:first-child{border-top-right-radius:0}.leaflet-draw-toolbar-nobottom a:last-child{border-bottom-right-radius:0}.leaflet-draw-toolbar a{background-image:url('images/spritesheet.png');background-image:linear-gradient(transparent,transparent),url('images/spritesheet.svg');background-repeat:no-repeat;background-size:300px 30px;background-clip:padding-box}.leaflet-retina .leaflet-draw-toolbar a{background-image:url('images/spritesheet-2x.png');background-image:linear-gradient(transparent,transparent),url('images/spritesheet.svg')} +.leaflet-draw a{display:block;text-align:center;text-decoration:none}.leaflet-draw a .sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);border:0}.leaflet-draw-actions{display:none;list-style:none;margin:0;padding:0;position:absolute;left:26px;top:0;white-space:nowrap}.leaflet-touch .leaflet-draw-actions{left:32px}.leaflet-right .leaflet-draw-actions{right:26px;left:auto}.leaflet-touch .leaflet-right .leaflet-draw-actions{right:32px;left:auto}.leaflet-draw-actions li{display:inline-block} +.leaflet-draw-actions li:first-child a{border-left:0}.leaflet-draw-actions li:last-child a{-webkit-border-radius:0 4px 4px 0;border-radius:0 4px 4px 0}.leaflet-right .leaflet-draw-actions li:last-child a{-webkit-border-radius:0;border-radius:0}.leaflet-right .leaflet-draw-actions li:first-child a{-webkit-border-radius:4px 0 0 4px;border-radius:4px 0 0 4px}.leaflet-draw-actions a{background-color:#919187;border-left:1px solid #AAA;color:#FFF;font:11px/19px "Helvetica Neue",Arial,Helvetica,sans-serif;line-height:28px;text-decoration:none;padding-left:10px;padding-right:10px;height:28px} +.leaflet-touch .leaflet-draw-actions a{font-size:12px;line-height:30px;height:30px}.leaflet-draw-actions-bottom{margin-top:0}.leaflet-draw-actions-top{margin-top:1px}.leaflet-draw-actions-top a,.leaflet-draw-actions-bottom a{height:27px;line-height:27px}.leaflet-draw-actions a:hover{background-color:#a0a098}.leaflet-draw-actions-top.leaflet-draw-actions-bottom a{height:26px;line-height:26px}.leaflet-draw-toolbar .leaflet-draw-draw-polyline{background-position:-2px -2px}.leaflet-touch .leaflet-draw-toolbar .leaflet-draw-draw-polyline{background-position:0 -1px} +.leaflet-draw-toolbar .leaflet-draw-draw-polygon{background-position:-31px -2px}.leaflet-touch .leaflet-draw-toolbar .leaflet-draw-draw-polygon{background-position:-29px -1px}.leaflet-draw-toolbar .leaflet-draw-draw-rectangle{background-position:-62px -2px}.leaflet-touch .leaflet-draw-toolbar .leaflet-draw-draw-rectangle{background-position:-60px -1px}.leaflet-draw-toolbar .leaflet-draw-draw-circle{background-position:-92px -2px}.leaflet-touch .leaflet-draw-toolbar .leaflet-draw-draw-circle{background-position:-90px -1px} +.leaflet-draw-toolbar .leaflet-draw-draw-marker{background-position:-122px -2px}.leaflet-touch .leaflet-draw-toolbar .leaflet-draw-draw-marker{background-position:-120px -1px}.leaflet-draw-toolbar .leaflet-draw-draw-circlemarker{background-position:-273px -2px}.leaflet-touch .leaflet-draw-toolbar .leaflet-draw-draw-circlemarker{background-position:-271px -1px}.leaflet-draw-toolbar .leaflet-draw-edit-edit{background-position:-152px -2px}.leaflet-touch .leaflet-draw-toolbar .leaflet-draw-edit-edit{background-position:-150px -1px} +.leaflet-draw-toolbar .leaflet-draw-edit-remove{background-position:-182px -2px}.leaflet-touch .leaflet-draw-toolbar .leaflet-draw-edit-remove{background-position:-180px -1px}.leaflet-draw-toolbar .leaflet-draw-edit-edit.leaflet-disabled{background-position:-212px -2px}.leaflet-touch .leaflet-draw-toolbar .leaflet-draw-edit-edit.leaflet-disabled{background-position:-210px -1px}.leaflet-draw-toolbar .leaflet-draw-edit-remove.leaflet-disabled{background-position:-242px -2px}.leaflet-touch .leaflet-draw-toolbar .leaflet-draw-edit-remove.leaflet-disabled{background-position:-240px -2px} +.leaflet-mouse-marker{background-color:#fff;cursor:crosshair}.leaflet-draw-tooltip{background:#363636;background:rgba(0,0,0,0.5);border:1px solid transparent;-webkit-border-radius:4px;border-radius:4px;color:#fff;font:12px/18px "Helvetica Neue",Arial,Helvetica,sans-serif;margin-left:20px;margin-top:-21px;padding:4px 8px;position:absolute;visibility:hidden;white-space:nowrap;z-index:6}.leaflet-draw-tooltip:before{border-right:6px solid black;border-right-color:rgba(0,0,0,0.5);border-top:6px solid transparent;border-bottom:6px solid transparent;content:"";position:absolute;top:7px;left:-7px} +.leaflet-error-draw-tooltip{background-color:#f2dede;border:1px solid #e6b6bd;color:#b94a48}.leaflet-error-draw-tooltip:before{border-right-color:#e6b6bd}.leaflet-draw-tooltip-single{margin-top:-12px}.leaflet-draw-tooltip-subtext{color:#f8d5e4}.leaflet-draw-guide-dash{font-size:1%;opacity:.6;position:absolute;width:5px;height:5px}.leaflet-edit-marker-selected{background-color:rgba(254,87,161,0.1);border:4px dashed rgba(254,87,161,0.6);-webkit-border-radius:4px;border-radius:4px;box-sizing:content-box} +.leaflet-edit-move{cursor:move}.leaflet-edit-resize{cursor:pointer}.leaflet-oldie .leaflet-draw-toolbar{border:1px solid #999} \ No newline at end of file diff --git a/dist/leaflet.draw.js b/dist/leaflet.draw.js new file mode 100644 index 000000000..d4efa5360 --- /dev/null +++ b/dist/leaflet.draw.js @@ -0,0 +1,10 @@ +/* + Leaflet.draw 1.0.3+e90ec6d, a plugin that adds drawing and editing tools to Leaflet powered maps. + (c) 2012-2017, Jacob Toye, Jon West, Smartrak, Leaflet + + https://github.com/Leaflet/Leaflet.draw + http://leafletjs.com + */ +!function(t,e,i){function o(t,e){for(;(t=t.parentElement)&&!t.classList.contains(e););return t}L.drawVersion="1.0.3+e90ec6d",L.Draw={},L.drawLocal={draw:{toolbar:{actions:{title:"Cancel drawing",text:"Cancel"},finish:{title:"Finish drawing",text:"Finish"},undo:{title:"Delete last point drawn",text:"Delete last point"},buttons:{polyline:"Draw a polyline",polygon:"Draw a polygon",rectangle:"Draw a rectangle",circle:"Draw a circle",marker:"Draw a marker",circlemarker:"Draw a circlemarker"}},handlers:{circle:{tooltip:{start:"Click and drag to draw circle."},radius:"Radius"},circlemarker:{tooltip:{start:"Click map to place circle marker."}},marker:{tooltip:{start:"Click map to place marker."}},polygon:{tooltip:{start:"Click to start drawing shape.",cont:"Click to continue drawing shape.",end:"Click first point to close this shape."}},polyline:{error:"Error: shape edges cannot cross!",tooltip:{start:"Click to start drawing line.",cont:"Click to continue drawing line.",end:"Click last point to finish line."}},rectangle:{tooltip:{start:"Click and drag to draw rectangle."}},simpleshape:{tooltip:{end:"Release mouse to finish drawing."}}}},edit:{toolbar:{actions:{save:{title:"Save changes",text:"Save"},cancel:{title:"Cancel editing, discards all changes",text:"Cancel"},clearAll:{title:"Clear all layers",text:"Clear All"}},buttons:{edit:"Edit layers",editDisabled:"No layers to edit",remove:"Delete layers",removeDisabled:"No layers to delete"}},handlers:{edit:{tooltip:{text:"Drag handles or markers to edit features.",subtext:"Click cancel to undo changes."}},remove:{tooltip:{text:"Click on a feature to remove."}}}}},L.Draw.Event={},L.Draw.Event.CREATED="draw:created",L.Draw.Event.EDITED="draw:edited",L.Draw.Event.DELETED="draw:deleted",L.Draw.Event.DRAWSTART="draw:drawstart",L.Draw.Event.DRAWSTOP="draw:drawstop",L.Draw.Event.DRAWVERTEX="draw:drawvertex",L.Draw.Event.EDITSTART="draw:editstart",L.Draw.Event.EDITMOVE="draw:editmove",L.Draw.Event.EDITRESIZE="draw:editresize",L.Draw.Event.EDITVERTEX="draw:editvertex",L.Draw.Event.EDITSTOP="draw:editstop",L.Draw.Event.DELETESTART="draw:deletestart",L.Draw.Event.DELETESTOP="draw:deletestop",L.Draw.Event.TOOLBAROPENED="draw:toolbaropened",L.Draw.Event.TOOLBARCLOSED="draw:toolbarclosed",L.Draw.Event.MARKERCONTEXT="draw:markercontext",L.Draw=L.Draw||{},L.Draw.Feature=L.Handler.extend({initialize:function(t,e){this._map=t,this._container=t._container,this._overlayPane=t._panes.overlayPane,this._popupPane=t._panes.popupPane,e&&e.shapeOptions&&(e.shapeOptions=L.Util.extend({},this.options.shapeOptions,e.shapeOptions)),L.setOptions(this,e);var i=L.version.split(".");1===parseInt(i[0],10)&&parseInt(i[1],10)>=2?L.Draw.Feature.include(L.Evented.prototype):L.Draw.Feature.include(L.Mixin.Events)},enable:function(){this._enabled||(L.Handler.prototype.enable.call(this),this.fire("enabled",{handler:this.type}),this._map.fire(L.Draw.Event.DRAWSTART,{layerType:this.type}))},disable:function(){this._enabled&&(L.Handler.prototype.disable.call(this),this._map.fire(L.Draw.Event.DRAWSTOP,{layerType:this.type}),this.fire("disabled",{handler:this.type}))},addHooks:function(){var t=this._map;t&&(L.DomUtil.disableTextSelection(),t.getContainer().focus(),this._tooltip=new L.Draw.Tooltip(this._map),L.DomEvent.on(this._container,"keyup",this._cancelDrawing,this))},removeHooks:function(){this._map&&(L.DomUtil.enableTextSelection(),this._tooltip.dispose(),this._tooltip=null,L.DomEvent.off(this._container,"keyup",this._cancelDrawing,this))},setOptions:function(t){L.setOptions(this,t)},_fireCreatedEvent:function(t){this._map.fire(L.Draw.Event.CREATED,{layer:t,layerType:this.type})},_cancelDrawing:function(t){27===t.keyCode&&(this._map.fire("draw:canceled",{layerType:this.type}),this.disable())}}),L.Draw.Polyline=L.Draw.Feature.extend({statics:{TYPE:"polyline"},Poly:L.Polyline,options:{allowIntersection:!0,repeatMode:!1,drawError:{color:"#b00b00",timeout:2500},icon:new L.DivIcon({iconSize:new L.Point(8,8),className:"leaflet-div-icon leaflet-editing-icon"}),touchIcon:new L.DivIcon({iconSize:new L.Point(20,20),className:"leaflet-div-icon leaflet-editing-icon leaflet-touch-icon"}),guidelineDistance:20,maxGuideLineLength:4e3,shapeOptions:{stroke:!0,color:"#3388ff",weight:4,opacity:.5,fill:!1,clickable:!0},metric:!0,feet:!0,nautic:!1,showLength:!0,zIndexOffset:2e3,factor:1,maxPoints:0},initialize:function(t,e){L.Browser.touch&&(this.options.icon=this.options.touchIcon),this.options.drawError.message=L.drawLocal.draw.handlers.polyline.error,e&&e.drawError&&(e.drawError=L.Util.extend({},this.options.drawError,e.drawError)),this.type=L.Draw.Polyline.TYPE,L.Draw.Feature.prototype.initialize.call(this,t,e)},addHooks:function(){L.Draw.Feature.prototype.addHooks.call(this),this._map&&(this._markers=[],this._markerGroup=new L.LayerGroup,this._map.addLayer(this._markerGroup),this._poly=new L.Polyline([],this.options.shapeOptions),this._tooltip.updateContent(this._getTooltipText()),this._mouseMarker||(this._mouseMarker=L.marker(this._map.getCenter(),{icon:L.divIcon({className:"leaflet-mouse-marker",iconAnchor:[20,20],iconSize:[40,40]}),opacity:0,zIndexOffset:this.options.zIndexOffset})),this._mouseMarker.on("mouseout",this._onMouseOut,this).on("mousemove",this._onMouseMove,this).on("mousedown",this._onMouseDown,this).on("mouseup",this._onMouseUp,this).addTo(this._map),this._map.on("mouseup",this._onMouseUp,this).on("mousemove",this._onMouseMove,this).on("zoomlevelschange",this._onZoomEnd,this).on("touchstart",this._onTouch,this).on("zoomend",this._onZoomEnd,this))},removeHooks:function(){L.Draw.Feature.prototype.removeHooks.call(this),this._clearHideErrorTimeout(),this._cleanUpShape(),this._map.removeLayer(this._markerGroup),delete this._markerGroup,delete this._markers,this._map.removeLayer(this._poly),delete this._poly,this._mouseMarker.off("mousedown",this._onMouseDown,this).off("mouseout",this._onMouseOut,this).off("mouseup",this._onMouseUp,this).off("mousemove",this._onMouseMove,this),this._map.removeLayer(this._mouseMarker),delete this._mouseMarker,this._clearGuides(),this._map.off("mouseup",this._onMouseUp,this).off("mousemove",this._onMouseMove,this).off("zoomlevelschange",this._onZoomEnd,this).off("zoomend",this._onZoomEnd,this).off("touchstart",this._onTouch,this).off("click",this._onTouch,this)},deleteLastVertex:function(){if(!(this._markers.length<=1)){var t=this._markers.pop(),e=this._poly,i=e.getLatLngs(),o=i.splice(-1,1)[0];this._poly.setLatLngs(i),this._markerGroup.removeLayer(t),e.getLatLngs().length<2&&this._map.removeLayer(e),this._vertexChanged(o,!1)}},addVertex:function(t){if(this._markers.length>=2&&!this.options.allowIntersection&&this._poly.newLatLngIntersects(t))return void this._showErrorTooltip();this._errorShown&&this._hideErrorTooltip(),this._markers.push(this._createMarker(t)),this._poly.addLatLng(t),2===this._poly.getLatLngs().length&&this._map.addLayer(this._poly),this._vertexChanged(t,!0)},completeShape:function(){this._markers.length<=1||!this._shapeIsValid()||(this._fireCreatedEvent(),this.disable(),this.options.repeatMode&&this.enable())},_finishShape:function(){var t=this._poly._defaultShape?this._poly._defaultShape():this._poly.getLatLngs(),e=this._poly.newLatLngIntersects(t[t.length-1]);if(!this.options.allowIntersection&&e||!this._shapeIsValid())return void this._showErrorTooltip();this._fireCreatedEvent(),this.disable(),this.options.repeatMode&&this.enable()},_shapeIsValid:function(){return!0},_onZoomEnd:function(){null!==this._markers&&this._updateGuide()},_onMouseMove:function(t){var e=this._map.mouseEventToLayerPoint(t.originalEvent),i=this._map.layerPointToLatLng(e);this._currentLatLng=i,this._updateTooltip(i),this._updateGuide(e),this._mouseMarker.setLatLng(i),L.DomEvent.preventDefault(t.originalEvent)},_vertexChanged:function(t,e){this._map.fire(L.Draw.Event.DRAWVERTEX,{layers:this._markerGroup}),this._updateFinishHandler(),this._updateRunningMeasure(t,e),this._clearGuides(),this._updateTooltip()},_onMouseDown:function(t){if(!this._clickHandled&&!this._touchHandled&&!this._disableMarkers){this._onMouseMove(t),this._clickHandled=!0,this._disableNewMarkers();var e=t.originalEvent,i=e.clientX,o=e.clientY;this._startPoint.call(this,i,o)}},_startPoint:function(t,e){this._mouseDownOrigin=L.point(t,e)},_onMouseUp:function(t){var e=t.originalEvent,i=e.clientX,o=e.clientY;this._endPoint.call(this,i,o,t),this._clickHandled=null},_endPoint:function(e,i,o){if(this._mouseDownOrigin){var a=L.point(e,i).distanceTo(this._mouseDownOrigin),n=this._calculateFinishDistance(o.latlng);this.options.maxPoints>1&&this.options.maxPoints==this._markers.length+1?(this.addVertex(o.latlng),this._finishShape()):n<10&&L.Browser.touch?this._finishShape():Math.abs(a)<9*(t.devicePixelRatio||1)&&this.addVertex(o.latlng),this._enableNewMarkers()}this._mouseDownOrigin=null},_onTouch:function(t){var e,i,o=t.originalEvent;!o.touches||!o.touches[0]||this._clickHandled||this._touchHandled||this._disableMarkers||(e=o.touches[0].clientX,i=o.touches[0].clientY,this._disableNewMarkers(),this._touchHandled=!0,this._startPoint.call(this,e,i),this._endPoint.call(this,e,i,t),this._touchHandled=null),this._clickHandled=null},_onMouseOut:function(){this._tooltip&&this._tooltip._onMouseOut.call(this._tooltip)},_calculateFinishDistance:function(t){var e;if(this._markers.length>0){var i;if(this.type===L.Draw.Polyline.TYPE)i=this._markers[this._markers.length-1];else{if(this.type!==L.Draw.Polygon.TYPE)return 1/0;i=this._markers[0]}var o=this._map.latLngToContainerPoint(i.getLatLng()),a=new L.Marker(t,{icon:this.options.icon,zIndexOffset:2*this.options.zIndexOffset}),n=this._map.latLngToContainerPoint(a.getLatLng());e=o.distanceTo(n)}else e=1/0;return e},_updateFinishHandler:function(){var t=this._markers.length;t>1&&this._markers[t-1].on("click",this._finishShape,this),t>2&&this._markers[t-2].off("click",this._finishShape,this)},_createMarker:function(t){var e=new L.Marker(t,{icon:this.options.icon,zIndexOffset:2*this.options.zIndexOffset});return this._markerGroup.addLayer(e),e},_updateGuide:function(t){var e=this._markers?this._markers.length:0;e>0&&(t=t||this._map.latLngToLayerPoint(this._currentLatLng),this._clearGuides(),this._drawGuide(this._map.latLngToLayerPoint(this._markers[e-1].getLatLng()),t))},_updateTooltip:function(t){var e=this._getTooltipText();t&&this._tooltip.updatePosition(t),this._errorShown||this._tooltip.updateContent(e)},_drawGuide:function(t,e){var i,o,a,n=Math.floor(Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))),s=this.options.guidelineDistance,r=this.options.maxGuideLineLength,l=n>r?n-r:s;for(this._guidesContainer||(this._guidesContainer=L.DomUtil.create("div","leaflet-draw-guides",this._overlayPane));l1&&this._markers[this._markers.length-1].off("click",this._finishShape,this)},_fireCreatedEvent:function(){var t=new this.Poly(this._poly.getLatLngs(),this.options.shapeOptions);L.Draw.Feature.prototype._fireCreatedEvent.call(this,t)}}),L.Draw.Polygon=L.Draw.Polyline.extend({statics:{TYPE:"polygon"},Poly:L.Polygon,options:{showArea:!1,showLength:!1,shapeOptions:{stroke:!0,color:"#3388ff",weight:4,opacity:.5,fill:!0,fillColor:null,fillOpacity:.2,clickable:!0},metric:!0,feet:!0,nautic:!1,precision:{}},initialize:function(t,e){L.Draw.Polyline.prototype.initialize.call(this,t,e),this.type=L.Draw.Polygon.TYPE},_updateFinishHandler:function(){var t=this._markers.length;1===t&&this._markers[0].on("click",this._finishShape,this),t>2&&(this._markers[t-1].on("dblclick",this._finishShape,this),t>3&&this._markers[t-2].off("dblclick",this._finishShape,this))},_getTooltipText:function(){var t,e;return 0===this._markers.length?t=L.drawLocal.draw.handlers.polygon.tooltip.start:this._markers.length<3?(t=L.drawLocal.draw.handlers.polygon.tooltip.cont,e=this._getMeasurementString()):(t=L.drawLocal.draw.handlers.polygon.tooltip.end,e=this._getMeasurementString()),{text:t,subtext:e}},_getMeasurementString:function(){var t=this._area,e="";return t||this.options.showLength?(this.options.showLength&&(e=L.Draw.Polyline.prototype._getMeasurementString.call(this)),t&&(e+="
"+L.GeometryUtil.readableArea(t,this.options.metric,this.options.precision)),e):null},_shapeIsValid:function(){return this._markers.length>=3},_vertexChanged:function(t,e){var i;!this.options.allowIntersection&&this.options.showArea&&(i=this._poly.getLatLngs(),this._area=L.GeometryUtil.geodesicArea(i)),L.Draw.Polyline.prototype._vertexChanged.call(this,t,e)},_cleanUpShape:function(){var t=this._markers.length;t>0&&(this._markers[0].off("click",this._finishShape,this),t>2&&this._markers[t-1].off("dblclick",this._finishShape,this))}}),L.SimpleShape={},L.Draw.SimpleShape=L.Draw.Feature.extend({options:{repeatMode:!1},initialize:function(t,e){this._endLabelText=L.drawLocal.draw.handlers.simpleshape.tooltip.end,L.Draw.Feature.prototype.initialize.call(this,t,e)},addHooks:function(){L.Draw.Feature.prototype.addHooks.call(this),this._map&&(this._mapDraggable=this._map.dragging.enabled(),this._mapDraggable&&this._map.dragging.disable(),this._container.style.cursor="crosshair",this._tooltip.updateContent({text:this._initialLabelText}),this._map.on("mousedown",this._onMouseDown,this).on("mousemove",this._onMouseMove,this).on("touchstart",this._onMouseDown,this).on("touchmove",this._onMouseMove,this),e.addEventListener("touchstart",L.DomEvent.preventDefault,{passive:!1}))},removeHooks:function(){L.Draw.Feature.prototype.removeHooks.call(this),this._map&&(this._mapDraggable&&this._map.dragging.enable(),this._container.style.cursor="",this._map.off("mousedown",this._onMouseDown,this).off("mousemove",this._onMouseMove,this).off("touchstart",this._onMouseDown,this).off("touchmove",this._onMouseMove,this),L.DomEvent.off(e,"mouseup",this._onMouseUp,this),L.DomEvent.off(e,"touchend",this._onMouseUp,this),e.removeEventListener("touchstart",L.DomEvent.preventDefault),this._shape&&(this._map.removeLayer(this._shape),delete this._shape)),this._isDrawing=!1},_getTooltipText:function(){return{text:this._endLabelText}},_onMouseDown:function(t){this._isDrawing=!0,this._startLatLng=t.latlng,L.DomEvent.on(e,"mouseup",this._onMouseUp,this).on(e,"touchend",this._onMouseUp,this).preventDefault(t.originalEvent)},_onMouseMove:function(t){var e=t.latlng;this._tooltip.updatePosition(e),this._isDrawing&&(this._tooltip.updateContent(this._getTooltipText()),this._drawShape(e))},_onMouseUp:function(){this._shape&&this._fireCreatedEvent(),this.disable(),this.options.repeatMode&&this.enable()}}),L.Draw.Rectangle=L.Draw.SimpleShape.extend({statics:{TYPE:"rectangle"},options:{shapeOptions:{stroke:!0,color:"#3388ff",weight:4,opacity:.5,fill:!0,fillColor:null,fillOpacity:.2,clickable:!0},showArea:!0,metric:!0},initialize:function(t,e){this.type=L.Draw.Rectangle.TYPE,this._initialLabelText=L.drawLocal.draw.handlers.rectangle.tooltip.start,L.Draw.SimpleShape.prototype.initialize.call(this,t,e)},disable:function(){this._enabled&&(this._isCurrentlyTwoClickDrawing=!1,L.Draw.SimpleShape.prototype.disable.call(this))},_onMouseUp:function(t){if(!this._shape&&!this._isCurrentlyTwoClickDrawing)return void(this._isCurrentlyTwoClickDrawing=!0);this._isCurrentlyTwoClickDrawing&&!o(t.target,"leaflet-pane")||L.Draw.SimpleShape.prototype._onMouseUp.call(this)},_drawShape:function(t){this._shape?this._shape.setBounds(new L.LatLngBounds(this._startLatLng,t)):(this._shape=new L.Rectangle(new L.LatLngBounds(this._startLatLng,t),this.options.shapeOptions),this._map.addLayer(this._shape))},_fireCreatedEvent:function(){var t=new L.Rectangle(this._shape.getBounds(),this.options.shapeOptions);L.Draw.SimpleShape.prototype._fireCreatedEvent.call(this,t)},_getTooltipText:function(){var t,e,i,o=L.Draw.SimpleShape.prototype._getTooltipText.call(this),a=this._shape,n=this.options.showArea;return a&&(t=this._shape._defaultShape?this._shape._defaultShape():this._shape.getLatLngs(),e=L.GeometryUtil.geodesicArea(t),i=n?L.GeometryUtil.readableArea(e,this.options.metric):""),{text:o.text,subtext:i}}}),L.Draw.Marker=L.Draw.Feature.extend({statics:{TYPE:"marker"},options:{icon:new L.Icon.Default,repeatMode:!1,zIndexOffset:2e3},initialize:function(t,e){this.type=L.Draw.Marker.TYPE,this._initialLabelText=L.drawLocal.draw.handlers.marker.tooltip.start,L.Draw.Feature.prototype.initialize.call(this,t,e)},addHooks:function(){L.Draw.Feature.prototype.addHooks.call(this),this._map&&(this._tooltip.updateContent({text:this._initialLabelText}),this._mouseMarker||(this._mouseMarker=L.marker(this._map.getCenter(),{icon:L.divIcon({className:"leaflet-mouse-marker",iconAnchor:[20,20],iconSize:[40,40]}),opacity:0,zIndexOffset:this.options.zIndexOffset})),this._mouseMarker.on("click",this._onClick,this).addTo(this._map),this._map.on("mousemove",this._onMouseMove,this),this._map.on("click",this._onTouch,this))},removeHooks:function(){L.Draw.Feature.prototype.removeHooks.call(this),this._map&&(this._map.off("click",this._onClick,this).off("click",this._onTouch,this),this._marker&&(this._marker.off("click",this._onClick,this),this._map.removeLayer(this._marker),delete this._marker),this._mouseMarker.off("click",this._onClick,this),this._map.removeLayer(this._mouseMarker),delete this._mouseMarker,this._map.off("mousemove",this._onMouseMove,this))},_onMouseMove:function(t){var e=t.latlng;this._tooltip.updatePosition(e),this._mouseMarker.setLatLng(e),this._marker?(e=this._mouseMarker.getLatLng(),this._marker.setLatLng(e)):(this._marker=this._createMarker(e),this._marker.on("click",this._onClick,this),this._map.on("click",this._onClick,this).addLayer(this._marker))},_createMarker:function(t){return new L.Marker(t,{icon:this.options.icon,zIndexOffset:this.options.zIndexOffset})},_onClick:function(){this._fireCreatedEvent(),this.disable(),this.options.repeatMode&&this.enable()},_onTouch:function(t){this._onMouseMove(t),this._onClick()},_fireCreatedEvent:function(){var t=new L.Marker.Touch(this._marker.getLatLng(),{icon:this.options.icon});L.Draw.Feature.prototype._fireCreatedEvent.call(this,t)}}),L.Draw.CircleMarker=L.Draw.Marker.extend({statics:{TYPE:"circlemarker"},options:{stroke:!0,color:"#3388ff",weight:4,opacity:.5,fill:!0,fillColor:null,fillOpacity:.2,clickable:!0,zIndexOffset:2e3},initialize:function(t,e){this.type=L.Draw.CircleMarker.TYPE,this._initialLabelText=L.drawLocal.draw.handlers.circlemarker.tooltip.start,L.Draw.Feature.prototype.initialize.call(this,t,e)},_fireCreatedEvent:function(){var t=new L.CircleMarker(this._marker.getLatLng(),this.options);L.Draw.Feature.prototype._fireCreatedEvent.call(this,t)},_createMarker:function(t){return new L.CircleMarker(t,this.options)}}),L.Draw.Circle=L.Draw.SimpleShape.extend({statics:{TYPE:"circle"},options:{shapeOptions:{stroke:!0,color:"#3388ff",weight:4,opacity:.5,fill:!0,fillColor:null,fillOpacity:.2,clickable:!0},showRadius:!0,metric:!0,feet:!0,nautic:!1},initialize:function(t,e){this.type=L.Draw.Circle.TYPE,this._initialLabelText=L.drawLocal.draw.handlers.circle.tooltip.start,L.Draw.SimpleShape.prototype.initialize.call(this,t,e)},_drawShape:function(t){if(L.GeometryUtil.isVersion07x())var e=this._startLatLng.distanceTo(t);else var e=this._map.distance(this._startLatLng,t);this._shape?this._shape.setRadius(e):(this._shape=new L.Circle(this._startLatLng,e,this.options.shapeOptions),this._map.addLayer(this._shape))},_fireCreatedEvent:function(){var t=new L.Circle(this._startLatLng,this._shape.getRadius(),this.options.shapeOptions);L.Draw.SimpleShape.prototype._fireCreatedEvent.call(this,t)},_onMouseMove:function(t){var e,i=t.latlng,o=this.options.showRadius,a=this.options.metric;if(this._tooltip.updatePosition(i),this._isDrawing){this._drawShape(i),e=this._shape.getRadius().toFixed(1);var n="";o&&(n=L.drawLocal.draw.handlers.circle.radius+": "+L.GeometryUtil.readableDistance(e,a,this.options.feet,this.options.nautic)),this._tooltip.updateContent({text:this._endLabelText,subtext:n})}}}),L.Edit=L.Edit||{},L.Edit.Marker=L.Handler.extend({initialize:function(t,e){this._marker=t,L.setOptions(this,e)},addHooks:function(){var t=this._marker;t.dragging.enable(),t.on("dragend",this._onDragEnd,t),this._toggleMarkerHighlight()},removeHooks:function(){var t=this._marker;t.dragging.disable(),t.off("dragend",this._onDragEnd,t),this._toggleMarkerHighlight()},_onDragEnd:function(t){var e=t.target;e.edited=!0,this._map.fire(L.Draw.Event.EDITMOVE,{layer:e})},_toggleMarkerHighlight:function(){var t=this._marker._icon;t&&(t.style.display="none",L.DomUtil.hasClass(t,"leaflet-edit-marker-selected")?(L.DomUtil.removeClass(t,"leaflet-edit-marker-selected"),this._offsetMarker(t,-4)):(L.DomUtil.addClass(t,"leaflet-edit-marker-selected"),this._offsetMarker(t,4)),t.style.display="")},_offsetMarker:function(t,e){var i=parseInt(t.style.marginTop,10)-e,o=parseInt(t.style.marginLeft,10)-e;t.style.marginTop=i+"px",t.style.marginLeft=o+"px"}}),L.Marker.addInitHook(function(){L.Edit.Marker&&(this.editing=new L.Edit.Marker(this),this.options.editable&&this.editing.enable())}),L.Edit=L.Edit||{},L.Edit.Poly=L.Handler.extend({initialize:function(t){this.latlngs=[t._latlngs],t._holes&&(this.latlngs=this.latlngs.concat(t._holes)),this._poly=t,this._poly.on("revert-edited",this._updateLatLngs,this)},_defaultShape:function(){return L.Polyline._flat?L.Polyline._flat(this._poly._latlngs)?this._poly._latlngs:this._poly._latlngs[0]:this._poly._latlngs},_eachVertexHandler:function(t){for(var e=0;et&&(i._index+=e)})},_createMiddleMarker:function(t,e){var i,o,a,n=this._getMiddleLatLng(t,e),s=this._createMarker(n);s.setOpacity(.6),t._middleRight=e._middleLeft=s,o=function(){s.off("touchmove",o,this);var a=e._index;s._index=a,s.off("click",i,this).on("click",this._onMarkerClick,this),n.lat=s.getLatLng().lat,n.lng=s.getLatLng().lng,this._spliceLatLngs(a,0,n),this._markers.splice(a,0,s),s.setOpacity(1),this._updateIndexes(a,1),e._index++,this._updatePrevNext(t,s),this._updatePrevNext(s,e),this._poly.fire("editstart")},a=function(){s.off("dragstart",o,this),s.off("dragend",a,this),s.off("touchmove",o,this),this._createMiddleMarker(t,s),this._createMiddleMarker(s,e)},i=function(){o.call(this),a.call(this),this._fireEdit()},s.on("click",i,this).on("dragstart",o,this).on("dragend",a,this).on("touchmove",o,this),this._markerGroup.addLayer(s)},_updatePrevNext:function(t,e){t&&(t._next=e),e&&(e._prev=t)},_getMiddleLatLng:function(t,e){var i=this._poly._map,o=i.project(t.getLatLng()),a=i.project(e.getLatLng());return i.unproject(o._add(a)._divideBy(2))}}),L.Polyline.addInitHook(function(){this.editing||(L.Edit.Poly&&(this.editing=new L.Edit.Poly(this),this.options.editable&&this.editing.enable()),this.on("add",function(){this.editing&&this.editing.enabled()&&this.editing.addHooks()}),this.on("remove",function(){this.editing&&this.editing.enabled()&&this.editing.removeHooks()}))}),L.Edit=L.Edit||{},L.Edit.SimpleShape=L.Handler.extend({options:{moveIcon:new L.DivIcon({iconSize:new L.Point(8,8),className:"leaflet-div-icon leaflet-editing-icon leaflet-edit-move"}),resizeIcon:new L.DivIcon({iconSize:new L.Point(8,8), +className:"leaflet-div-icon leaflet-editing-icon leaflet-edit-resize"}),touchMoveIcon:new L.DivIcon({iconSize:new L.Point(20,20),className:"leaflet-div-icon leaflet-editing-icon leaflet-edit-move leaflet-touch-icon"}),touchResizeIcon:new L.DivIcon({iconSize:new L.Point(20,20),className:"leaflet-div-icon leaflet-editing-icon leaflet-edit-resize leaflet-touch-icon"})},initialize:function(t,e){L.Browser.touch&&(this.options.moveIcon=this.options.touchMoveIcon,this.options.resizeIcon=this.options.touchResizeIcon),this._shape=t,L.Util.setOptions(this,e)},addHooks:function(){var t=this._shape;this._shape._map&&(this._map=this._shape._map,t.setStyle(t.options.editing),t._map&&(this._map=t._map,this._markerGroup||this._initMarkers(),this._map.addLayer(this._markerGroup)))},removeHooks:function(){var t=this._shape;if(t.setStyle(t.options.original),t._map){this._unbindMarker(this._moveMarker);for(var e=0,i=this._resizeMarkers.length;e"+L.drawLocal.edit.handlers.edit.tooltip.text,subtext:L.drawLocal.draw.handlers.circle.radius+": "+L.GeometryUtil.readableDistance(radius,!0,this.options.feet,this.options.nautic)})),this._shape.setRadius(radius),this._map.fire(L.Draw.Event.EDITRESIZE,{layer:this._shape})}}),L.Circle.addInitHook(function(){L.Edit.Circle&&(this.editing=new L.Edit.Circle(this),this.options.editable&&this.editing.enable())}),L.Map.mergeOptions({touchExtend:!0}),L.Map.TouchExtend=L.Handler.extend({initialize:function(t){this._map=t,this._container=t._container,this._pane=t._panes.overlayPane},addHooks:function(){L.DomEvent.on(this._container,"touchstart",this._onTouchStart,this),L.DomEvent.on(this._container,"touchend",this._onTouchEnd,this),L.DomEvent.on(this._container,"touchmove",this._onTouchMove,this),this._detectIE()?(L.DomEvent.on(this._container,"MSPointerDown",this._onTouchStart,this),L.DomEvent.on(this._container,"MSPointerUp",this._onTouchEnd,this),L.DomEvent.on(this._container,"MSPointerMove",this._onTouchMove,this),L.DomEvent.on(this._container,"MSPointerCancel",this._onTouchCancel,this)):(L.DomEvent.on(this._container,"touchcancel",this._onTouchCancel,this),L.DomEvent.on(this._container,"touchleave",this._onTouchLeave,this))},removeHooks:function(){L.DomEvent.off(this._container,"touchstart",this._onTouchStart,this),L.DomEvent.off(this._container,"touchend",this._onTouchEnd,this),L.DomEvent.off(this._container,"touchmove",this._onTouchMove,this),this._detectIE()?(L.DomEvent.off(this._container,"MSPointerDown",this._onTouchStart,this),L.DomEvent.off(this._container,"MSPointerUp",this._onTouchEnd,this),L.DomEvent.off(this._container,"MSPointerMove",this._onTouchMove,this),L.DomEvent.off(this._container,"MSPointerCancel",this._onTouchCancel,this)):(L.DomEvent.off(this._container,"touchcancel",this._onTouchCancel,this),L.DomEvent.off(this._container,"touchleave",this._onTouchLeave,this))},_touchEvent:function(t,e){var i={};if(void 0!==t.touches){if(!t.touches.length)return;i=t.touches[0]}else{if("touch"!==t.pointerType)return;if(i=t,!this._filterClick(t))return}var o=this._map.mouseEventToContainerPoint(i),a=this._map.mouseEventToLayerPoint(i),n=this._map.layerPointToLatLng(a);this._map.fire(e,{latlng:n,layerPoint:a,containerPoint:o,pageX:i.pageX,pageY:i.pageY,originalEvent:t})},_filterClick:function(t){var e=t.timeStamp||t.originalEvent.timeStamp,i=L.DomEvent._lastClick&&e-L.DomEvent._lastClick;return i&&i>100&&i<500||t.target._simulatedClick&&!t._simulated?(L.DomEvent.stop(t),!1):(L.DomEvent._lastClick=e,!0)},_onTouchStart:function(t){if(this._map._loaded){this._touchEvent(t,"touchstart")}},_onTouchEnd:function(t){if(this._map._loaded){this._touchEvent(t,"touchend")}},_onTouchCancel:function(t){if(this._map._loaded){var e="touchcancel";this._detectIE()&&(e="pointercancel"),this._touchEvent(t,e)}},_onTouchLeave:function(t){if(this._map._loaded){this._touchEvent(t,"touchleave")}},_onTouchMove:function(t){if(this._map._loaded){this._touchEvent(t,"touchmove")}},_detectIE:function(){var e=t.navigator.userAgent,i=e.indexOf("MSIE ");if(i>0)return parseInt(e.substring(i+5,e.indexOf(".",i)),10);if(e.indexOf("Trident/")>0){var o=e.indexOf("rv:");return parseInt(e.substring(o+3,e.indexOf(".",o)),10)}var a=e.indexOf("Edge/");return a>0&&parseInt(e.substring(a+5,e.indexOf(".",a)),10)}}),L.Map.addInitHook("addHandler","touchExtend",L.Map.TouchExtend),L.Marker.Touch=L.Marker.extend({_initInteraction:function(){return this.addInteractiveTarget?L.Marker.prototype._initInteraction.apply(this):this._initInteractionLegacy()},_initInteractionLegacy:function(){if(this.options.clickable){var t=this._icon,e=["dblclick","mousedown","mouseover","mouseout","contextmenu","touchstart","touchend","touchmove"];this._detectIE?e.concat(["MSPointerDown","MSPointerUp","MSPointerMove","MSPointerCancel"]):e.concat(["touchcancel"]),L.DomUtil.addClass(t,"leaflet-clickable"),L.DomEvent.on(t,"click",this._onMouseClick,this),L.DomEvent.on(t,"keypress",this._onKeyPress,this);for(var i=0;i0)return parseInt(e.substring(i+5,e.indexOf(".",i)),10);if(e.indexOf("Trident/")>0){var o=e.indexOf("rv:");return parseInt(e.substring(o+3,e.indexOf(".",o)),10)}var a=e.indexOf("Edge/");return a>0&&parseInt(e.substring(a+5,e.indexOf(".",a)),10)}}),L.LatLngUtil={cloneLatLngs:function(t){for(var e=[],i=0,o=t.length;i2){for(var s=0;s1&&(i=i+s+r[1])}return i},readableArea:function(e,i,o){var a,n,o=L.Util.extend({},t,o);return i?(n=["ha","m"],type=typeof i,"string"===type?n=[i]:"boolean"!==type&&(n=i),a=e>=1e6&&-1!==n.indexOf("km")?L.GeometryUtil.formattedNumber(1e-6*e,o.km)+" km²":e>=1e4&&-1!==n.indexOf("ha")?L.GeometryUtil.formattedNumber(1e-4*e,o.ha)+" ha":L.GeometryUtil.formattedNumber(e,o.m)+" m²"):(e/=.836127,a=e>=3097600?L.GeometryUtil.formattedNumber(e/3097600,o.mi)+" mi²":e>=4840?L.GeometryUtil.formattedNumber(e/4840,o.ac)+" acres":L.GeometryUtil.formattedNumber(e,o.yd)+" yd²"),a},readableDistance:function(e,i,o,a,n){var s,n=L.Util.extend({},t,n);switch(i?"string"==typeof i?i:"metric":o?"feet":a?"nauticalMile":"yards"){case"metric":s=e>1e3?L.GeometryUtil.formattedNumber(e/1e3,n.km)+" km":L.GeometryUtil.formattedNumber(e,n.m)+" m";break;case"feet":e*=3.28083,s=L.GeometryUtil.formattedNumber(e,n.ft)+" ft";break;case"nauticalMile":e*=.53996,s=L.GeometryUtil.formattedNumber(e/1e3,n.nm)+" nm";break;case"yards":default:e*=1.09361,s=e>1760?L.GeometryUtil.formattedNumber(e/1760,n.mi)+" miles":L.GeometryUtil.formattedNumber(e,n.yd)+" yd"}return s},isVersion07x:function(){var t=L.version.split(".");return 0===parseInt(t[0],10)&&7===parseInt(t[1],10)}})}(),L.Util.extend(L.LineUtil,{segmentsIntersect:function(t,e,i,o){return this._checkCounterclockwise(t,i,o)!==this._checkCounterclockwise(e,i,o)&&this._checkCounterclockwise(t,e,i)!==this._checkCounterclockwise(t,e,o)},_checkCounterclockwise:function(t,e,i){return(i.y-t.y)*(e.x-t.x)>(e.y-t.y)*(i.x-t.x)}}),L.Polyline.include({intersects:function(){var t,e,i,o=this._getProjectedPoints(),a=o?o.length:0;if(this._tooFewPointsForIntersection())return!1;for(t=a-1;t>=3;t--)if(e=o[t-1],i=o[t],this._lineSegmentsIntersectsRange(e,i,t-2))return!0;return!1},newLatLngIntersects:function(t,e){return!!this._map&&this.newPointIntersects(this._map.latLngToLayerPoint(t),e)},newPointIntersects:function(t,e){var i=this._getProjectedPoints(),o=i?i.length:0,a=i?i[o-1]:null,n=o-2;return!this._tooFewPointsForIntersection(1)&&this._lineSegmentsIntersectsRange(a,t,n,e?1:0)},_tooFewPointsForIntersection:function(t){var e=this._getProjectedPoints(),i=e?e.length:0;return i+=t||0,!e||i<=3},_lineSegmentsIntersectsRange:function(t,e,i,o){var a,n,s=this._getProjectedPoints();o=o||0;for(var r=i;r>o;r--)if(a=s[r-1],n=s[r],L.LineUtil.segmentsIntersect(t,e,a,n))return!0;return!1},_getProjectedPoints:function(){if(!this._defaultShape)return this._originalPoints;for(var t=[],e=this._defaultShape(),i=0;i=2?L.Toolbar.include(L.Evented.prototype):L.Toolbar.include(L.Mixin.Events)},enabled:function(){return null!==this._activeMode},disable:function(){this.enabled()&&this._activeMode.handler.disable()},addToolbar:function(t){var e,i=L.DomUtil.create("div","leaflet-draw-section"),o=0,a=this._toolbarClass||"",n=this.getModeHandlers(t);for(this._toolbarContainer=L.DomUtil.create("div","leaflet-draw-toolbar leaflet-bar"),this._map=t,e=0;e0&&this._singleLineLabel&&(L.DomUtil.removeClass(this._container,"leaflet-draw-tooltip-single"),this._singleLineLabel=!1):(L.DomUtil.addClass(this._container,"leaflet-draw-tooltip-single"),this._singleLineLabel=!0),this._container.innerHTML=(t.subtext.length>0?''+t.subtext+"
":"")+""+t.text+"",t.text||t.subtext?(this._visible=!0,this._container.style.visibility="inherit"):(this._visible=!1,this._container.style.visibility="hidden"),this):this},updatePosition:function(t){var e=this._map.latLngToLayerPoint(t),i=this._container;return this._container&&(this._visible&&(i.style.visibility="inherit"),L.DomUtil.setPosition(i,e)),this},showAsError:function(){return this._container&&L.DomUtil.addClass(this._container,"leaflet-error-draw-tooltip"),this},removeError:function(){return this._container&&L.DomUtil.removeClass(this._container,"leaflet-error-draw-tooltip"),this},_onMouseOut:function(){this._container&&(this._container.style.visibility="hidden")}}),L.DrawToolbar=L.Toolbar.extend({statics:{TYPE:"draw"},options:{polyline:{},polygon:{},rectangle:{},circle:{},marker:{},circlemarker:{}},initialize:function(t){for(var e in this.options)this.options.hasOwnProperty(e)&&t[e]&&(t[e]=L.extend({},this.options[e],t[e]));this._toolbarClass="leaflet-draw-draw",L.Toolbar.prototype.initialize.call(this,t)},getModeHandlers:function(t){return[{enabled:this.options.polyline,handler:new L.Draw.Polyline(t,this.options.polyline),title:L.drawLocal.draw.toolbar.buttons.polyline},{enabled:this.options.polygon,handler:new L.Draw.Polygon(t,this.options.polygon),title:L.drawLocal.draw.toolbar.buttons.polygon},{enabled:this.options.rectangle,handler:new L.Draw.Rectangle(t,this.options.rectangle),title:L.drawLocal.draw.toolbar.buttons.rectangle},{enabled:this.options.circle,handler:new L.Draw.Circle(t,this.options.circle),title:L.drawLocal.draw.toolbar.buttons.circle},{enabled:this.options.marker,handler:new L.Draw.Marker(t,this.options.marker),title:L.drawLocal.draw.toolbar.buttons.marker},{enabled:this.options.circlemarker,handler:new L.Draw.CircleMarker(t,this.options.circlemarker),title:L.drawLocal.draw.toolbar.buttons.circlemarker}]},getActions:function(t){return[{enabled:t.completeShape,title:L.drawLocal.draw.toolbar.finish.title,text:L.drawLocal.draw.toolbar.finish.text,callback:t.completeShape,context:t},{enabled:t.deleteLastVertex,title:L.drawLocal.draw.toolbar.undo.title,text:L.drawLocal.draw.toolbar.undo.text,callback:t.deleteLastVertex,context:t},{title:L.drawLocal.draw.toolbar.actions.title,text:L.drawLocal.draw.toolbar.actions.text,callback:this.disable,context:this}]},setOptions:function(t){L.setOptions(this,t);for(var e in this._modes)this._modes.hasOwnProperty(e)&&t.hasOwnProperty(e)&&this._modes[e].handler.setOptions(t[e])}}),L.EditToolbar=L.Toolbar.extend({statics:{TYPE:"edit"},options:{edit:{selectedPathOptions:{dashArray:"10, 10",fill:!0,fillColor:"#fe57a1",fillOpacity:.1,maintainColor:!1}},remove:{},poly:null,featureGroup:null},initialize:function(t){t.edit&&(void 0===t.edit.selectedPathOptions&&(t.edit.selectedPathOptions=this.options.edit.selectedPathOptions),t.edit.selectedPathOptions=L.extend({},this.options.edit.selectedPathOptions,t.edit.selectedPathOptions)),t.remove&&(t.remove=L.extend({},this.options.remove,t.remove)),t.poly&&(t.poly=L.extend({},this.options.poly,t.poly)),this._toolbarClass="leaflet-draw-edit",L.Toolbar.prototype.initialize.call(this,t),this._selectedFeatureCount=0},getModeHandlers:function(t){var e=this.options.featureGroup;return[{enabled:this.options.edit,handler:new L.EditToolbar.Edit(t,{featureGroup:e,selectedPathOptions:this.options.edit.selectedPathOptions,poly:this.options.poly}),title:L.drawLocal.edit.toolbar.buttons.edit},{enabled:this.options.remove,handler:new L.EditToolbar.Delete(t,{featureGroup:e}),title:L.drawLocal.edit.toolbar.buttons.remove}]},getActions:function(t){var e=[{title:L.drawLocal.edit.toolbar.actions.save.title,text:L.drawLocal.edit.toolbar.actions.save.text,callback:this._save,context:this},{title:L.drawLocal.edit.toolbar.actions.cancel.title,text:L.drawLocal.edit.toolbar.actions.cancel.text,callback:this.disable,context:this}];return t.removeAllLayers&&e.push({title:L.drawLocal.edit.toolbar.actions.clearAll.title,text:L.drawLocal.edit.toolbar.actions.clearAll.text,callback:this._clearAllLayers,context:this}),e},addToolbar:function(t){var e=L.Toolbar.prototype.addToolbar.call(this,t);return this._checkDisabled(),this.options.featureGroup.on("layeradd layerremove",this._checkDisabled,this),e},removeToolbar:function(){this.options.featureGroup.off("layeradd layerremove",this._checkDisabled,this),L.Toolbar.prototype.removeToolbar.call(this)},disable:function(){this.enabled()&&(this._activeMode.handler.revertLayers(),L.Toolbar.prototype.disable.call(this))},_save:function(){this._activeMode.handler.save(),this._activeMode&&this._activeMode.handler.disable()},_clearAllLayers:function(){this._activeMode.handler.removeAllLayers(),this._activeMode&&this._activeMode.handler.disable()},_checkDisabled:function(){var t,e=this.options.featureGroup,i=0!==e.getLayers().length;this.options.edit&&(t=this._modes[L.EditToolbar.Edit.TYPE].button,i?L.DomUtil.removeClass(t,"leaflet-disabled"):L.DomUtil.addClass(t,"leaflet-disabled"),t.setAttribute("title",i?L.drawLocal.edit.toolbar.buttons.edit:L.drawLocal.edit.toolbar.buttons.editDisabled)),this.options.remove&&(t=this._modes[L.EditToolbar.Delete.TYPE].button,i?L.DomUtil.removeClass(t,"leaflet-disabled"):L.DomUtil.addClass(t,"leaflet-disabled"),t.setAttribute("title",i?L.drawLocal.edit.toolbar.buttons.remove:L.drawLocal.edit.toolbar.buttons.removeDisabled))}}),L.EditToolbar.Edit=L.Handler.extend({statics:{TYPE:"edit"},initialize:function(t,e){if(L.Handler.prototype.initialize.call(this,t),L.setOptions(this,e),this._featureGroup=e.featureGroup,!(this._featureGroup instanceof L.FeatureGroup))throw new Error("options.featureGroup must be a L.FeatureGroup");this._uneditedLayerProps={},this.type=L.EditToolbar.Edit.TYPE;var i=L.version.split(".");1===parseInt(i[0],10)&&parseInt(i[1],10)>=2?L.EditToolbar.Edit.include(L.Evented.prototype):L.EditToolbar.Edit.include(L.Mixin.Events)},enable:function(){!this._enabled&&this._hasAvailableLayers()&&(this.fire("enabled",{handler:this.type}),this._map.fire(L.Draw.Event.EDITSTART,{handler:this.type}),L.Handler.prototype.enable.call(this),this._featureGroup.on("layeradd",this._enableLayerEdit,this).on("layerremove",this._disableLayerEdit,this))},disable:function(){this._enabled&&(this._featureGroup.off("layeradd",this._enableLayerEdit,this).off("layerremove",this._disableLayerEdit,this),L.Handler.prototype.disable.call(this),this._map.fire(L.Draw.Event.EDITSTOP,{handler:this.type}),this.fire("disabled",{handler:this.type}))},addHooks:function(){var t=this._map;t&&(t.getContainer().focus(),this._featureGroup.eachLayer(this._enableLayerEdit,this),this._tooltip=new L.Draw.Tooltip(this._map),this._tooltip.updateContent({text:L.drawLocal.edit.handlers.edit.tooltip.text,subtext:L.drawLocal.edit.handlers.edit.tooltip.subtext}),t._editTooltip=this._tooltip,this._updateTooltip(),this._map.on("mousemove",this._onMouseMove,this).on("touchmove",this._onMouseMove,this).on("MSPointerMove",this._onMouseMove,this).on(L.Draw.Event.EDITVERTEX,this._updateTooltip,this))},removeHooks:function(){this._map&&(this._featureGroup.eachLayer(this._disableLayerEdit,this),this._map._editTooltip.dispose(),this._map._editTooltip=null,this._uneditedLayerProps={},this._tooltip.dispose(),this._tooltip=null,this._map.off("mousemove",this._onMouseMove,this).off("touchmove",this._onMouseMove,this).off("MSPointerMove",this._onMouseMove,this).off(L.Draw.Event.EDITVERTEX,this._updateTooltip,this))},revertLayers:function(){this._featureGroup.eachLayer(function(t){this._revertLayer(t)},this)},save:function(){var t=new L.LayerGroup;this._featureGroup.eachLayer(function(e){e.edited&&(t.addLayer(e),e.edited=!1)}),this._map.fire(L.Draw.Event.EDITED,{layers:t})},_backupLayer:function(t){var e=L.Util.stamp(t);this._uneditedLayerProps[e]||(t instanceof L.Polyline||t instanceof L.Polygon||t instanceof L.Rectangle?this._uneditedLayerProps[e]={latlngs:L.LatLngUtil.cloneLatLngs(t.getLatLngs())}:t instanceof L.Circle?this._uneditedLayerProps[e]={latlng:L.LatLngUtil.cloneLatLng(t.getLatLng()),radius:t.getRadius()}:(t instanceof L.Marker||t instanceof L.CircleMarker)&&(this._uneditedLayerProps[e]={latlng:L.LatLngUtil.cloneLatLng(t.getLatLng())}))},_getTooltipText:function(){return{text:L.drawLocal.edit.handlers.edit.tooltip.text,subtext:L.drawLocal.edit.handlers.edit.tooltip.subtext}},_updateTooltip:function(){this._tooltip.updateContent(this._getTooltipText())},_revertLayer:function(t){var e=L.Util.stamp(t);t.edited=!1,this._uneditedLayerProps.hasOwnProperty(e)&&(t instanceof L.Polyline||t instanceof L.Polygon||t instanceof L.Rectangle?t.setLatLngs(this._uneditedLayerProps[e].latlngs):t instanceof L.Circle?(t.setLatLng(this._uneditedLayerProps[e].latlng),t.setRadius(this._uneditedLayerProps[e].radius)):(t instanceof L.Marker||t instanceof L.CircleMarker)&&t.setLatLng(this._uneditedLayerProps[e].latlng),t.fire("revert-edited",{layer:t}))},_enableLayerEdit:function(t){var e,i,o=t.layer||t.target||t;this._backupLayer(o),this.options.poly&&(i=L.Util.extend({},this.options.poly),o.options.poly=i),this.options.selectedPathOptions&&(e=L.Util.extend({},this.options.selectedPathOptions),e.maintainColor&&(e.color=o.options.color,e.fillColor=o.options.fillColor),o.options.original=L.extend({},o.options),o.options.editing=e),o instanceof L.Marker?(o.editing&&o.editing.enable(),o.dragging.enable(),o.on("dragend",this._onMarkerDragEnd).on("touchmove",this._onTouchMove,this).on("MSPointerMove",this._onTouchMove,this).on("touchend",this._onMarkerDragEnd,this).on("MSPointerUp",this._onMarkerDragEnd,this)):o.editing.enable()},_disableLayerEdit:function(t){var e=t.layer||t.target||t;e.edited=!1,e.editing&&e.editing.disable(), +delete e.options.editing,delete e.options.original,this._selectedPathOptions&&(e instanceof L.Marker?this._toggleMarkerHighlight(e):(e.setStyle(e.options.previousOptions),delete e.options.previousOptions)),e instanceof L.Marker?(e.dragging.disable(),e.off("dragend",this._onMarkerDragEnd,this).off("touchmove",this._onTouchMove,this).off("MSPointerMove",this._onTouchMove,this).off("touchend",this._onMarkerDragEnd,this).off("MSPointerUp",this._onMarkerDragEnd,this)):e.editing.disable()},_onMouseMove:function(t){this._tooltip.updatePosition(t.latlng)},_onMarkerDragEnd:function(t){var e=t.target;e.edited=!0,this._map.fire(L.Draw.Event.EDITMOVE,{layer:e})},_onTouchMove:function(t){var e=t.originalEvent.changedTouches[0],i=this._map.mouseEventToLayerPoint(e),o=this._map.layerPointToLatLng(i);t.target.setLatLng(o)},_hasAvailableLayers:function(){return 0!==this._featureGroup.getLayers().length}}),L.EditToolbar.Delete=L.Handler.extend({statics:{TYPE:"remove"},initialize:function(t,e){if(L.Handler.prototype.initialize.call(this,t),L.Util.setOptions(this,e),this._deletableLayers=this.options.featureGroup,!(this._deletableLayers instanceof L.FeatureGroup))throw new Error("options.featureGroup must be a L.FeatureGroup");this.type=L.EditToolbar.Delete.TYPE;var i=L.version.split(".");1===parseInt(i[0],10)&&parseInt(i[1],10)>=2?L.EditToolbar.Delete.include(L.Evented.prototype):L.EditToolbar.Delete.include(L.Mixin.Events)},enable:function(){!this._enabled&&this._hasAvailableLayers()&&(this.fire("enabled",{handler:this.type}),this._map.fire(L.Draw.Event.DELETESTART,{handler:this.type}),L.Handler.prototype.enable.call(this),this._deletableLayers.on("layeradd",this._enableLayerDelete,this).on("layerremove",this._disableLayerDelete,this))},disable:function(){this._enabled&&(this._deletableLayers.off("layeradd",this._enableLayerDelete,this).off("layerremove",this._disableLayerDelete,this),L.Handler.prototype.disable.call(this),this._map.fire(L.Draw.Event.DELETESTOP,{handler:this.type}),this.fire("disabled",{handler:this.type}))},addHooks:function(){var t=this._map;t&&(t.getContainer().focus(),this._deletableLayers.eachLayer(this._enableLayerDelete,this),this._deletedLayers=new L.LayerGroup,this._tooltip=new L.Draw.Tooltip(this._map),this._tooltip.updateContent({text:L.drawLocal.edit.handlers.remove.tooltip.text}),this._map.on("mousemove",this._onMouseMove,this))},removeHooks:function(){this._map&&(this._deletableLayers.eachLayer(this._disableLayerDelete,this),this._deletedLayers=null,this._tooltip.dispose(),this._tooltip=null,this._map.off("mousemove",this._onMouseMove,this))},revertLayers:function(){this._deletedLayers.eachLayer(function(t){this._deletableLayers.addLayer(t),t.fire("revert-deleted",{layer:t})},this)},save:function(){this._map.fire(L.Draw.Event.DELETED,{layers:this._deletedLayers})},removeAllLayers:function(){this._deletableLayers.eachLayer(function(t){this._removeLayer({layer:t})},this),this.save()},_enableLayerDelete:function(t){(t.layer||t.target||t).on("click",this._removeLayer,this)},_disableLayerDelete:function(t){var e=t.layer||t.target||t;e.off("click",this._removeLayer,this),this._deletedLayers.removeLayer(e)},_removeLayer:function(t){var e=t.layer||t.target||t;this._deletableLayers.removeLayer(e),this._deletedLayers.addLayer(e),e.fire("deleted")},_onMouseMove:function(t){this._tooltip.updatePosition(t.latlng)},_hasAvailableLayers:function(){return 0!==this._deletableLayers.getLayers().length}})}(window,document); \ No newline at end of file From 638b962d9f526ad1ca003abccaac2a3cf04218fb Mon Sep 17 00:00:00 2001 From: BONDA Sai Aswath Date: Wed, 19 Jan 2022 19:52:37 +0530 Subject: [PATCH 3/6] renaming editTooltip to _editTooltip --- src/edit/handler/Edit.Circle.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/edit/handler/Edit.Circle.js b/src/edit/handler/Edit.Circle.js index 09aade594..600d1cc0e 100644 --- a/src/edit/handler/Edit.Circle.js +++ b/src/edit/handler/Edit.Circle.js @@ -32,7 +32,7 @@ L.Edit.Circle = L.Edit.CircleMarker.extend({ } this._shape.setRadius(radius); - if (this._map.editTooltip) { + if (this._map._editTooltip) { this._map._editTooltip.updatePosition(latlng); this._map._editTooltip.updateContent({ text: L.drawLocal.edit.handlers.edit.tooltip.subtext + '
' + L.drawLocal.edit.handlers.edit.tooltip.text, From 374c0d30c928bfb5ded25e30f453c2aef1eb9bac Mon Sep 17 00:00:00 2001 From: BONDA Sai Aswath Date: Wed, 2 Feb 2022 16:20:39 +0530 Subject: [PATCH 4/6] renaming editTooltip to _editTooltip in leaflet draw main files --- dist/leaflet.draw-src.js | 6 +++--- dist/leaflet.draw-src.map | 2 +- dist/leaflet.draw.js | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/dist/leaflet.draw-src.js b/dist/leaflet.draw-src.js index 21f4d5059..02a6353b2 100644 --- a/dist/leaflet.draw-src.js +++ b/dist/leaflet.draw-src.js @@ -1,5 +1,5 @@ /* - Leaflet.draw 1.0.3+e90ec6d, a plugin that adds drawing and editing tools to Leaflet powered maps. + Leaflet.draw 1.0.3+638b962, a plugin that adds drawing and editing tools to Leaflet powered maps. (c) 2012-2017, Jacob Toye, Jon West, Smartrak, Leaflet https://github.com/Leaflet/Leaflet.draw @@ -8,7 +8,7 @@ (function (window, document, undefined) {/** * Leaflet.draw assumes that you have already included the Leaflet library. */ -L.drawVersion = "1.0.3+e90ec6d"; +L.drawVersion = "1.0.3+638b962"; /** * @class L.Draw * @aka Draw @@ -2754,7 +2754,7 @@ L.Edit.Circle = L.Edit.CircleMarker.extend({ } this._shape.setRadius(radius); - if (this._map.editTooltip) { + if (this._map._editTooltip) { this._map._editTooltip.updatePosition(latlng); this._map._editTooltip.updateContent({ text: L.drawLocal.edit.handlers.edit.tooltip.subtext + '
' + L.drawLocal.edit.handlers.edit.tooltip.text, diff --git a/dist/leaflet.draw-src.map b/dist/leaflet.draw-src.map index 81a68cc98..d13d09e00 100644 --- a/dist/leaflet.draw-src.map +++ b/dist/leaflet.draw-src.map @@ -1 +1 @@ -{"version":3,"sources":["src/Leaflet.draw.js","src/Leaflet.Draw.Event.js","src/draw/handler/Draw.Feature.js","src/draw/handler/Draw.Polyline.js","src/draw/handler/Draw.Polygon.js","src/draw/handler/Draw.SimpleShape.js","src/draw/handler/Draw.Rectangle.js","src/draw/handler/Draw.Marker.js","src/draw/handler/Draw.CircleMarker.js","src/draw/handler/Draw.Circle.js","src/edit/handler/Edit.Marker.js","src/edit/handler/Edit.Poly.js","src/edit/handler/Edit.SimpleShape.js","src/edit/handler/Edit.Rectangle.js","src/edit/handler/Edit.CircleMarker.js","src/edit/handler/Edit.Circle.js","src/ext/TouchEvents.js","src/ext/LatLngUtil.js","src/ext/GeometryUtil.js","src/ext/LineUtil.Intersect.js","src/ext/Polyline.Intersect.js","src/ext/Polygon.Intersect.js","src/Control.Draw.js","src/Toolbar.js","src/Tooltip.js","src/draw/DrawToolbar.js","src/edit/EditToolbar.js","src/edit/handler/EditToolbar.Edit.js","src/edit/handler/EditToolbar.Delete.js"],"names":[],"mappings":";;;;;;;yCAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC7LA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AChLA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACxGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AChlBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACjIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACvHA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AClGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC/HA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC1CA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACnFA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACpFA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACxgBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACrOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC7HA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACrDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC1DA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AChRA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC5BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACrKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACtBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC1GA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACjCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACtHA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC9UA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACtHA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC9GA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AClMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACnSA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","sourcesContent":["/**\r\n * Leaflet.draw assumes that you have already included the Leaflet library.\r\n */\r\nL.drawVersion = \"1.0.3+e90ec6d\";\r\n/**\r\n * @class L.Draw\r\n * @aka Draw\r\n *\r\n *\r\n * To add the draw toolbar set the option drawControl: true in the map options.\r\n *\r\n * @example\r\n * ```js\r\n * var map = L.map('map', {drawControl: true}).setView([51.505, -0.09], 13);\r\n *\r\n * L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {\r\n * attribution: '© OpenStreetMap contributors'\r\n * }).addTo(map);\r\n * ```\r\n *\r\n * ### Adding the edit toolbar\r\n * To use the edit toolbar you must initialise the Leaflet.draw control and manually add it to the map.\r\n *\r\n * ```js\r\n * var map = L.map('map').setView([51.505, -0.09], 13);\r\n *\r\n * L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {\r\n * attribution: '© OpenStreetMap contributors'\r\n * }).addTo(map);\r\n *\r\n * // FeatureGroup is to store editable layers\r\n * var drawnItems = new L.FeatureGroup();\r\n * map.addLayer(drawnItems);\r\n *\r\n * var drawControl = new L.Control.Draw({\r\n * edit: {\r\n * featureGroup: drawnItems\r\n * }\r\n * });\r\n * map.addControl(drawControl);\r\n * ```\r\n *\r\n * The key here is the featureGroup option. This tells the plugin which FeatureGroup contains the layers that\r\n * should be editable. The featureGroup can contain 0 or more features with geometry types Point, LineString, and Polygon.\r\n * Leaflet.draw does not work with multigeometry features such as MultiPoint, MultiLineString, MultiPolygon,\r\n * or GeometryCollection. If you need to add multigeometry features to the draw plugin, convert them to a\r\n * FeatureCollection of non-multigeometries (Points, LineStrings, or Polygons).\r\n */\r\nL.Draw = {};\r\n\r\n/**\r\n * @class L.drawLocal\r\n * @aka L.drawLocal\r\n *\r\n * The core toolbar class of the API — it is used to create the toolbar ui\r\n *\r\n * @example\r\n * ```js\r\n * var modifiedDraw = L.drawLocal.extend({\r\n * draw: {\r\n * toolbar: {\r\n * buttons: {\r\n * polygon: 'Draw an awesome polygon'\r\n * }\r\n * }\r\n * }\r\n * });\r\n * ```\r\n *\r\n * The default state for the control is the draw toolbar just below the zoom control.\r\n * This will allow map users to draw vectors and markers.\r\n * **Please note the edit toolbar is not enabled by default.**\r\n */\r\nL.drawLocal = {\r\n\t// format: {\r\n\t// \tnumeric: {\r\n\t// \t\tdelimiters: {\r\n\t// \t\t\tthousands: ',',\r\n\t// \t\t\tdecimal: '.'\r\n\t// \t\t}\r\n\t// \t}\r\n\t// },\r\n\tdraw: {\r\n\t\ttoolbar: {\r\n\t\t\t// #TODO: this should be reorganized where actions are nested in actions\r\n\t\t\t// ex: actions.undo or actions.cancel\r\n\t\t\tactions: {\r\n\t\t\t\ttitle: 'Cancel drawing',\r\n\t\t\t\ttext: 'Cancel'\r\n\t\t\t},\r\n\t\t\tfinish: {\r\n\t\t\t\ttitle: 'Finish drawing',\r\n\t\t\t\ttext: 'Finish'\r\n\t\t\t},\r\n\t\t\tundo: {\r\n\t\t\t\ttitle: 'Delete last point drawn',\r\n\t\t\t\ttext: 'Delete last point'\r\n\t\t\t},\r\n\t\t\tbuttons: {\r\n\t\t\t\tpolyline: 'Draw a polyline',\r\n\t\t\t\tpolygon: 'Draw a polygon',\r\n\t\t\t\trectangle: 'Draw a rectangle',\r\n\t\t\t\tcircle: 'Draw a circle',\r\n\t\t\t\tmarker: 'Draw a marker',\r\n\t\t\t\tcirclemarker: 'Draw a circlemarker'\r\n\t\t\t}\r\n\t\t},\r\n\t\thandlers: {\r\n\t\t\tcircle: {\r\n\t\t\t\ttooltip: {\r\n\t\t\t\t\tstart: 'Click and drag to draw circle.'\r\n\t\t\t\t},\r\n\t\t\t\tradius: 'Radius'\r\n\t\t\t},\r\n\t\t\tcirclemarker: {\r\n\t\t\t\ttooltip: {\r\n\t\t\t\t\tstart: 'Click map to place circle marker.'\r\n\t\t\t\t}\r\n\t\t\t},\r\n\t\t\tmarker: {\r\n\t\t\t\ttooltip: {\r\n\t\t\t\t\tstart: 'Click map to place marker.'\r\n\t\t\t\t}\r\n\t\t\t},\r\n\t\t\tpolygon: {\r\n\t\t\t\ttooltip: {\r\n\t\t\t\t\tstart: 'Click to start drawing shape.',\r\n\t\t\t\t\tcont: 'Click to continue drawing shape.',\r\n\t\t\t\t\tend: 'Click first point to close this shape.'\r\n\t\t\t\t}\r\n\t\t\t},\r\n\t\t\tpolyline: {\r\n\t\t\t\terror: 'Error: shape edges cannot cross!',\r\n\t\t\t\ttooltip: {\r\n\t\t\t\t\tstart: 'Click to start drawing line.',\r\n\t\t\t\t\tcont: 'Click to continue drawing line.',\r\n\t\t\t\t\tend: 'Click last point to finish line.'\r\n\t\t\t\t}\r\n\t\t\t},\r\n\t\t\trectangle: {\r\n\t\t\t\ttooltip: {\r\n\t\t\t\t\tstart: 'Click and drag to draw rectangle.'\r\n\t\t\t\t}\r\n\t\t\t},\r\n\t\t\tsimpleshape: {\r\n\t\t\t\ttooltip: {\r\n\t\t\t\t\tend: 'Release mouse to finish drawing.'\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t},\r\n\tedit: {\r\n\t\ttoolbar: {\r\n\t\t\tactions: {\r\n\t\t\t\tsave: {\r\n\t\t\t\t\ttitle: 'Save changes',\r\n\t\t\t\t\ttext: 'Save'\r\n\t\t\t\t},\r\n\t\t\t\tcancel: {\r\n\t\t\t\t\ttitle: 'Cancel editing, discards all changes',\r\n\t\t\t\t\ttext: 'Cancel'\r\n\t\t\t\t},\r\n\t\t\t\tclearAll: {\r\n\t\t\t\t\ttitle: 'Clear all layers',\r\n\t\t\t\t\ttext: 'Clear All'\r\n\t\t\t\t}\r\n\t\t\t},\r\n\t\t\tbuttons: {\r\n\t\t\t\tedit: 'Edit layers',\r\n\t\t\t\teditDisabled: 'No layers to edit',\r\n\t\t\t\tremove: 'Delete layers',\r\n\t\t\t\tremoveDisabled: 'No layers to delete'\r\n\t\t\t}\r\n\t\t},\r\n\t\thandlers: {\r\n\t\t\tedit: {\r\n\t\t\t\ttooltip: {\r\n\t\t\t\t\ttext: 'Drag handles or markers to edit features.',\r\n\t\t\t\t\tsubtext: 'Click cancel to undo changes.'\r\n\t\t\t\t}\r\n\t\t\t},\r\n\t\t\tremove: {\r\n\t\t\t\ttooltip: {\r\n\t\t\t\t\ttext: 'Click on a feature to remove.'\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n};\r\n","/**\r\n * ### Events\r\n * Once you have successfully added the Leaflet.draw plugin to your map you will want to respond to the different\r\n * actions users can initiate. The following events will be triggered on the map:\r\n *\r\n * @class L.Draw.Event\r\n * @aka Draw.Event\r\n *\r\n * Use `L.Draw.Event.EVENTNAME` constants to ensure events are correct.\r\n *\r\n * @example\r\n * ```js\r\n * map.on(L.Draw.Event.CREATED; function (e) {\r\n * var type = e.layerType,\r\n * layer = e.layer;\r\n *\r\n * if (type === 'marker') {\r\n * // Do marker specific actions\r\n * }\r\n *\r\n * // Do whatever else you need to. (save to db; add to map etc)\r\n * map.addLayer(layer);\r\n *});\r\n * ```\r\n */\r\nL.Draw.Event = {};\r\n/**\r\n * @event draw:created: PolyLine; Polygon; Rectangle; Circle; Marker | String\r\n *\r\n * Layer that was just created.\r\n * The type of layer this is. One of: `polyline`; `polygon`; `rectangle`; `circle`; `marker`\r\n * Triggered when a new vector or marker has been created.\r\n *\r\n */\r\nL.Draw.Event.CREATED = 'draw:created';\r\n\r\n/**\r\n * @event draw:edited: LayerGroup\r\n *\r\n * List of all layers just edited on the map.\r\n *\r\n *\r\n * Triggered when layers in the FeatureGroup; initialised with the plugin; have been edited and saved.\r\n *\r\n * @example\r\n * ```js\r\n * map.on('draw:edited', function (e) {\r\n * var layers = e.layers;\r\n * layers.eachLayer(function (layer) {\r\n * //do whatever you want; most likely save back to db\r\n * });\r\n * });\r\n * ```\r\n */\r\nL.Draw.Event.EDITED = 'draw:edited';\r\n\r\n/**\r\n * @event draw:deleted: LayerGroup\r\n *\r\n * List of all layers just removed from the map.\r\n *\r\n * Triggered when layers have been removed (and saved) from the FeatureGroup.\r\n */\r\nL.Draw.Event.DELETED = 'draw:deleted';\r\n\r\n/**\r\n * @event draw:drawstart: String\r\n *\r\n * The type of layer this is. One of:`polyline`; `polygon`; `rectangle`; `circle`; `marker`\r\n *\r\n * Triggered when the user has chosen to draw a particular vector or marker.\r\n */\r\nL.Draw.Event.DRAWSTART = 'draw:drawstart';\r\n\r\n/**\r\n * @event draw:drawstop: String\r\n *\r\n * The type of layer this is. One of: `polyline`; `polygon`; `rectangle`; `circle`; `marker`\r\n *\r\n * Triggered when the user has finished a particular vector or marker.\r\n */\r\n\r\nL.Draw.Event.DRAWSTOP = 'draw:drawstop';\r\n\r\n/**\r\n * @event draw:drawvertex: LayerGroup\r\n *\r\n * List of all layers just being added from the map.\r\n *\r\n * Triggered when a vertex is created on a polyline or polygon.\r\n */\r\nL.Draw.Event.DRAWVERTEX = 'draw:drawvertex';\r\n\r\n/**\r\n * @event draw:editstart: String\r\n *\r\n * The type of edit this is. One of: `edit`\r\n *\r\n * Triggered when the user starts edit mode by clicking the edit tool button.\r\n */\r\n\r\nL.Draw.Event.EDITSTART = 'draw:editstart';\r\n\r\n/**\r\n * @event draw:editmove: ILayer\r\n *\r\n * Layer that was just moved.\r\n *\r\n * Triggered as the user moves a rectangle; circle or marker.\r\n */\r\nL.Draw.Event.EDITMOVE = 'draw:editmove';\r\n\r\n/**\r\n * @event draw:editresize: ILayer\r\n *\r\n * Layer that was just moved.\r\n *\r\n * Triggered as the user resizes a rectangle or circle.\r\n */\r\nL.Draw.Event.EDITRESIZE = 'draw:editresize';\r\n\r\n/**\r\n * @event draw:editvertex: LayerGroup\r\n *\r\n * List of all layers just being edited from the map.\r\n *\r\n * Triggered when a vertex is edited on a polyline or polygon.\r\n */\r\nL.Draw.Event.EDITVERTEX = 'draw:editvertex';\r\n\r\n/**\r\n * @event draw:editstop: String\r\n *\r\n * The type of edit this is. One of: `edit`\r\n *\r\n * Triggered when the user has finshed editing (edit mode) and saves edits.\r\n */\r\nL.Draw.Event.EDITSTOP = 'draw:editstop';\r\n\r\n/**\r\n * @event draw:deletestart: String\r\n *\r\n * The type of edit this is. One of: `remove`\r\n *\r\n * Triggered when the user starts remove mode by clicking the remove tool button.\r\n */\r\nL.Draw.Event.DELETESTART = 'draw:deletestart';\r\n\r\n/**\r\n * @event draw:deletestop: String\r\n *\r\n * The type of edit this is. One of: `remove`\r\n *\r\n * Triggered when the user has finished removing shapes (remove mode) and saves.\r\n */\r\nL.Draw.Event.DELETESTOP = 'draw:deletestop';\r\n\r\n/**\r\n * @event draw:toolbaropened: String\r\n *\r\n * Triggered when a toolbar is opened.\r\n */\r\nL.Draw.Event.TOOLBAROPENED = 'draw:toolbaropened';\r\n\r\n/**\r\n * @event draw:toolbarclosed: String\r\n *\r\n * Triggered when a toolbar is closed.\r\n */\r\nL.Draw.Event.TOOLBARCLOSED = 'draw:toolbarclosed';\r\n\r\n/**\r\n * @event draw:markercontext: String\r\n *\r\n * Triggered when a marker is right clicked.\r\n */\r\nL.Draw.Event.MARKERCONTEXT = 'draw:markercontext';","L.Draw = L.Draw || {};\r\n\r\n/**\r\n * @class L.Draw.Feature\r\n * @aka Draw.Feature\r\n */\r\nL.Draw.Feature = L.Handler.extend({\r\n\r\n\t// @method initialize(): void\r\n\tinitialize: function (map, options) {\r\n\t\tthis._map = map;\r\n\t\tthis._container = map._container;\r\n\t\tthis._overlayPane = map._panes.overlayPane;\r\n\t\tthis._popupPane = map._panes.popupPane;\r\n\r\n\t\t// Merge default shapeOptions options with custom shapeOptions\r\n\t\tif (options && options.shapeOptions) {\r\n\t\t\toptions.shapeOptions = L.Util.extend({}, this.options.shapeOptions, options.shapeOptions);\r\n\t\t}\r\n\t\tL.setOptions(this, options);\r\n\r\n\t\tvar version = L.version.split('.');\r\n\t\t//If Version is >= 1.2.0\r\n\t\tif (parseInt(version[0], 10) === 1 && parseInt(version[1], 10) >= 2) {\r\n\t\t\tL.Draw.Feature.include(L.Evented.prototype);\r\n\t\t} else {\r\n\t\t\tL.Draw.Feature.include(L.Mixin.Events);\r\n\t\t}\r\n\t},\r\n\r\n\t// @method enable(): void\r\n\t// Enables this handler\r\n\tenable: function () {\r\n\t\tif (this._enabled) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tL.Handler.prototype.enable.call(this);\r\n\r\n\t\tthis.fire('enabled', {handler: this.type});\r\n\r\n\t\tthis._map.fire(L.Draw.Event.DRAWSTART, {layerType: this.type});\r\n\t},\r\n\r\n\t// @method disable(): void\r\n\tdisable: function () {\r\n\t\tif (!this._enabled) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tL.Handler.prototype.disable.call(this);\r\n\r\n\t\tthis._map.fire(L.Draw.Event.DRAWSTOP, {layerType: this.type});\r\n\r\n\t\tthis.fire('disabled', {handler: this.type});\r\n\t},\r\n\r\n\t// @method addHooks(): void\r\n\t// Add's event listeners to this handler\r\n\taddHooks: function () {\r\n\t\tvar map = this._map;\r\n\r\n\t\tif (map) {\r\n\t\t\tL.DomUtil.disableTextSelection();\r\n\r\n\t\t\tmap.getContainer().focus();\r\n\r\n\t\t\tthis._tooltip = new L.Draw.Tooltip(this._map);\r\n\r\n\t\t\tL.DomEvent.on(this._container, 'keyup', this._cancelDrawing, this);\r\n\t\t}\r\n\t},\r\n\r\n\t// @method removeHooks(): void\r\n\t// Removes event listeners from this handler\r\n\tremoveHooks: function () {\r\n\t\tif (this._map) {\r\n\t\t\tL.DomUtil.enableTextSelection();\r\n\r\n\t\t\tthis._tooltip.dispose();\r\n\t\t\tthis._tooltip = null;\r\n\r\n\t\t\tL.DomEvent.off(this._container, 'keyup', this._cancelDrawing, this);\r\n\t\t}\r\n\t},\r\n\r\n\t// @method setOptions(object): void\r\n\t// Sets new options to this handler\r\n\tsetOptions: function (options) {\r\n\t\tL.setOptions(this, options);\r\n\t},\r\n\r\n\t_fireCreatedEvent: function (layer) {\r\n\t\tthis._map.fire(L.Draw.Event.CREATED, {layer: layer, layerType: this.type});\r\n\t},\r\n\r\n\t// Cancel drawing when the escape key is pressed\r\n\t_cancelDrawing: function (e) {\r\n\t\tif (e.keyCode === 27) {\r\n\t\t\tthis._map.fire('draw:canceled', {layerType: this.type});\r\n\t\t\tthis.disable();\r\n\t\t}\r\n\t}\r\n});\r\n","/**\r\n * @class L.Draw.Polyline\r\n * @aka Draw.Polyline\r\n * @inherits L.Draw.Feature\r\n */\r\nL.Draw.Polyline = L.Draw.Feature.extend({\r\n\tstatics: {\r\n\t\tTYPE: 'polyline'\r\n\t},\r\n\r\n\tPoly: L.Polyline,\r\n\r\n\toptions: {\r\n\t\tallowIntersection: true,\r\n\t\trepeatMode: false,\r\n\t\tdrawError: {\r\n\t\t\tcolor: '#b00b00',\r\n\t\t\ttimeout: 2500\r\n\t\t},\r\n\t\ticon: new L.DivIcon({\r\n\t\t\ticonSize: new L.Point(8, 8),\r\n\t\t\tclassName: 'leaflet-div-icon leaflet-editing-icon'\r\n\t\t}),\r\n\t\ttouchIcon: new L.DivIcon({\r\n\t\t\ticonSize: new L.Point(20, 20),\r\n\t\t\tclassName: 'leaflet-div-icon leaflet-editing-icon leaflet-touch-icon'\r\n\t\t}),\r\n\t\tguidelineDistance: 20,\r\n\t\tmaxGuideLineLength: 4000,\r\n\t\tshapeOptions: {\r\n\t\t\tstroke: true,\r\n\t\t\tcolor: '#3388ff',\r\n\t\t\tweight: 4,\r\n\t\t\topacity: 0.5,\r\n\t\t\tfill: false,\r\n\t\t\tclickable: true\r\n\t\t},\r\n\t\tmetric: true, // Whether to use the metric measurement system or imperial\r\n\t\tfeet: true, // When not metric, to use feet instead of yards for display.\r\n\t\tnautic: false, // When not metric, not feet use nautic mile for display\r\n\t\tshowLength: true, // Whether to display distance in the tooltip\r\n\t\tzIndexOffset: 2000, // This should be > than the highest z-index any map layers\r\n\t\tfactor: 1, // To change distance calculation\r\n\t\tmaxPoints: 0 // Once this number of points are placed, finish shape\r\n\t},\r\n\r\n\t// @method initialize(): void\r\n\tinitialize: function (map, options) {\r\n\t\t// if touch, switch to touch icon\r\n\t\tif (L.Browser.touch) {\r\n\t\t\tthis.options.icon = this.options.touchIcon;\r\n\t\t}\r\n\r\n\t\t// Need to set this here to ensure the correct message is used.\r\n\t\tthis.options.drawError.message = L.drawLocal.draw.handlers.polyline.error;\r\n\r\n\t\t// Merge default drawError options with custom options\r\n\t\tif (options && options.drawError) {\r\n\t\t\toptions.drawError = L.Util.extend({}, this.options.drawError, options.drawError);\r\n\t\t}\r\n\r\n\t\t// Save the type so super can fire, need to do this as cannot do this.TYPE :(\r\n\t\tthis.type = L.Draw.Polyline.TYPE;\r\n\r\n\t\tL.Draw.Feature.prototype.initialize.call(this, map, options);\r\n\t},\r\n\r\n\t// @method addHooks(): void\r\n\t// Add listener hooks to this handler\r\n\taddHooks: function () {\r\n\t\tL.Draw.Feature.prototype.addHooks.call(this);\r\n\t\tif (this._map) {\r\n\t\t\tthis._markers = [];\r\n\r\n\t\t\tthis._markerGroup = new L.LayerGroup();\r\n\t\t\tthis._map.addLayer(this._markerGroup);\r\n\r\n\t\t\tthis._poly = new L.Polyline([], this.options.shapeOptions);\r\n\r\n\t\t\tthis._tooltip.updateContent(this._getTooltipText());\r\n\r\n\t\t\t// Make a transparent marker that will used to catch click events. These click\r\n\t\t\t// events will create the vertices. We need to do this so we can ensure that\r\n\t\t\t// we can create vertices over other map layers (markers, vector layers). We\r\n\t\t\t// also do not want to trigger any click handlers of objects we are clicking on\r\n\t\t\t// while drawing.\r\n\t\t\tif (!this._mouseMarker) {\r\n\t\t\t\tthis._mouseMarker = L.marker(this._map.getCenter(), {\r\n\t\t\t\t\ticon: L.divIcon({\r\n\t\t\t\t\t\tclassName: 'leaflet-mouse-marker',\r\n\t\t\t\t\t\ticonAnchor: [20, 20],\r\n\t\t\t\t\t\ticonSize: [40, 40]\r\n\t\t\t\t\t}),\r\n\t\t\t\t\topacity: 0,\r\n\t\t\t\t\tzIndexOffset: this.options.zIndexOffset\r\n\t\t\t\t});\r\n\t\t\t}\r\n\r\n\t\t\tthis._mouseMarker\r\n\t\t\t\t.on('mouseout', this._onMouseOut, this)\r\n\t\t\t\t.on('mousemove', this._onMouseMove, this) // Necessary to prevent 0.8 stutter\r\n\t\t\t\t.on('mousedown', this._onMouseDown, this)\r\n\t\t\t\t.on('mouseup', this._onMouseUp, this) // Necessary for 0.8 compatibility\r\n\t\t\t\t.addTo(this._map);\r\n\r\n\t\t\tthis._map\r\n\t\t\t\t.on('mouseup', this._onMouseUp, this) // Necessary for 0.7 compatibility\r\n\t\t\t\t.on('mousemove', this._onMouseMove, this)\r\n\t\t\t\t.on('zoomlevelschange', this._onZoomEnd, this)\r\n\t\t\t\t.on('touchstart', this._onTouch, this)\r\n\t\t\t\t.on('zoomend', this._onZoomEnd, this);\r\n\r\n\t\t}\r\n\t},\r\n\r\n\t// @method removeHooks(): void\r\n\t// Remove listener hooks from this handler.\r\n\tremoveHooks: function () {\r\n\t\tL.Draw.Feature.prototype.removeHooks.call(this);\r\n\r\n\t\tthis._clearHideErrorTimeout();\r\n\r\n\t\tthis._cleanUpShape();\r\n\r\n\t\t// remove markers from map\r\n\t\tthis._map.removeLayer(this._markerGroup);\r\n\t\tdelete this._markerGroup;\r\n\t\tdelete this._markers;\r\n\r\n\t\tthis._map.removeLayer(this._poly);\r\n\t\tdelete this._poly;\r\n\r\n\t\tthis._mouseMarker\r\n\t\t\t.off('mousedown', this._onMouseDown, this)\r\n\t\t\t.off('mouseout', this._onMouseOut, this)\r\n\t\t\t.off('mouseup', this._onMouseUp, this)\r\n\t\t\t.off('mousemove', this._onMouseMove, this);\r\n\t\tthis._map.removeLayer(this._mouseMarker);\r\n\t\tdelete this._mouseMarker;\r\n\r\n\t\t// clean up DOM\r\n\t\tthis._clearGuides();\r\n\r\n\t\tthis._map\r\n\t\t\t.off('mouseup', this._onMouseUp, this)\r\n\t\t\t.off('mousemove', this._onMouseMove, this)\r\n\t\t\t.off('zoomlevelschange', this._onZoomEnd, this)\r\n\t\t\t.off('zoomend', this._onZoomEnd, this)\r\n\t\t\t.off('touchstart', this._onTouch, this)\r\n\t\t\t.off('click', this._onTouch, this);\r\n\t},\r\n\r\n\t// @method deleteLastVertex(): void\r\n\t// Remove the last vertex from the polyline, removes polyline from map if only one point exists.\r\n\tdeleteLastVertex: function () {\r\n\t\tif (this._markers.length <= 1) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tvar lastMarker = this._markers.pop(),\r\n\t\t\tpoly = this._poly,\r\n\t\t\t// Replaces .spliceLatLngs()\r\n\t\t\tlatlngs = poly.getLatLngs(),\r\n\t\t\tlatlng = latlngs.splice(-1, 1)[0];\r\n\t\tthis._poly.setLatLngs(latlngs);\r\n\r\n\t\tthis._markerGroup.removeLayer(lastMarker);\r\n\r\n\t\tif (poly.getLatLngs().length < 2) {\r\n\t\t\tthis._map.removeLayer(poly);\r\n\t\t}\r\n\r\n\t\tthis._vertexChanged(latlng, false);\r\n\t},\r\n\r\n\t// @method addVertex(): void\r\n\t// Add a vertex to the end of the polyline\r\n\taddVertex: function (latlng) {\r\n\t\tvar markersLength = this._markers.length;\r\n\t\t// markersLength must be greater than or equal to 2 before intersections can occur\r\n\t\tif (markersLength >= 2 && !this.options.allowIntersection && this._poly.newLatLngIntersects(latlng)) {\r\n\t\t\tthis._showErrorTooltip();\r\n\t\t\treturn;\r\n\t\t}\r\n\t\telse if (this._errorShown) {\r\n\t\t\tthis._hideErrorTooltip();\r\n\t\t}\r\n\r\n\t\tthis._markers.push(this._createMarker(latlng));\r\n\r\n\t\tthis._poly.addLatLng(latlng);\r\n\r\n\t\tif (this._poly.getLatLngs().length === 2) {\r\n\t\t\tthis._map.addLayer(this._poly);\r\n\t\t}\r\n\r\n\t\tthis._vertexChanged(latlng, true);\r\n\t},\r\n\r\n\t// @method completeShape(): void\r\n\t// Closes the polyline between the first and last points\r\n\tcompleteShape: function () {\r\n\t\tif (this._markers.length <= 1 || !this._shapeIsValid()) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tthis._fireCreatedEvent();\r\n\t\tthis.disable();\r\n\r\n\t\tif (this.options.repeatMode) {\r\n\t\t\tthis.enable();\r\n\t\t}\r\n\t},\r\n\r\n\t_finishShape: function () {\r\n\t\tvar latlngs = this._poly._defaultShape ? this._poly._defaultShape() : this._poly.getLatLngs();\r\n\t\tvar intersects = this._poly.newLatLngIntersects(latlngs[latlngs.length - 1]);\r\n\r\n\t\tif ((!this.options.allowIntersection && intersects) || !this._shapeIsValid()) {\r\n\t\t\tthis._showErrorTooltip();\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tthis._fireCreatedEvent();\r\n\t\tthis.disable();\r\n\t\tif (this.options.repeatMode) {\r\n\t\t\tthis.enable();\r\n\t\t}\r\n\t},\r\n\r\n\t// Called to verify the shape is valid when the user tries to finish it\r\n\t// Return false if the shape is not valid\r\n\t_shapeIsValid: function () {\r\n\t\treturn true;\r\n\t},\r\n\r\n\t_onZoomEnd: function () {\r\n\t\tif (this._markers !== null) {\r\n\t\t\tthis._updateGuide();\r\n\t\t}\r\n\t},\r\n\r\n\t_onMouseMove: function (e) {\r\n\t\tvar newPos = this._map.mouseEventToLayerPoint(e.originalEvent);\r\n\t\tvar latlng = this._map.layerPointToLatLng(newPos);\r\n\r\n\t\t// Save latlng\r\n\t\t// should this be moved to _updateGuide() ?\r\n\t\tthis._currentLatLng = latlng;\r\n\r\n\t\tthis._updateTooltip(latlng);\r\n\r\n\t\t// Update the guide line\r\n\t\tthis._updateGuide(newPos);\r\n\r\n\t\t// Update the mouse marker position\r\n\t\tthis._mouseMarker.setLatLng(latlng);\r\n\r\n\t\tL.DomEvent.preventDefault(e.originalEvent);\r\n\t},\r\n\r\n\t_vertexChanged: function (latlng, added) {\r\n\t\tthis._map.fire(L.Draw.Event.DRAWVERTEX, {layers: this._markerGroup});\r\n\t\tthis._updateFinishHandler();\r\n\r\n\t\tthis._updateRunningMeasure(latlng, added);\r\n\r\n\t\tthis._clearGuides();\r\n\r\n\t\tthis._updateTooltip();\r\n\t},\r\n\r\n\t_onMouseDown: function (e) {\r\n\t\tif (!this._clickHandled && !this._touchHandled && !this._disableMarkers) {\r\n\t\t\tthis._onMouseMove(e);\r\n\t\t\tthis._clickHandled = true;\r\n\t\t\tthis._disableNewMarkers();\r\n\t\t\tvar originalEvent = e.originalEvent;\r\n\t\t\tvar clientX = originalEvent.clientX;\r\n\t\t\tvar clientY = originalEvent.clientY;\r\n\t\t\tthis._startPoint.call(this, clientX, clientY);\r\n\t\t}\r\n\t},\r\n\r\n\t_startPoint: function (clientX, clientY) {\r\n\t\tthis._mouseDownOrigin = L.point(clientX, clientY);\r\n\t},\r\n\r\n\t_onMouseUp: function (e) {\r\n\t\tvar originalEvent = e.originalEvent;\r\n\t\tvar clientX = originalEvent.clientX;\r\n\t\tvar clientY = originalEvent.clientY;\r\n\t\tthis._endPoint.call(this, clientX, clientY, e);\r\n\t\tthis._clickHandled = null;\r\n\t},\r\n\r\n\t_endPoint: function (clientX, clientY, e) {\r\n\t\tif (this._mouseDownOrigin) {\r\n\t\t\tvar dragCheckDistance = L.point(clientX, clientY)\r\n\t\t\t\t.distanceTo(this._mouseDownOrigin);\r\n\t\t\tvar lastPtDistance = this._calculateFinishDistance(e.latlng);\r\n\t\t\tif (this.options.maxPoints > 1 && this.options.maxPoints == this._markers.length + 1) {\r\n\t\t\t\tthis.addVertex(e.latlng);\r\n\t\t\t\tthis._finishShape();\r\n\t\t\t} else if (lastPtDistance < 10 && L.Browser.touch) {\r\n\t\t\t\tthis._finishShape();\r\n\t\t\t} else if (Math.abs(dragCheckDistance) < 9 * (window.devicePixelRatio || 1)) {\r\n\t\t\t\tthis.addVertex(e.latlng);\r\n\t\t\t}\r\n\t\t\tthis._enableNewMarkers(); // after a short pause, enable new markers\r\n\t\t}\r\n\t\tthis._mouseDownOrigin = null;\r\n\t},\r\n\r\n\t// ontouch prevented by clickHandled flag because some browsers fire both click/touch events,\r\n\t// causing unwanted behavior\r\n\t_onTouch: function (e) {\r\n\t\tvar originalEvent = e.originalEvent;\r\n\t\tvar clientX;\r\n\t\tvar clientY;\r\n\t\tif (originalEvent.touches && originalEvent.touches[0] && !this._clickHandled && !this._touchHandled && !this._disableMarkers) {\r\n\t\t\tclientX = originalEvent.touches[0].clientX;\r\n\t\t\tclientY = originalEvent.touches[0].clientY;\r\n\t\t\tthis._disableNewMarkers();\r\n\t\t\tthis._touchHandled = true;\r\n\t\t\tthis._startPoint.call(this, clientX, clientY);\r\n\t\t\tthis._endPoint.call(this, clientX, clientY, e);\r\n\t\t\tthis._touchHandled = null;\r\n\t\t}\r\n\t\tthis._clickHandled = null;\r\n\t},\r\n\r\n\t_onMouseOut: function () {\r\n\t\tif (this._tooltip) {\r\n\t\t\tthis._tooltip._onMouseOut.call(this._tooltip);\r\n\t\t}\r\n\t},\r\n\r\n\t// calculate if we are currently within close enough distance\r\n\t// of the closing point (first point for shapes, last point for lines)\r\n\t// this is semi-ugly code but the only reliable way i found to get the job done\r\n\t// note: calculating point.distanceTo between mouseDownOrigin and last marker did NOT work\r\n\t_calculateFinishDistance: function (potentialLatLng) {\r\n\t\tvar lastPtDistance;\r\n\t\tif (this._markers.length > 0) {\r\n\t\t\tvar finishMarker;\r\n\t\t\tif (this.type === L.Draw.Polyline.TYPE) {\r\n\t\t\t\tfinishMarker = this._markers[this._markers.length - 1];\r\n\t\t\t} else if (this.type === L.Draw.Polygon.TYPE) {\r\n\t\t\t\tfinishMarker = this._markers[0];\r\n\t\t\t} else {\r\n\t\t\t\treturn Infinity;\r\n\t\t\t}\r\n\t\t\tvar lastMarkerPoint = this._map.latLngToContainerPoint(finishMarker.getLatLng()),\r\n\t\t\t\tpotentialMarker = new L.Marker(potentialLatLng, {\r\n\t\t\t\t\ticon: this.options.icon,\r\n\t\t\t\t\tzIndexOffset: this.options.zIndexOffset * 2\r\n\t\t\t\t});\r\n\t\t\tvar potentialMarkerPint = this._map.latLngToContainerPoint(potentialMarker.getLatLng());\r\n\t\t\tlastPtDistance = lastMarkerPoint.distanceTo(potentialMarkerPint);\r\n\t\t} else {\r\n\t\t\tlastPtDistance = Infinity;\r\n\t\t}\r\n\t\treturn lastPtDistance;\r\n\t},\r\n\r\n\t_updateFinishHandler: function () {\r\n\t\tvar markerCount = this._markers.length;\r\n\t\t// The last marker should have a click handler to close the polyline\r\n\t\tif (markerCount > 1) {\r\n\t\t\tthis._markers[markerCount - 1].on('click', this._finishShape, this);\r\n\t\t}\r\n\r\n\t\t// Remove the old marker click handler (as only the last point should close the polyline)\r\n\t\tif (markerCount > 2) {\r\n\t\t\tthis._markers[markerCount - 2].off('click', this._finishShape, this);\r\n\t\t}\r\n\t},\r\n\r\n\t_createMarker: function (latlng) {\r\n\t\tvar marker = new L.Marker(latlng, {\r\n\t\t\ticon: this.options.icon,\r\n\t\t\tzIndexOffset: this.options.zIndexOffset * 2\r\n\t\t});\r\n\r\n\t\tthis._markerGroup.addLayer(marker);\r\n\r\n\t\treturn marker;\r\n\t},\r\n\r\n\t_updateGuide: function (newPos) {\r\n\t\tvar markerCount = this._markers ? this._markers.length : 0;\r\n\r\n\t\tif (markerCount > 0) {\r\n\t\t\tnewPos = newPos || this._map.latLngToLayerPoint(this._currentLatLng);\r\n\r\n\t\t\t// draw the guide line\r\n\t\t\tthis._clearGuides();\r\n\t\t\tthis._drawGuide(\r\n\t\t\t\tthis._map.latLngToLayerPoint(this._markers[markerCount - 1].getLatLng()),\r\n\t\t\t\tnewPos\r\n\t\t\t);\r\n\t\t}\r\n\t},\r\n\r\n\t_updateTooltip: function (latLng) {\r\n\t\tvar text = this._getTooltipText();\r\n\r\n\t\tif (latLng) {\r\n\t\t\tthis._tooltip.updatePosition(latLng);\r\n\t\t}\r\n\r\n\t\tif (!this._errorShown) {\r\n\t\t\tthis._tooltip.updateContent(text);\r\n\t\t}\r\n\t},\r\n\r\n\t_drawGuide: function (pointA, pointB) {\r\n\t\tvar length = Math.floor(Math.sqrt(Math.pow((pointB.x - pointA.x), 2) + Math.pow((pointB.y - pointA.y), 2))),\r\n\t\t\tguidelineDistance = this.options.guidelineDistance,\r\n\t\t\tmaxGuideLineLength = this.options.maxGuideLineLength,\r\n\t\t\t// Only draw a guideline with a max length\r\n\t\t\ti = length > maxGuideLineLength ? length - maxGuideLineLength : guidelineDistance,\r\n\t\t\tfraction,\r\n\t\t\tdashPoint,\r\n\t\t\tdash;\r\n\r\n\t\t//create the guides container if we haven't yet\r\n\t\tif (!this._guidesContainer) {\r\n\t\t\tthis._guidesContainer = L.DomUtil.create('div', 'leaflet-draw-guides', this._overlayPane);\r\n\t\t}\r\n\r\n\t\t//draw a dash every GuildeLineDistance\r\n\t\tfor (; i < length; i += this.options.guidelineDistance) {\r\n\t\t\t//work out fraction along line we are\r\n\t\t\tfraction = i / length;\r\n\r\n\t\t\t//calculate new x,y point\r\n\t\t\tdashPoint = {\r\n\t\t\t\tx: Math.floor((pointA.x * (1 - fraction)) + (fraction * pointB.x)),\r\n\t\t\t\ty: Math.floor((pointA.y * (1 - fraction)) + (fraction * pointB.y))\r\n\t\t\t};\r\n\r\n\t\t\t//add guide dash to guide container\r\n\t\t\tdash = L.DomUtil.create('div', 'leaflet-draw-guide-dash', this._guidesContainer);\r\n\t\t\tdash.style.backgroundColor =\r\n\t\t\t\t!this._errorShown ? this.options.shapeOptions.color : this.options.drawError.color;\r\n\r\n\t\t\tL.DomUtil.setPosition(dash, dashPoint);\r\n\t\t}\r\n\t},\r\n\r\n\t_updateGuideColor: function (color) {\r\n\t\tif (this._guidesContainer) {\r\n\t\t\tfor (var i = 0, l = this._guidesContainer.childNodes.length; i < l; i++) {\r\n\t\t\t\tthis._guidesContainer.childNodes[i].style.backgroundColor = color;\r\n\t\t\t}\r\n\t\t}\r\n\t},\r\n\r\n\t// removes all child elements (guide dashes) from the guides container\r\n\t_clearGuides: function () {\r\n\t\tif (this._guidesContainer) {\r\n\t\t\twhile (this._guidesContainer.firstChild) {\r\n\t\t\t\tthis._guidesContainer.removeChild(this._guidesContainer.firstChild);\r\n\t\t\t}\r\n\t\t}\r\n\t},\r\n\r\n\t_getTooltipText: function () {\r\n\t\tvar showLength = this.options.showLength,\r\n\t\t\tlabelText, distanceStr;\r\n\t\tif (this._markers.length === 0) {\r\n\t\t\tlabelText = {\r\n\t\t\t\ttext: L.drawLocal.draw.handlers.polyline.tooltip.start\r\n\t\t\t};\r\n\t\t} else {\r\n\t\t\tdistanceStr = showLength ? this._getMeasurementString() : '';\r\n\r\n\t\t\tif (this._markers.length === 1) {\r\n\t\t\t\tlabelText = {\r\n\t\t\t\t\ttext: L.drawLocal.draw.handlers.polyline.tooltip.cont,\r\n\t\t\t\t\tsubtext: distanceStr\r\n\t\t\t\t};\r\n\t\t\t} else {\r\n\t\t\t\tlabelText = {\r\n\t\t\t\t\ttext: L.drawLocal.draw.handlers.polyline.tooltip.end,\r\n\t\t\t\t\tsubtext: distanceStr\r\n\t\t\t\t};\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn labelText;\r\n\t},\r\n\r\n\t_updateRunningMeasure: function (latlng, added) {\r\n\t\tvar markersLength = this._markers.length,\r\n\t\t\tpreviousMarkerIndex, distance;\r\n\r\n\t\tif (this._markers.length === 1) {\r\n\t\t\tthis._measurementRunningTotal = 0;\r\n\t\t} else {\r\n\t\t\tpreviousMarkerIndex = markersLength - (added ? 2 : 1);\r\n\r\n\t\t\t// Calculate the distance based on the version\r\n\t\t\tif (L.GeometryUtil.isVersion07x()) {\r\n\t\t\t\tdistance = latlng.distanceTo(this._markers[previousMarkerIndex].getLatLng()) * (this.options.factor || 1);\r\n\t\t\t} else {\r\n\t\t\t\tdistance = this._map.distance(latlng, this._markers[previousMarkerIndex].getLatLng()) * (this.options.factor || 1);\r\n\t\t\t}\r\n\r\n\t\t\tthis._measurementRunningTotal += distance * (added ? 1 : -1);\r\n\t\t}\r\n\t},\r\n\r\n\t_getMeasurementString: function () {\r\n\t\tvar currentLatLng = this._currentLatLng,\r\n\t\t\tpreviousLatLng = this._markers[this._markers.length - 1].getLatLng(),\r\n\t\t\tdistance;\r\n\r\n\t\t// Calculate the distance from the last fixed point to the mouse position based on the version\r\n\t\tif (L.GeometryUtil.isVersion07x()) {\r\n\t\t\tdistance = previousLatLng && currentLatLng && currentLatLng.distanceTo ? this._measurementRunningTotal + currentLatLng.distanceTo(previousLatLng) * (this.options.factor || 1) : this._measurementRunningTotal || 0;\r\n\t\t} else {\r\n\t\t\tdistance = previousLatLng && currentLatLng ? this._measurementRunningTotal + this._map.distance(currentLatLng, previousLatLng) * (this.options.factor || 1) : this._measurementRunningTotal || 0;\r\n\t\t}\r\n\r\n\t\treturn L.GeometryUtil.readableDistance(distance, this.options.metric, this.options.feet, this.options.nautic, this.options.precision);\r\n\t},\r\n\r\n\t_showErrorTooltip: function () {\r\n\t\tthis._errorShown = true;\r\n\r\n\t\t// Update tooltip\r\n\t\tthis._tooltip\r\n\t\t\t.showAsError()\r\n\t\t\t.updateContent({text: this.options.drawError.message});\r\n\r\n\t\t// Update shape\r\n\t\tthis._updateGuideColor(this.options.drawError.color);\r\n\t\tthis._poly.setStyle({color: this.options.drawError.color});\r\n\r\n\t\t// Hide the error after 2 seconds\r\n\t\tthis._clearHideErrorTimeout();\r\n\t\tthis._hideErrorTimeout = setTimeout(L.Util.bind(this._hideErrorTooltip, this), this.options.drawError.timeout);\r\n\t},\r\n\r\n\t_hideErrorTooltip: function () {\r\n\t\tthis._errorShown = false;\r\n\r\n\t\tthis._clearHideErrorTimeout();\r\n\r\n\t\t// Revert tooltip\r\n\t\tthis._tooltip\r\n\t\t\t.removeError()\r\n\t\t\t.updateContent(this._getTooltipText());\r\n\r\n\t\t// Revert shape\r\n\t\tthis._updateGuideColor(this.options.shapeOptions.color);\r\n\t\tthis._poly.setStyle({color: this.options.shapeOptions.color});\r\n\t},\r\n\r\n\t_clearHideErrorTimeout: function () {\r\n\t\tif (this._hideErrorTimeout) {\r\n\t\t\tclearTimeout(this._hideErrorTimeout);\r\n\t\t\tthis._hideErrorTimeout = null;\r\n\t\t}\r\n\t},\r\n\r\n\t// disable new markers temporarily;\r\n\t// this is to prevent duplicated touch/click events in some browsers\r\n\t_disableNewMarkers: function () {\r\n\t\tthis._disableMarkers = true;\r\n\t},\r\n\r\n\t// see _disableNewMarkers\r\n\t_enableNewMarkers: function () {\r\n\t\tsetTimeout(function () {\r\n\t\t\tthis._disableMarkers = false;\r\n\t\t}.bind(this), 50);\r\n\t},\r\n\r\n\t_cleanUpShape: function () {\r\n\t\tif (this._markers.length > 1) {\r\n\t\t\tthis._markers[this._markers.length - 1].off('click', this._finishShape, this);\r\n\t\t}\r\n\t},\r\n\r\n\t_fireCreatedEvent: function () {\r\n\t\tvar poly = new this.Poly(this._poly.getLatLngs(), this.options.shapeOptions);\r\n\t\tL.Draw.Feature.prototype._fireCreatedEvent.call(this, poly);\r\n\t}\r\n});\r\n","/**\r\n * @class L.Draw.Polygon\r\n * @aka Draw.Polygon\r\n * @inherits L.Draw.Polyline\r\n */\r\nL.Draw.Polygon = L.Draw.Polyline.extend({\r\n\tstatics: {\r\n\t\tTYPE: 'polygon'\r\n\t},\r\n\r\n\tPoly: L.Polygon,\r\n\r\n\toptions: {\r\n\t\tshowArea: false,\r\n\t\tshowLength: false,\r\n\t\tshapeOptions: {\r\n\t\t\tstroke: true,\r\n\t\t\tcolor: '#3388ff',\r\n\t\t\tweight: 4,\r\n\t\t\topacity: 0.5,\r\n\t\t\tfill: true,\r\n\t\t\tfillColor: null, //same as color by default\r\n\t\t\tfillOpacity: 0.2,\r\n\t\t\tclickable: true\r\n\t\t},\r\n\t\t// Whether to use the metric measurement system (truthy) or not (falsy).\r\n\t\t// Also defines the units to use for the metric system as an array of\r\n\t\t// strings (e.g. `['ha', 'm']`).\r\n\t\tmetric: true,\r\n\t\tfeet: true, // When not metric, to use feet instead of yards for display.\r\n\t\tnautic: false, // When not metric, not feet use nautic mile for display\r\n\t\t// Defines the precision for each type of unit (e.g. {km: 2, ft: 0}\r\n\t\tprecision: {}\r\n\t},\r\n\r\n\t// @method initialize(): void\r\n\tinitialize: function (map, options) {\r\n\t\tL.Draw.Polyline.prototype.initialize.call(this, map, options);\r\n\r\n\t\t// Save the type so super can fire, need to do this as cannot do this.TYPE :(\r\n\t\tthis.type = L.Draw.Polygon.TYPE;\r\n\t},\r\n\r\n\t_updateFinishHandler: function () {\r\n\t\tvar markerCount = this._markers.length;\r\n\r\n\t\t// The first marker should have a click handler to close the polygon\r\n\t\tif (markerCount === 1) {\r\n\t\t\tthis._markers[0].on('click', this._finishShape, this);\r\n\t\t}\r\n\r\n\t\t// Add and update the double click handler\r\n\t\tif (markerCount > 2) {\r\n\t\t\tthis._markers[markerCount - 1].on('dblclick', this._finishShape, this);\r\n\t\t\t// Only need to remove handler if has been added before\r\n\t\t\tif (markerCount > 3) {\r\n\t\t\t\tthis._markers[markerCount - 2].off('dblclick', this._finishShape, this);\r\n\t\t\t}\r\n\t\t}\r\n\t},\r\n\r\n\t_getTooltipText: function () {\r\n\t\tvar text, subtext;\r\n\r\n\t\tif (this._markers.length === 0) {\r\n\t\t\ttext = L.drawLocal.draw.handlers.polygon.tooltip.start;\r\n\t\t} else if (this._markers.length < 3) {\r\n\t\t\ttext = L.drawLocal.draw.handlers.polygon.tooltip.cont;\r\n\t\t\tsubtext = this._getMeasurementString();\r\n\t\t} else {\r\n\t\t\ttext = L.drawLocal.draw.handlers.polygon.tooltip.end;\r\n\t\t\tsubtext = this._getMeasurementString();\r\n\t\t}\r\n\r\n\t\treturn {\r\n\t\t\ttext: text,\r\n\t\t\tsubtext: subtext\r\n\t\t};\r\n\t},\r\n\r\n\t_getMeasurementString: function () {\r\n\t\tvar area = this._area,\r\n\t\t\tmeasurementString = '';\r\n\r\n\r\n\t\tif (!area && !this.options.showLength) {\r\n\t\t\treturn null;\r\n\t\t}\r\n\r\n\t\tif (this.options.showLength) {\r\n\t\t\tmeasurementString = L.Draw.Polyline.prototype._getMeasurementString.call(this);\r\n\t\t}\r\n\r\n\t\tif (area) {\r\n\t\t\tmeasurementString += '
' + L.GeometryUtil.readableArea(area, this.options.metric, this.options.precision);\r\n\t\t}\r\n\r\n\t\treturn measurementString;\r\n\t},\r\n\r\n\t_shapeIsValid: function () {\r\n\t\treturn this._markers.length >= 3;\r\n\t},\r\n\r\n\t_vertexChanged: function (latlng, added) {\r\n\t\tvar latLngs;\r\n\r\n\t\t// Check to see if we should show the area\r\n\t\tif (!this.options.allowIntersection && this.options.showArea) {\r\n\t\t\tlatLngs = this._poly.getLatLngs();\r\n\r\n\t\t\tthis._area = L.GeometryUtil.geodesicArea(latLngs);\r\n\t\t}\r\n\r\n\t\tL.Draw.Polyline.prototype._vertexChanged.call(this, latlng, added);\r\n\t},\r\n\r\n\t_cleanUpShape: function () {\r\n\t\tvar markerCount = this._markers.length;\r\n\r\n\t\tif (markerCount > 0) {\r\n\t\t\tthis._markers[0].off('click', this._finishShape, this);\r\n\r\n\t\t\tif (markerCount > 2) {\r\n\t\t\t\tthis._markers[markerCount - 1].off('dblclick', this._finishShape, this);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n});\r\n","L.SimpleShape = {};\r\n/**\r\n * @class L.Draw.SimpleShape\r\n * @aka Draw.SimpleShape\r\n * @inherits L.Draw.Feature\r\n */\r\nL.Draw.SimpleShape = L.Draw.Feature.extend({\r\n\toptions: {\r\n\t\trepeatMode: false\r\n\t},\r\n\r\n\t// @method initialize(): void\r\n\tinitialize: function (map, options) {\r\n\t\tthis._endLabelText = L.drawLocal.draw.handlers.simpleshape.tooltip.end;\r\n\r\n\t\tL.Draw.Feature.prototype.initialize.call(this, map, options);\r\n\t},\r\n\r\n\t// @method addHooks(): void\r\n\t// Add listener hooks to this handler.\r\n\taddHooks: function () {\r\n\t\tL.Draw.Feature.prototype.addHooks.call(this);\r\n\t\tif (this._map) {\r\n\t\t\tthis._mapDraggable = this._map.dragging.enabled();\r\n\r\n\t\t\tif (this._mapDraggable) {\r\n\t\t\t\tthis._map.dragging.disable();\r\n\t\t\t}\r\n\r\n\t\t\t//TODO refactor: move cursor to styles\r\n\t\t\tthis._container.style.cursor = 'crosshair';\r\n\r\n\t\t\tthis._tooltip.updateContent({text: this._initialLabelText});\r\n\r\n\t\t\tthis._map\r\n\t\t\t\t.on('mousedown', this._onMouseDown, this)\r\n\t\t\t\t.on('mousemove', this._onMouseMove, this)\r\n\t\t\t\t.on('touchstart', this._onMouseDown, this)\r\n\t\t\t\t.on('touchmove', this._onMouseMove, this);\r\n\r\n\t\t\t// we should prevent default, otherwise default behavior (scrolling) will fire,\r\n\t\t\t// and that will cause document.touchend to fire and will stop the drawing\r\n\t\t\t// (circle, rectangle) in touch mode.\r\n\t\t\t// (update): we have to send passive now to prevent scroll, because by default it is {passive: true} now, which means,\r\n\t\t\t// handler can't event.preventDefault\r\n\t\t\t// check the news https://developers.google.com/web/updates/2016/06/passive-event-listeners\r\n\t\t\tdocument.addEventListener('touchstart', L.DomEvent.preventDefault, {passive: false});\r\n\t\t}\r\n\t},\r\n\r\n\t// @method removeHooks(): void\r\n\t// Remove listener hooks from this handler.\r\n\tremoveHooks: function () {\r\n\t\tL.Draw.Feature.prototype.removeHooks.call(this);\r\n\t\tif (this._map) {\r\n\t\t\tif (this._mapDraggable) {\r\n\t\t\t\tthis._map.dragging.enable();\r\n\t\t\t}\r\n\r\n\t\t\t//TODO refactor: move cursor to styles\r\n\t\t\tthis._container.style.cursor = '';\r\n\r\n\t\t\tthis._map\r\n\t\t\t\t.off('mousedown', this._onMouseDown, this)\r\n\t\t\t\t.off('mousemove', this._onMouseMove, this)\r\n\t\t\t\t.off('touchstart', this._onMouseDown, this)\r\n\t\t\t\t.off('touchmove', this._onMouseMove, this);\r\n\r\n\t\t\tL.DomEvent.off(document, 'mouseup', this._onMouseUp, this);\r\n\t\t\tL.DomEvent.off(document, 'touchend', this._onMouseUp, this);\r\n\r\n\t\t\tdocument.removeEventListener('touchstart', L.DomEvent.preventDefault);\r\n\r\n\t\t\t// If the box element doesn't exist they must not have moved the mouse, so don't need to destroy/return\r\n\t\t\tif (this._shape) {\r\n\t\t\t\tthis._map.removeLayer(this._shape);\r\n\t\t\t\tdelete this._shape;\r\n\t\t\t}\r\n\t\t}\r\n\t\tthis._isDrawing = false;\r\n\t},\r\n\r\n\t_getTooltipText: function () {\r\n\t\treturn {\r\n\t\t\ttext: this._endLabelText\r\n\t\t};\r\n\t},\r\n\r\n\t_onMouseDown: function (e) {\r\n\t\tthis._isDrawing = true;\r\n\t\tthis._startLatLng = e.latlng;\r\n\r\n\t\tL.DomEvent\r\n\t\t\t.on(document, 'mouseup', this._onMouseUp, this)\r\n\t\t\t.on(document, 'touchend', this._onMouseUp, this)\r\n\t\t\t.preventDefault(e.originalEvent);\r\n\t},\r\n\r\n\t_onMouseMove: function (e) {\r\n\t\tvar latlng = e.latlng;\r\n\r\n\t\tthis._tooltip.updatePosition(latlng);\r\n\t\tif (this._isDrawing) {\r\n\t\t\tthis._tooltip.updateContent(this._getTooltipText());\r\n\t\t\tthis._drawShape(latlng);\r\n\t\t}\r\n\t},\r\n\r\n\t_onMouseUp: function () {\r\n\t\tif (this._shape) {\r\n\t\t\tthis._fireCreatedEvent();\r\n\t\t}\r\n\r\n\t\tthis.disable();\r\n\t\tif (this.options.repeatMode) {\r\n\t\t\tthis.enable();\r\n\t\t}\r\n\t}\r\n});\r\n","/**\r\n * @class L.Draw.Rectangle\r\n * @aka Draw.Rectangle\r\n * @inherits L.Draw.SimpleShape\r\n */\r\nL.Draw.Rectangle = L.Draw.SimpleShape.extend({\r\n\tstatics: {\r\n\t\tTYPE: 'rectangle'\r\n\t},\r\n\r\n\toptions: {\r\n\t\tshapeOptions: {\r\n\t\t\tstroke: true,\r\n\t\t\tcolor: '#3388ff',\r\n\t\t\tweight: 4,\r\n\t\t\topacity: 0.5,\r\n\t\t\tfill: true,\r\n\t\t\tfillColor: null, //same as color by default\r\n\t\t\tfillOpacity: 0.2,\r\n\t\t\tclickable: true\r\n\t\t},\r\n\t\tshowArea: true, //Whether to show the area in the tooltip\r\n\t\tmetric: true // Whether to use the metric measurement system or imperial\r\n\t},\r\n\r\n\t// @method initialize(): void\r\n\tinitialize: function (map, options) {\r\n\t\t// Save the type so super can fire, need to do this as cannot do this.TYPE :(\r\n\t\tthis.type = L.Draw.Rectangle.TYPE;\r\n\r\n\t\tthis._initialLabelText = L.drawLocal.draw.handlers.rectangle.tooltip.start;\r\n\r\n\t\tL.Draw.SimpleShape.prototype.initialize.call(this, map, options);\r\n\t},\r\n\r\n\t// @method disable(): void\r\n\tdisable: function () {\r\n\t\tif (!this._enabled) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tthis._isCurrentlyTwoClickDrawing = false;\r\n\t\tL.Draw.SimpleShape.prototype.disable.call(this);\r\n\t},\r\n\r\n\t_onMouseUp: function (e) {\r\n\t\tif (!this._shape && !this._isCurrentlyTwoClickDrawing) {\r\n\t\t\tthis._isCurrentlyTwoClickDrawing = true;\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\t// Make sure closing click is on map\r\n\t\tif (this._isCurrentlyTwoClickDrawing && !_hasAncestor(e.target, 'leaflet-pane')) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tL.Draw.SimpleShape.prototype._onMouseUp.call(this);\r\n\t},\r\n\r\n\t_drawShape: function (latlng) {\r\n\t\tif (!this._shape) {\r\n\t\t\tthis._shape = new L.Rectangle(new L.LatLngBounds(this._startLatLng, latlng), this.options.shapeOptions);\r\n\t\t\tthis._map.addLayer(this._shape);\r\n\t\t} else {\r\n\t\t\tthis._shape.setBounds(new L.LatLngBounds(this._startLatLng, latlng));\r\n\t\t}\r\n\t},\r\n\r\n\t_fireCreatedEvent: function () {\r\n\t\tvar rectangle = new L.Rectangle(this._shape.getBounds(), this.options.shapeOptions);\r\n\t\tL.Draw.SimpleShape.prototype._fireCreatedEvent.call(this, rectangle);\r\n\t},\r\n\r\n\t_getTooltipText: function () {\r\n\t\tvar tooltipText = L.Draw.SimpleShape.prototype._getTooltipText.call(this),\r\n\t\t\tshape = this._shape,\r\n\t\t\tshowArea = this.options.showArea,\r\n\t\t\tlatLngs, area, subtext;\r\n\r\n\t\tif (shape) {\r\n\t\t\tlatLngs = this._shape._defaultShape ? this._shape._defaultShape() : this._shape.getLatLngs();\r\n\t\t\tarea = L.GeometryUtil.geodesicArea(latLngs);\r\n\t\t\tsubtext = showArea ? L.GeometryUtil.readableArea(area, this.options.metric) : '';\r\n\t\t}\r\n\r\n\t\treturn {\r\n\t\t\ttext: tooltipText.text,\r\n\t\t\tsubtext: subtext\r\n\t\t};\r\n\t}\r\n});\r\n\r\nfunction _hasAncestor(el, cls) {\r\n\twhile ((el = el.parentElement) && !el.classList.contains(cls)) {\r\n\t\t;\r\n\t}\r\n\treturn el;\r\n}\r\n","/**\r\n * @class L.Draw.Marker\r\n * @aka Draw.Marker\r\n * @inherits L.Draw.Feature\r\n */\r\nL.Draw.Marker = L.Draw.Feature.extend({\r\n\tstatics: {\r\n\t\tTYPE: 'marker'\r\n\t},\r\n\r\n\toptions: {\r\n\t\ticon: new L.Icon.Default(),\r\n\t\trepeatMode: false,\r\n\t\tzIndexOffset: 2000 // This should be > than the highest z-index any markers\r\n\t},\r\n\r\n\t// @method initialize(): void\r\n\tinitialize: function (map, options) {\r\n\t\t// Save the type so super can fire, need to do this as cannot do this.TYPE :(\r\n\t\tthis.type = L.Draw.Marker.TYPE;\r\n\r\n\t\tthis._initialLabelText = L.drawLocal.draw.handlers.marker.tooltip.start;\r\n\r\n\t\tL.Draw.Feature.prototype.initialize.call(this, map, options);\r\n\t},\r\n\r\n\t// @method addHooks(): void\r\n\t// Add listener hooks to this handler.\r\n\taddHooks: function () {\r\n\t\tL.Draw.Feature.prototype.addHooks.call(this);\r\n\r\n\t\tif (this._map) {\r\n\t\t\tthis._tooltip.updateContent({text: this._initialLabelText});\r\n\r\n\t\t\t// Same mouseMarker as in Draw.Polyline\r\n\t\t\tif (!this._mouseMarker) {\r\n\t\t\t\tthis._mouseMarker = L.marker(this._map.getCenter(), {\r\n\t\t\t\t\ticon: L.divIcon({\r\n\t\t\t\t\t\tclassName: 'leaflet-mouse-marker',\r\n\t\t\t\t\t\ticonAnchor: [20, 20],\r\n\t\t\t\t\t\ticonSize: [40, 40]\r\n\t\t\t\t\t}),\r\n\t\t\t\t\topacity: 0,\r\n\t\t\t\t\tzIndexOffset: this.options.zIndexOffset\r\n\t\t\t\t});\r\n\t\t\t}\r\n\r\n\t\t\tthis._mouseMarker\r\n\t\t\t\t.on('click', this._onClick, this)\r\n\t\t\t\t.addTo(this._map);\r\n\r\n\t\t\tthis._map.on('mousemove', this._onMouseMove, this);\r\n\t\t\tthis._map.on('click', this._onTouch, this);\r\n\t\t}\r\n\t},\r\n\r\n\t// @method removeHooks(): void\r\n\t// Remove listener hooks from this handler.\r\n\tremoveHooks: function () {\r\n\t\tL.Draw.Feature.prototype.removeHooks.call(this);\r\n\r\n\t\tif (this._map) {\r\n\t\t\tthis._map\r\n\t\t\t\t.off('click', this._onClick, this)\r\n\t\t\t\t.off('click', this._onTouch, this);\r\n\t\t\tif (this._marker) {\r\n\t\t\t\tthis._marker.off('click', this._onClick, this);\r\n\t\t\t\tthis._map\r\n\t\t\t\t\t.removeLayer(this._marker);\r\n\t\t\t\tdelete this._marker;\r\n\t\t\t}\r\n\r\n\t\t\tthis._mouseMarker.off('click', this._onClick, this);\r\n\t\t\tthis._map.removeLayer(this._mouseMarker);\r\n\t\t\tdelete this._mouseMarker;\r\n\r\n\t\t\tthis._map.off('mousemove', this._onMouseMove, this);\r\n\t\t}\r\n\t},\r\n\r\n\t_onMouseMove: function (e) {\r\n\t\tvar latlng = e.latlng;\r\n\r\n\t\tthis._tooltip.updatePosition(latlng);\r\n\t\tthis._mouseMarker.setLatLng(latlng);\r\n\r\n\t\tif (!this._marker) {\r\n\t\t\tthis._marker = this._createMarker(latlng);\r\n\t\t\t// Bind to both marker and map to make sure we get the click event.\r\n\t\t\tthis._marker.on('click', this._onClick, this);\r\n\t\t\tthis._map\r\n\t\t\t\t.on('click', this._onClick, this)\r\n\t\t\t\t.addLayer(this._marker);\r\n\t\t}\r\n\t\telse {\r\n\t\t\tlatlng = this._mouseMarker.getLatLng();\r\n\t\t\tthis._marker.setLatLng(latlng);\r\n\t\t}\r\n\t},\r\n\r\n\t_createMarker: function (latlng) {\r\n\t\treturn new L.Marker(latlng, {\r\n\t\t\ticon: this.options.icon,\r\n\t\t\tzIndexOffset: this.options.zIndexOffset\r\n\t\t});\r\n\t},\r\n\r\n\t_onClick: function () {\r\n\t\tthis._fireCreatedEvent();\r\n\r\n\t\tthis.disable();\r\n\t\tif (this.options.repeatMode) {\r\n\t\t\tthis.enable();\r\n\t\t}\r\n\t},\r\n\r\n\t_onTouch: function (e) {\r\n\t\t// called on click & tap, only really does any thing on tap\r\n\t\tthis._onMouseMove(e); // creates & places marker\r\n\t\tthis._onClick(); // permanently places marker & ends interaction\r\n\t},\r\n\r\n\t_fireCreatedEvent: function () {\r\n\t\tvar marker = new L.Marker.Touch(this._marker.getLatLng(), {icon: this.options.icon});\r\n\t\tL.Draw.Feature.prototype._fireCreatedEvent.call(this, marker);\r\n\t}\r\n});\r\n","/**\r\n * @class L.Draw.CircleMarker\r\n * @aka Draw.CircleMarker\r\n * @inherits L.Draw.Marker\r\n */\r\nL.Draw.CircleMarker = L.Draw.Marker.extend({\r\n\tstatics: {\r\n\t\tTYPE: 'circlemarker'\r\n\t},\r\n\r\n\toptions: {\r\n\t\tstroke: true,\r\n\t\tcolor: '#3388ff',\r\n\t\tweight: 4,\r\n\t\topacity: 0.5,\r\n\t\tfill: true,\r\n\t\tfillColor: null, //same as color by default\r\n\t\tfillOpacity: 0.2,\r\n\t\tclickable: true,\r\n\t\tzIndexOffset: 2000 // This should be > than the highest z-index any markers\r\n\t},\r\n\r\n\t// @method initialize(): void\r\n\tinitialize: function (map, options) {\r\n\t\t// Save the type so super can fire, need to do this as cannot do this.TYPE :(\r\n\t\tthis.type = L.Draw.CircleMarker.TYPE;\r\n\r\n\t\tthis._initialLabelText = L.drawLocal.draw.handlers.circlemarker.tooltip.start;\r\n\r\n\t\tL.Draw.Feature.prototype.initialize.call(this, map, options);\r\n\t},\r\n\r\n\r\n\t_fireCreatedEvent: function () {\r\n\t\tvar circleMarker = new L.CircleMarker(this._marker.getLatLng(), this.options);\r\n\t\tL.Draw.Feature.prototype._fireCreatedEvent.call(this, circleMarker);\r\n\t},\r\n\r\n\t_createMarker: function (latlng) {\r\n\t\treturn new L.CircleMarker(latlng, this.options);\r\n\t}\r\n});\r\n","/**\r\n * @class L.Draw.Circle\r\n * @aka Draw.Circle\r\n * @inherits L.Draw.SimpleShape\r\n */\r\nL.Draw.Circle = L.Draw.SimpleShape.extend({\r\n\tstatics: {\r\n\t\tTYPE: 'circle'\r\n\t},\r\n\r\n\toptions: {\r\n\t\tshapeOptions: {\r\n\t\t\tstroke: true,\r\n\t\t\tcolor: '#3388ff',\r\n\t\t\tweight: 4,\r\n\t\t\topacity: 0.5,\r\n\t\t\tfill: true,\r\n\t\t\tfillColor: null, //same as color by default\r\n\t\t\tfillOpacity: 0.2,\r\n\t\t\tclickable: true\r\n\t\t},\r\n\t\tshowRadius: true,\r\n\t\tmetric: true, // Whether to use the metric measurement system or imperial\r\n\t\tfeet: true, // When not metric, use feet instead of yards for display\r\n\t\tnautic: false // When not metric, not feet use nautic mile for display\r\n\t},\r\n\r\n\t// @method initialize(): void\r\n\tinitialize: function (map, options) {\r\n\t\t// Save the type so super can fire, need to do this as cannot do this.TYPE :(\r\n\t\tthis.type = L.Draw.Circle.TYPE;\r\n\r\n\t\tthis._initialLabelText = L.drawLocal.draw.handlers.circle.tooltip.start;\r\n\r\n\t\tL.Draw.SimpleShape.prototype.initialize.call(this, map, options);\r\n\t},\r\n\r\n\t_drawShape: function (latlng) {\r\n\t\t// Calculate the distance based on the version\r\n\t\tif (L.GeometryUtil.isVersion07x()) {\r\n\t\t\tvar distance = this._startLatLng.distanceTo(latlng);\r\n\t\t} else {\r\n\t\t\tvar distance = this._map.distance(this._startLatLng, latlng);\r\n\t\t}\r\n\r\n\t\tif (!this._shape) {\r\n\t\t\tthis._shape = new L.Circle(this._startLatLng, distance, this.options.shapeOptions);\r\n\t\t\tthis._map.addLayer(this._shape);\r\n\t\t} else {\r\n\t\t\tthis._shape.setRadius(distance);\r\n\t\t}\r\n\t},\r\n\r\n\t_fireCreatedEvent: function () {\r\n\t\tvar circle = new L.Circle(this._startLatLng, this._shape.getRadius(), this.options.shapeOptions);\r\n\t\tL.Draw.SimpleShape.prototype._fireCreatedEvent.call(this, circle);\r\n\t},\r\n\r\n\t_onMouseMove: function (e) {\r\n\t\tvar latlng = e.latlng,\r\n\t\t\tshowRadius = this.options.showRadius,\r\n\t\t\tuseMetric = this.options.metric,\r\n\t\t\tradius;\r\n\r\n\t\tthis._tooltip.updatePosition(latlng);\r\n\t\tif (this._isDrawing) {\r\n\t\t\tthis._drawShape(latlng);\r\n\r\n\t\t\t// Get the new radius (rounded to 1 dp)\r\n\t\t\tradius = this._shape.getRadius().toFixed(1);\r\n\r\n\t\t\tvar subtext = '';\r\n\t\t\tif (showRadius) {\r\n\t\t\t\tsubtext = L.drawLocal.draw.handlers.circle.radius + ': ' +\r\n\t\t\t\t\tL.GeometryUtil.readableDistance(radius, useMetric, this.options.feet, this.options.nautic);\r\n\t\t\t}\r\n\t\t\tthis._tooltip.updateContent({\r\n\t\t\t\ttext: this._endLabelText,\r\n\t\t\t\tsubtext: subtext\r\n\t\t\t});\r\n\t\t}\r\n\t}\r\n});\r\n","L.Edit = L.Edit || {};\r\n\r\n/**\r\n * @class L.Edit.Marker\r\n * @aka Edit.Marker\r\n */\r\nL.Edit.Marker = L.Handler.extend({\r\n\t// @method initialize(): void\r\n\tinitialize: function (marker, options) {\r\n\t\tthis._marker = marker;\r\n\t\tL.setOptions(this, options);\r\n\t},\r\n\r\n\t// @method addHooks(): void\r\n\t// Add listener hooks to this handler\r\n\taddHooks: function () {\r\n\t\tvar marker = this._marker;\r\n\r\n\t\tmarker.dragging.enable();\r\n\t\tmarker.on('dragend', this._onDragEnd, marker);\r\n\t\tthis._toggleMarkerHighlight();\r\n\t},\r\n\r\n\t// @method removeHooks(): void\r\n\t// Remove listener hooks from this handler\r\n\tremoveHooks: function () {\r\n\t\tvar marker = this._marker;\r\n\r\n\t\tmarker.dragging.disable();\r\n\t\tmarker.off('dragend', this._onDragEnd, marker);\r\n\t\tthis._toggleMarkerHighlight();\r\n\t},\r\n\r\n\t_onDragEnd: function (e) {\r\n\t\tvar layer = e.target;\r\n\t\tlayer.edited = true;\r\n\t\tthis._map.fire(L.Draw.Event.EDITMOVE, {layer: layer});\r\n\t},\r\n\r\n\t_toggleMarkerHighlight: function () {\r\n\t\tvar icon = this._marker._icon;\r\n\r\n\t\t// Don't do anything if this layer is a marker but doesn't have an icon. Markers\r\n\t\t// should usually have icons. If using Leaflet.draw with Leaflet.markercluster there\r\n\t\t// is a chance that a marker doesn't.\r\n\t\tif (!icon) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\t// This is quite naughty, but I don't see another way of doing it. (short of setting a new icon)\r\n\t\ticon.style.display = 'none';\r\n\r\n\t\tif (L.DomUtil.hasClass(icon, 'leaflet-edit-marker-selected')) {\r\n\t\t\tL.DomUtil.removeClass(icon, 'leaflet-edit-marker-selected');\r\n\t\t\t// Offset as the border will make the icon move.\r\n\t\t\tthis._offsetMarker(icon, -4);\r\n\r\n\t\t} else {\r\n\t\t\tL.DomUtil.addClass(icon, 'leaflet-edit-marker-selected');\r\n\t\t\t// Offset as the border will make the icon move.\r\n\t\t\tthis._offsetMarker(icon, 4);\r\n\t\t}\r\n\r\n\t\ticon.style.display = '';\r\n\t},\r\n\r\n\t_offsetMarker: function (icon, offset) {\r\n\t\tvar iconMarginTop = parseInt(icon.style.marginTop, 10) - offset,\r\n\t\t\ticonMarginLeft = parseInt(icon.style.marginLeft, 10) - offset;\r\n\r\n\t\ticon.style.marginTop = iconMarginTop + 'px';\r\n\t\ticon.style.marginLeft = iconMarginLeft + 'px';\r\n\t}\r\n});\r\n\r\nL.Marker.addInitHook(function () {\r\n\tif (L.Edit.Marker) {\r\n\t\tthis.editing = new L.Edit.Marker(this);\r\n\r\n\t\tif (this.options.editable) {\r\n\t\t\tthis.editing.enable();\r\n\t\t}\r\n\t}\r\n});\r\n","L.Edit = L.Edit || {};\r\n\r\n/**\r\n * @class L.Edit.Polyline\r\n * @aka L.Edit.Poly\r\n * @aka Edit.Poly\r\n */\r\nL.Edit.Poly = L.Handler.extend({\r\n\t// @method initialize(): void\r\n\tinitialize: function (poly) {\r\n\r\n\t\tthis.latlngs = [poly._latlngs];\r\n\t\tif (poly._holes) {\r\n\t\t\tthis.latlngs = this.latlngs.concat(poly._holes);\r\n\t\t}\r\n\r\n\t\tthis._poly = poly;\r\n\r\n\t\tthis._poly.on('revert-edited', this._updateLatLngs, this);\r\n\t},\r\n\r\n\t// Compatibility method to normalize Poly* objects\r\n\t// between 0.7.x and 1.0+\r\n\t_defaultShape: function () {\r\n\t\tif (!L.Polyline._flat) {\r\n\t\t\treturn this._poly._latlngs;\r\n\t\t}\r\n\t\treturn L.Polyline._flat(this._poly._latlngs) ? this._poly._latlngs : this._poly._latlngs[0];\r\n\t},\r\n\r\n\t_eachVertexHandler: function (callback) {\r\n\t\tfor (var i = 0; i < this._verticesHandlers.length; i++) {\r\n\t\t\tcallback(this._verticesHandlers[i]);\r\n\t\t}\r\n\t},\r\n\r\n\t// @method addHooks(): void\r\n\t// Add listener hooks to this handler\r\n\taddHooks: function () {\r\n\t\tthis._initHandlers();\r\n\t\tthis._eachVertexHandler(function (handler) {\r\n\t\t\thandler.addHooks();\r\n\t\t});\r\n\t},\r\n\r\n\t// @method removeHooks(): void\r\n\t// Remove listener hooks from this handler\r\n\tremoveHooks: function () {\r\n\t\tthis._eachVertexHandler(function (handler) {\r\n\t\t\thandler.removeHooks();\r\n\t\t});\r\n\t},\r\n\r\n\t// @method updateMarkers(): void\r\n\t// Fire an update for each vertex handler\r\n\tupdateMarkers: function () {\r\n\t\tthis._eachVertexHandler(function (handler) {\r\n\t\t\thandler.updateMarkers();\r\n\t\t});\r\n\t},\r\n\r\n\t_initHandlers: function () {\r\n\t\tthis._verticesHandlers = [];\r\n\t\tfor (var i = 0; i < this.latlngs.length; i++) {\r\n\t\t\tthis._verticesHandlers.push(new L.Edit.PolyVerticesEdit(this._poly, this.latlngs[i], this._poly.options.poly));\r\n\t\t}\r\n\t},\r\n\r\n\t_updateLatLngs: function (e) {\r\n\t\tthis.latlngs = [e.layer._latlngs];\r\n\t\tif (e.layer._holes) {\r\n\t\t\tthis.latlngs = this.latlngs.concat(e.layer._holes);\r\n\t\t}\r\n\t}\r\n\r\n});\r\n\r\n/**\r\n * @class L.Edit.PolyVerticesEdit\r\n * @aka Edit.PolyVerticesEdit\r\n */\r\nL.Edit.PolyVerticesEdit = L.Handler.extend({\r\n\toptions: {\r\n\t\ticon: new L.DivIcon({\r\n\t\t\ticonSize: new L.Point(8, 8),\r\n\t\t\tclassName: 'leaflet-div-icon leaflet-editing-icon'\r\n\t\t}),\r\n\t\ttouchIcon: new L.DivIcon({\r\n\t\t\ticonSize: new L.Point(20, 20),\r\n\t\t\tclassName: 'leaflet-div-icon leaflet-editing-icon leaflet-touch-icon'\r\n\t\t}),\r\n\t\tdrawError: {\r\n\t\t\tcolor: '#b00b00',\r\n\t\t\ttimeout: 1000\r\n\t\t}\r\n\r\n\r\n\t},\r\n\r\n\t// @method intialize(): void\r\n\tinitialize: function (poly, latlngs, options) {\r\n\t\t// if touch, switch to touch icon\r\n\t\tif (L.Browser.touch) {\r\n\t\t\tthis.options.icon = this.options.touchIcon;\r\n\t\t}\r\n\t\tthis._poly = poly;\r\n\r\n\t\tif (options && options.drawError) {\r\n\t\t\toptions.drawError = L.Util.extend({}, this.options.drawError, options.drawError);\r\n\t\t}\r\n\r\n\t\tthis._latlngs = latlngs;\r\n\r\n\t\tL.setOptions(this, options);\r\n\t},\r\n\r\n\t// Compatibility method to normalize Poly* objects\r\n\t// between 0.7.x and 1.0+\r\n\t_defaultShape: function () {\r\n\t\tif (!L.Polyline._flat) {\r\n\t\t\treturn this._latlngs;\r\n\t\t}\r\n\t\treturn L.Polyline._flat(this._latlngs) ? this._latlngs : this._latlngs[0];\r\n\t},\r\n\r\n\t// @method addHooks(): void\r\n\t// Add listener hooks to this handler.\r\n\taddHooks: function () {\r\n\t\tvar poly = this._poly;\r\n\t\tvar path = poly._path;\r\n\r\n\t\tif (!(poly instanceof L.Polygon)) {\r\n\t\t\tpoly.options.fill = false;\r\n\t\t\tif (poly.options.editing) {\r\n\t\t\t\tpoly.options.editing.fill = false;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (path) {\r\n\t\t\tif (poly.options.editing && poly.options.editing.className) {\r\n\t\t\t\tif (poly.options.original.className) {\r\n\t\t\t\t\tpoly.options.original.className.split(' ').forEach(function (className) {\r\n\t\t\t\t\t\tL.DomUtil.removeClass(path, className);\r\n\t\t\t\t\t});\r\n\t\t\t\t}\r\n\t\t\t\tpoly.options.editing.className.split(' ').forEach(function (className) {\r\n\t\t\t\t\tL.DomUtil.addClass(path, className);\r\n\t\t\t\t});\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tpoly.setStyle(poly.options.editing);\r\n\r\n\t\tif (this._poly._map) {\r\n\r\n\t\t\tthis._map = this._poly._map; // Set map\r\n\r\n\t\t\tif (!this._markerGroup) {\r\n\t\t\t\tthis._initMarkers();\r\n\t\t\t}\r\n\t\t\tthis._poly._map.addLayer(this._markerGroup);\r\n\t\t}\r\n\t},\r\n\r\n\t// @method removeHooks(): void\r\n\t// Remove listener hooks from this handler.\r\n\tremoveHooks: function () {\r\n\t\tvar poly = this._poly;\r\n\t\tvar path = poly._path;\r\n\r\n\t\tif (path) {\r\n\t\t\tif (poly.options.editing && poly.options.editing.className) {\r\n\t\t\t\tpoly.options.editing.className.split(' ').forEach(function (className) {\r\n\t\t\t\t\tL.DomUtil.removeClass(path, className);\r\n\t\t\t\t});\r\n\t\t\t\tif (poly.options.original.className) {\r\n\t\t\t\t\tpoly.options.original.className.split(' ').forEach(function (className) {\r\n\t\t\t\t\t\tL.DomUtil.addClass(path, className);\r\n\t\t\t\t\t});\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tpoly.setStyle(poly.options.original);\r\n\r\n\t\tif (poly._map) {\r\n\t\t\tpoly._map.removeLayer(this._markerGroup);\r\n\t\t\tdelete this._markerGroup;\r\n\t\t\tdelete this._markers;\r\n\t\t}\r\n\t},\r\n\r\n\t// @method updateMarkers(): void\r\n\t// Clear markers and update their location\r\n\tupdateMarkers: function () {\r\n\t\tthis._markerGroup.clearLayers();\r\n\t\tthis._initMarkers();\r\n\t},\r\n\r\n\t_initMarkers: function () {\r\n\t\tif (!this._markerGroup) {\r\n\t\t\tthis._markerGroup = new L.LayerGroup();\r\n\t\t}\r\n\t\tthis._markers = [];\r\n\r\n\t\tvar latlngs = this._defaultShape(),\r\n\t\t\ti, j, len, marker;\r\n\r\n\t\tfor (i = 0, len = latlngs.length; i < len; i++) {\r\n\r\n\t\t\tmarker = this._createMarker(latlngs[i], i);\r\n\t\t\tmarker.on('click', this._onMarkerClick, this);\r\n\t\t\tmarker.on('contextmenu', this._onContextMenu, this);\r\n\t\t\tthis._markers.push(marker);\r\n\t\t}\r\n\r\n\t\tvar markerLeft, markerRight;\r\n\r\n\t\tfor (i = 0, j = len - 1; i < len; j = i++) {\r\n\t\t\tif (i === 0 && !(L.Polygon && (this._poly instanceof L.Polygon))) {\r\n\t\t\t\tcontinue;\r\n\t\t\t}\r\n\r\n\t\t\tmarkerLeft = this._markers[j];\r\n\t\t\tmarkerRight = this._markers[i];\r\n\r\n\t\t\tthis._createMiddleMarker(markerLeft, markerRight);\r\n\t\t\tthis._updatePrevNext(markerLeft, markerRight);\r\n\t\t}\r\n\t},\r\n\r\n\t_createMarker: function (latlng, index) {\r\n\t\t// Extending L.Marker in TouchEvents.js to include touch.\r\n\t\tvar marker = new L.Marker.Touch(latlng, {\r\n\t\t\tdraggable: true,\r\n\t\t\ticon: this.options.icon,\r\n\t\t});\r\n\r\n\t\tmarker._origLatLng = latlng;\r\n\t\tmarker._index = index;\r\n\r\n\t\tmarker\r\n\t\t\t.on('dragstart', this._onMarkerDragStart, this)\r\n\t\t\t.on('drag', this._onMarkerDrag, this)\r\n\t\t\t.on('dragend', this._fireEdit, this)\r\n\t\t\t.on('touchmove', this._onTouchMove, this)\r\n\t\t\t.on('touchend', this._fireEdit, this)\r\n\t\t\t.on('MSPointerMove', this._onTouchMove, this)\r\n\t\t\t.on('MSPointerUp', this._fireEdit, this);\r\n\r\n\t\tthis._markerGroup.addLayer(marker);\r\n\r\n\t\treturn marker;\r\n\t},\r\n\r\n\t_onMarkerDragStart: function () {\r\n\t\tthis._poly.fire('editstart');\r\n\t},\r\n\r\n\t_spliceLatLngs: function () {\r\n\t\tvar latlngs = this._defaultShape();\r\n\t\tvar removed = [].splice.apply(latlngs, arguments);\r\n\t\tthis._poly._convertLatLngs(latlngs, true);\r\n\t\tthis._poly.redraw();\r\n\t\treturn removed;\r\n\t},\r\n\r\n\t_removeMarker: function (marker) {\r\n\t\tvar i = marker._index;\r\n\r\n\t\tthis._markerGroup.removeLayer(marker);\r\n\t\tthis._markers.splice(i, 1);\r\n\t\tthis._spliceLatLngs(i, 1);\r\n\t\tthis._updateIndexes(i, -1);\r\n\r\n\t\tmarker\r\n\t\t\t.off('dragstart', this._onMarkerDragStart, this)\r\n\t\t\t.off('drag', this._onMarkerDrag, this)\r\n\t\t\t.off('dragend', this._fireEdit, this)\r\n\t\t\t.off('touchmove', this._onMarkerDrag, this)\r\n\t\t\t.off('touchend', this._fireEdit, this)\r\n\t\t\t.off('click', this._onMarkerClick, this)\r\n\t\t\t.off('MSPointerMove', this._onTouchMove, this)\r\n\t\t\t.off('MSPointerUp', this._fireEdit, this);\r\n\t},\r\n\r\n\t_fireEdit: function () {\r\n\t\tthis._poly.edited = true;\r\n\t\tthis._poly.fire('edit');\r\n\t\tthis._poly._map.fire(L.Draw.Event.EDITVERTEX, {layers: this._markerGroup, poly: this._poly});\r\n\t},\r\n\r\n\t_onMarkerDrag: function (e) {\r\n\t\tvar marker = e.target;\r\n\t\tvar poly = this._poly;\r\n\r\n\t\tvar oldOrigLatLng = L.LatLngUtil.cloneLatLng(marker._origLatLng);\r\n\t\tL.extend(marker._origLatLng, marker._latlng);\r\n\t\tif (poly.options.poly) {\r\n\t\t\tvar tooltip = poly._map._editTooltip; // Access the tooltip\r\n\r\n\t\t\t// If we don't allow intersections and the polygon intersects\r\n\t\t\tif (!poly.options.poly.allowIntersection && poly.intersects()) {\r\n\t\t\t\tL.extend(marker._origLatLng, oldOrigLatLng);\r\n\t\t\t\tmarker.setLatLng(oldOrigLatLng);\r\n\t\t\t\tvar originalColor = poly.options.color;\r\n\t\t\t\tpoly.setStyle({color: this.options.drawError.color});\r\n\t\t\t\tif (tooltip) {\r\n\t\t\t\t\ttooltip.updateContent({\r\n\t\t\t\t\t\ttext: L.drawLocal.draw.handlers.polyline.error\r\n\t\t\t\t\t});\r\n\t\t\t\t}\r\n\r\n\t\t\t\t// Reset everything back to normal after a second\r\n\t\t\t\tsetTimeout(function () {\r\n\t\t\t\t\tpoly.setStyle({color: originalColor});\r\n\t\t\t\t\tif (tooltip) {\r\n\t\t\t\t\t\ttooltip.updateContent({\r\n\t\t\t\t\t\t\ttext: L.drawLocal.edit.handlers.edit.tooltip.text,\r\n\t\t\t\t\t\t\tsubtext: L.drawLocal.edit.handlers.edit.tooltip.subtext\r\n\t\t\t\t\t\t});\r\n\t\t\t\t\t}\r\n\t\t\t\t}, 1000);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (marker._middleLeft) {\r\n\t\t\tmarker._middleLeft.setLatLng(this._getMiddleLatLng(marker._prev, marker));\r\n\t\t}\r\n\t\tif (marker._middleRight) {\r\n\t\t\tmarker._middleRight.setLatLng(this._getMiddleLatLng(marker, marker._next));\r\n\t\t}\r\n\r\n\t\t//refresh the bounds when draging\r\n\t\tthis._poly._bounds._southWest = L.latLng(Infinity, Infinity);\r\n\t\tthis._poly._bounds._northEast = L.latLng(-Infinity, -Infinity);\r\n\t\tvar latlngs = this._poly.getLatLngs();\r\n\t\tthis._poly._convertLatLngs(latlngs, true);\r\n\t\tthis._poly.redraw();\r\n\t\tthis._poly.fire('editdrag');\r\n\t},\r\n\r\n\t_onMarkerClick: function (e) {\r\n\r\n\t\tvar minPoints = L.Polygon && (this._poly instanceof L.Polygon) ? 4 : 3,\r\n\t\t\tmarker = e.target;\r\n\r\n\t\t// If removing this point would create an invalid polyline/polygon don't remove\r\n\t\tif (this._defaultShape().length < minPoints) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\t// remove the marker\r\n\t\tthis._removeMarker(marker);\r\n\r\n\t\t// update prev/next links of adjacent markers\r\n\t\tthis._updatePrevNext(marker._prev, marker._next);\r\n\r\n\t\t// remove ghost markers near the removed marker\r\n\t\tif (marker._middleLeft) {\r\n\t\t\tthis._markerGroup.removeLayer(marker._middleLeft);\r\n\t\t}\r\n\t\tif (marker._middleRight) {\r\n\t\t\tthis._markerGroup.removeLayer(marker._middleRight);\r\n\t\t}\r\n\r\n\t\t// create a ghost marker in place of the removed one\r\n\t\tif (marker._prev && marker._next) {\r\n\t\t\tthis._createMiddleMarker(marker._prev, marker._next);\r\n\r\n\t\t} else if (!marker._prev) {\r\n\t\t\tmarker._next._middleLeft = null;\r\n\r\n\t\t} else if (!marker._next) {\r\n\t\t\tmarker._prev._middleRight = null;\r\n\t\t}\r\n\r\n\t\tthis._fireEdit();\r\n\t},\r\n\r\n\t_onContextMenu: function (e) {\r\n\t\tvar marker = e.target;\r\n\t\tvar poly = this._poly;\r\n\t\tthis._poly._map.fire(L.Draw.Event.MARKERCONTEXT, {marker: marker, layers: this._markerGroup, poly: this._poly});\r\n\t\tL.DomEvent.stopPropagation;\r\n\t},\r\n\r\n\t_onTouchMove: function (e) {\r\n\r\n\t\tvar layerPoint = this._map.mouseEventToLayerPoint(e.originalEvent.touches[0]),\r\n\t\t\tlatlng = this._map.layerPointToLatLng(layerPoint),\r\n\t\t\tmarker = e.target;\r\n\r\n\t\tL.extend(marker._origLatLng, latlng);\r\n\r\n\t\tif (marker._middleLeft) {\r\n\t\t\tmarker._middleLeft.setLatLng(this._getMiddleLatLng(marker._prev, marker));\r\n\t\t}\r\n\t\tif (marker._middleRight) {\r\n\t\t\tmarker._middleRight.setLatLng(this._getMiddleLatLng(marker, marker._next));\r\n\t\t}\r\n\r\n\t\tthis._poly.redraw();\r\n\t\tthis.updateMarkers();\r\n\t},\r\n\r\n\t_updateIndexes: function (index, delta) {\r\n\t\tthis._markerGroup.eachLayer(function (marker) {\r\n\t\t\tif (marker._index > index) {\r\n\t\t\t\tmarker._index += delta;\r\n\t\t\t}\r\n\t\t});\r\n\t},\r\n\r\n\t_createMiddleMarker: function (marker1, marker2) {\r\n\t\tvar latlng = this._getMiddleLatLng(marker1, marker2),\r\n\t\t\tmarker = this._createMarker(latlng),\r\n\t\t\tonClick,\r\n\t\t\tonDragStart,\r\n\t\t\tonDragEnd;\r\n\r\n\t\tmarker.setOpacity(0.6);\r\n\r\n\t\tmarker1._middleRight = marker2._middleLeft = marker;\r\n\r\n\t\tonDragStart = function () {\r\n\t\t\tmarker.off('touchmove', onDragStart, this);\r\n\t\t\tvar i = marker2._index;\r\n\r\n\t\t\tmarker._index = i;\r\n\r\n\t\t\tmarker\r\n\t\t\t\t.off('click', onClick, this)\r\n\t\t\t\t.on('click', this._onMarkerClick, this);\r\n\r\n\t\t\tlatlng.lat = marker.getLatLng().lat;\r\n\t\t\tlatlng.lng = marker.getLatLng().lng;\r\n\t\t\tthis._spliceLatLngs(i, 0, latlng);\r\n\t\t\tthis._markers.splice(i, 0, marker);\r\n\r\n\t\t\tmarker.setOpacity(1);\r\n\r\n\t\t\tthis._updateIndexes(i, 1);\r\n\t\t\tmarker2._index++;\r\n\t\t\tthis._updatePrevNext(marker1, marker);\r\n\t\t\tthis._updatePrevNext(marker, marker2);\r\n\r\n\t\t\tthis._poly.fire('editstart');\r\n\t\t};\r\n\r\n\t\tonDragEnd = function () {\r\n\t\t\tmarker.off('dragstart', onDragStart, this);\r\n\t\t\tmarker.off('dragend', onDragEnd, this);\r\n\t\t\tmarker.off('touchmove', onDragStart, this);\r\n\r\n\t\t\tthis._createMiddleMarker(marker1, marker);\r\n\t\t\tthis._createMiddleMarker(marker, marker2);\r\n\t\t};\r\n\r\n\t\tonClick = function () {\r\n\t\t\tonDragStart.call(this);\r\n\t\t\tonDragEnd.call(this);\r\n\t\t\tthis._fireEdit();\r\n\t\t};\r\n\r\n\t\tmarker\r\n\t\t\t.on('click', onClick, this)\r\n\t\t\t.on('dragstart', onDragStart, this)\r\n\t\t\t.on('dragend', onDragEnd, this)\r\n\t\t\t.on('touchmove', onDragStart, this);\r\n\r\n\t\tthis._markerGroup.addLayer(marker);\r\n\t},\r\n\r\n\t_updatePrevNext: function (marker1, marker2) {\r\n\t\tif (marker1) {\r\n\t\t\tmarker1._next = marker2;\r\n\t\t}\r\n\t\tif (marker2) {\r\n\t\t\tmarker2._prev = marker1;\r\n\t\t}\r\n\t},\r\n\r\n\t_getMiddleLatLng: function (marker1, marker2) {\r\n\t\tvar map = this._poly._map,\r\n\t\t\tp1 = map.project(marker1.getLatLng()),\r\n\t\t\tp2 = map.project(marker2.getLatLng());\r\n\r\n\t\treturn map.unproject(p1._add(p2)._divideBy(2));\r\n\t}\r\n});\r\n\r\nL.Polyline.addInitHook(function () {\r\n\r\n\t// Check to see if handler has already been initialized. This is to support versions of Leaflet that still have L.Handler.PolyEdit\r\n\tif (this.editing) {\r\n\t\treturn;\r\n\t}\r\n\r\n\tif (L.Edit.Poly) {\r\n\r\n\t\tthis.editing = new L.Edit.Poly(this);\r\n\r\n\t\tif (this.options.editable) {\r\n\t\t\tthis.editing.enable();\r\n\t\t}\r\n\t}\r\n\r\n\tthis.on('add', function () {\r\n\t\tif (this.editing && this.editing.enabled()) {\r\n\t\t\tthis.editing.addHooks();\r\n\t\t}\r\n\t});\r\n\r\n\tthis.on('remove', function () {\r\n\t\tif (this.editing && this.editing.enabled()) {\r\n\t\t\tthis.editing.removeHooks();\r\n\t\t}\r\n\t});\r\n});\r\n","L.Edit = L.Edit || {};\r\n/**\r\n * @class L.Edit.SimpleShape\r\n * @aka Edit.SimpleShape\r\n */\r\nL.Edit.SimpleShape = L.Handler.extend({\r\n\toptions: {\r\n\t\tmoveIcon: new L.DivIcon({\r\n\t\t\ticonSize: new L.Point(8, 8),\r\n\t\t\tclassName: 'leaflet-div-icon leaflet-editing-icon leaflet-edit-move'\r\n\t\t}),\r\n\t\tresizeIcon: new L.DivIcon({\r\n\t\t\ticonSize: new L.Point(8, 8),\r\n\t\t\tclassName: 'leaflet-div-icon leaflet-editing-icon leaflet-edit-resize'\r\n\t\t}),\r\n\t\ttouchMoveIcon: new L.DivIcon({\r\n\t\t\ticonSize: new L.Point(20, 20),\r\n\t\t\tclassName: 'leaflet-div-icon leaflet-editing-icon leaflet-edit-move leaflet-touch-icon'\r\n\t\t}),\r\n\t\ttouchResizeIcon: new L.DivIcon({\r\n\t\t\ticonSize: new L.Point(20, 20),\r\n\t\t\tclassName: 'leaflet-div-icon leaflet-editing-icon leaflet-edit-resize leaflet-touch-icon'\r\n\t\t}),\r\n\t},\r\n\r\n\t// @method intialize(): void\r\n\tinitialize: function (shape, options) {\r\n\t\t// if touch, switch to touch icon\r\n\t\tif (L.Browser.touch) {\r\n\t\t\tthis.options.moveIcon = this.options.touchMoveIcon;\r\n\t\t\tthis.options.resizeIcon = this.options.touchResizeIcon;\r\n\t\t}\r\n\r\n\t\tthis._shape = shape;\r\n\t\tL.Util.setOptions(this, options);\r\n\t},\r\n\r\n\t// @method addHooks(): void\r\n\t// Add listener hooks to this handler\r\n\taddHooks: function () {\r\n\t\tvar shape = this._shape;\r\n\t\tif (this._shape._map) {\r\n\t\t\tthis._map = this._shape._map;\r\n\t\t\tshape.setStyle(shape.options.editing);\r\n\r\n\t\t\tif (shape._map) {\r\n\t\t\t\tthis._map = shape._map;\r\n\t\t\t\tif (!this._markerGroup) {\r\n\t\t\t\t\tthis._initMarkers();\r\n\t\t\t\t}\r\n\t\t\t\tthis._map.addLayer(this._markerGroup);\r\n\t\t\t}\r\n\t\t}\r\n\t},\r\n\r\n\t// @method removeHooks(): void\r\n\t// Remove listener hooks from this handler\r\n\tremoveHooks: function () {\r\n\t\tvar shape = this._shape;\r\n\r\n\t\tshape.setStyle(shape.options.original);\r\n\r\n\t\tif (shape._map) {\r\n\t\t\tthis._unbindMarker(this._moveMarker);\r\n\r\n\t\t\tfor (var i = 0, l = this._resizeMarkers.length; i < l; i++) {\r\n\t\t\t\tthis._unbindMarker(this._resizeMarkers[i]);\r\n\t\t\t}\r\n\t\t\tthis._resizeMarkers = null;\r\n\r\n\t\t\tthis._map.removeLayer(this._markerGroup);\r\n\t\t\tdelete this._markerGroup;\r\n\t\t}\r\n\r\n\t\tthis._map = null;\r\n\t},\r\n\r\n\t// @method updateMarkers(): void\r\n\t// Remove the edit markers from this layer\r\n\tupdateMarkers: function () {\r\n\t\tthis._markerGroup.clearLayers();\r\n\t\tthis._initMarkers();\r\n\t},\r\n\r\n\t_initMarkers: function () {\r\n\t\tif (!this._markerGroup) {\r\n\t\t\tthis._markerGroup = new L.LayerGroup();\r\n\t\t}\r\n\r\n\t\t// Create center marker\r\n\t\tthis._createMoveMarker();\r\n\r\n\t\t// Create edge marker\r\n\t\tthis._createResizeMarker();\r\n\t},\r\n\r\n\t_createMoveMarker: function () {\r\n\t\t// Children override\r\n\t},\r\n\r\n\t_createResizeMarker: function () {\r\n\t\t// Children override\r\n\t},\r\n\r\n\t_createMarker: function (latlng, icon) {\r\n\t\t// Extending L.Marker in TouchEvents.js to include touch.\r\n\t\tvar marker = new L.Marker.Touch(latlng, {\r\n\t\t\tdraggable: true,\r\n\t\t\ticon: icon,\r\n\t\t\tzIndexOffset: 10\r\n\t\t});\r\n\r\n\t\tthis._bindMarker(marker);\r\n\r\n\t\tthis._markerGroup.addLayer(marker);\r\n\r\n\t\treturn marker;\r\n\t},\r\n\r\n\t_bindMarker: function (marker) {\r\n\t\tmarker\r\n\t\t\t.on('dragstart', this._onMarkerDragStart, this)\r\n\t\t\t.on('drag', this._onMarkerDrag, this)\r\n\t\t\t.on('dragend', this._onMarkerDragEnd, this)\r\n\t\t\t.on('touchstart', this._onTouchStart, this)\r\n\t\t\t.on('touchmove', this._onTouchMove, this)\r\n\t\t\t.on('MSPointerMove', this._onTouchMove, this)\r\n\t\t\t.on('touchend', this._onTouchEnd, this)\r\n\t\t\t.on('MSPointerUp', this._onTouchEnd, this);\r\n\t},\r\n\r\n\t_unbindMarker: function (marker) {\r\n\t\tmarker\r\n\t\t\t.off('dragstart', this._onMarkerDragStart, this)\r\n\t\t\t.off('drag', this._onMarkerDrag, this)\r\n\t\t\t.off('dragend', this._onMarkerDragEnd, this)\r\n\t\t\t.off('touchstart', this._onTouchStart, this)\r\n\t\t\t.off('touchmove', this._onTouchMove, this)\r\n\t\t\t.off('MSPointerMove', this._onTouchMove, this)\r\n\t\t\t.off('touchend', this._onTouchEnd, this)\r\n\t\t\t.off('MSPointerUp', this._onTouchEnd, this);\r\n\t},\r\n\r\n\t_onMarkerDragStart: function (e) {\r\n\t\tvar marker = e.target;\r\n\t\tmarker.setOpacity(0);\r\n\r\n\t\tthis._shape.fire('editstart');\r\n\t},\r\n\r\n\t_fireEdit: function () {\r\n\t\tthis._shape.edited = true;\r\n\t\tthis._shape.fire('edit');\r\n\t},\r\n\r\n\t_onMarkerDrag: function (e) {\r\n\t\tvar marker = e.target,\r\n\t\t\tlatlng = marker.getLatLng();\r\n\r\n\t\tif (marker === this._moveMarker) {\r\n\t\t\tthis._move(latlng);\r\n\t\t} else {\r\n\t\t\tthis._resize(latlng);\r\n\t\t}\r\n\r\n\t\tthis._shape.redraw();\r\n\t\tthis._shape.fire('editdrag');\r\n\t},\r\n\r\n\t_onMarkerDragEnd: function (e) {\r\n\t\tvar marker = e.target;\r\n\t\tmarker.setOpacity(1);\r\n\r\n\t\tthis._fireEdit();\r\n\t},\r\n\r\n\t_onTouchStart: function (e) {\r\n\t\tL.Edit.SimpleShape.prototype._onMarkerDragStart.call(this, e);\r\n\r\n\t\tif (typeof(this._getCorners) === 'function') {\r\n\t\t\t// Save a reference to the opposite point\r\n\t\t\tvar corners = this._getCorners(),\r\n\t\t\t\tmarker = e.target,\r\n\t\t\t\tcurrentCornerIndex = marker._cornerIndex;\r\n\r\n\t\t\tmarker.setOpacity(0);\r\n\r\n\t\t\t// Copyed from Edit.Rectangle.js line 23 _onMarkerDragStart()\r\n\t\t\t// Latlng is null otherwise.\r\n\t\t\tthis._oppositeCorner = corners[(currentCornerIndex + 2) % 4];\r\n\t\t\tthis._toggleCornerMarkers(0, currentCornerIndex);\r\n\t\t}\r\n\r\n\t\tthis._shape.fire('editstart');\r\n\t},\r\n\r\n\t_onTouchMove: function (e) {\r\n\t\tvar layerPoint = this._map.mouseEventToLayerPoint(e.originalEvent.touches[0]),\r\n\t\t\tlatlng = this._map.layerPointToLatLng(layerPoint),\r\n\t\t\tmarker = e.target;\r\n\r\n\t\tif (marker === this._moveMarker) {\r\n\t\t\tthis._move(latlng);\r\n\t\t} else {\r\n\t\t\tthis._resize(latlng);\r\n\t\t}\r\n\r\n\t\tthis._shape.redraw();\r\n\r\n\t\t// prevent touchcancel in IOS\r\n\t\t// e.preventDefault();\r\n\t\treturn false;\r\n\t},\r\n\r\n\t_onTouchEnd: function (e) {\r\n\t\tvar marker = e.target;\r\n\t\tmarker.setOpacity(1);\r\n\t\tthis.updateMarkers();\r\n\t\tthis._fireEdit();\r\n\t},\r\n\r\n\t_move: function () {\r\n\t\t// Children override\r\n\t},\r\n\r\n\t_resize: function () {\r\n\t\t// Children override\r\n\t}\r\n});\r\n","L.Edit = L.Edit || {};\r\n/**\r\n * @class L.Edit.Rectangle\r\n * @aka Edit.Rectangle\r\n * @inherits L.Edit.SimpleShape\r\n */\r\nL.Edit.Rectangle = L.Edit.SimpleShape.extend({\r\n\t_createMoveMarker: function () {\r\n\t\tvar bounds = this._shape.getBounds(),\r\n\t\t\tcenter = bounds.getCenter();\r\n\r\n\t\tthis._moveMarker = this._createMarker(center, this.options.moveIcon);\r\n\t},\r\n\r\n\t_createResizeMarker: function () {\r\n\t\tvar corners = this._getCorners();\r\n\r\n\t\tthis._resizeMarkers = [];\r\n\r\n\t\tfor (var i = 0, l = corners.length; i < l; i++) {\r\n\t\t\tthis._resizeMarkers.push(this._createMarker(corners[i], this.options.resizeIcon));\r\n\t\t\t// Monkey in the corner index as we will need to know this for dragging\r\n\t\t\tthis._resizeMarkers[i]._cornerIndex = i;\r\n\t\t}\r\n\t},\r\n\r\n\t_onMarkerDragStart: function (e) {\r\n\t\tL.Edit.SimpleShape.prototype._onMarkerDragStart.call(this, e);\r\n\r\n\t\t// Save a reference to the opposite point\r\n\t\tvar corners = this._getCorners(),\r\n\t\t\tmarker = e.target,\r\n\t\t\tcurrentCornerIndex = marker._cornerIndex;\r\n\r\n\t\tthis._oppositeCorner = corners[(currentCornerIndex + 2) % 4];\r\n\r\n\t\tthis._toggleCornerMarkers(0, currentCornerIndex);\r\n\t},\r\n\r\n\t_onMarkerDragEnd: function (e) {\r\n\t\tvar marker = e.target,\r\n\t\t\tbounds, center;\r\n\r\n\t\t// Reset move marker position to the center\r\n\t\tif (marker === this._moveMarker) {\r\n\t\t\tbounds = this._shape.getBounds();\r\n\t\t\tcenter = bounds.getCenter();\r\n\r\n\t\t\tmarker.setLatLng(center);\r\n\t\t}\r\n\r\n\t\tthis._toggleCornerMarkers(1);\r\n\r\n\t\tthis._repositionCornerMarkers();\r\n\r\n\t\tL.Edit.SimpleShape.prototype._onMarkerDragEnd.call(this, e);\r\n\t},\r\n\r\n\t_move: function (newCenter) {\r\n\t\tvar latlngs = this._shape._defaultShape ? this._shape._defaultShape() : this._shape.getLatLngs(),\r\n\t\t\tbounds = this._shape.getBounds(),\r\n\t\t\tcenter = bounds.getCenter(),\r\n\t\t\toffset, newLatLngs = [];\r\n\r\n\t\t// Offset the latlngs to the new center\r\n\t\tfor (var i = 0, l = latlngs.length; i < l; i++) {\r\n\t\t\toffset = [latlngs[i].lat - center.lat, latlngs[i].lng - center.lng];\r\n\t\t\tnewLatLngs.push([newCenter.lat + offset[0], newCenter.lng + offset[1]]);\r\n\t\t}\r\n\r\n\t\tthis._shape.setLatLngs(newLatLngs);\r\n\r\n\t\t// Reposition the resize markers\r\n\t\tthis._repositionCornerMarkers();\r\n\r\n\t\tthis._map.fire(L.Draw.Event.EDITMOVE, {layer: this._shape});\r\n\t},\r\n\r\n\t_resize: function (latlng) {\r\n\t\tvar bounds;\r\n\r\n\t\t// Update the shape based on the current position of this corner and the opposite point\r\n\t\tthis._shape.setBounds(L.latLngBounds(latlng, this._oppositeCorner));\r\n\r\n\t\t// Reposition the move marker\r\n\t\tbounds = this._shape.getBounds();\r\n\t\tthis._moveMarker.setLatLng(bounds.getCenter());\r\n\r\n\t\tthis._map.fire(L.Draw.Event.EDITRESIZE, {layer: this._shape});\r\n\t},\r\n\r\n\t_getCorners: function () {\r\n\t\tvar bounds = this._shape.getBounds(),\r\n\t\t\tnw = bounds.getNorthWest(),\r\n\t\t\tne = bounds.getNorthEast(),\r\n\t\t\tse = bounds.getSouthEast(),\r\n\t\t\tsw = bounds.getSouthWest();\r\n\r\n\t\treturn [nw, ne, se, sw];\r\n\t},\r\n\r\n\t_toggleCornerMarkers: function (opacity) {\r\n\t\tfor (var i = 0, l = this._resizeMarkers.length; i < l; i++) {\r\n\t\t\tthis._resizeMarkers[i].setOpacity(opacity);\r\n\t\t}\r\n\t},\r\n\r\n\t_repositionCornerMarkers: function () {\r\n\t\tvar corners = this._getCorners();\r\n\r\n\t\tfor (var i = 0, l = this._resizeMarkers.length; i < l; i++) {\r\n\t\t\tthis._resizeMarkers[i].setLatLng(corners[i]);\r\n\t\t}\r\n\t}\r\n});\r\n\r\nL.Rectangle.addInitHook(function () {\r\n\tif (L.Edit.Rectangle) {\r\n\t\tthis.editing = new L.Edit.Rectangle(this);\r\n\r\n\t\tif (this.options.editable) {\r\n\t\t\tthis.editing.enable();\r\n\t\t}\r\n\t}\r\n});\r\n","L.Edit = L.Edit || {};\r\n/**\r\n * @class L.Edit.CircleMarker\r\n * @aka Edit.Circle\r\n * @inherits L.Edit.SimpleShape\r\n */\r\nL.Edit.CircleMarker = L.Edit.SimpleShape.extend({\r\n\t_createMoveMarker: function () {\r\n\t\tvar center = this._shape.getLatLng();\r\n\t\tthis._map._editTooltip = new L.Draw.Tooltip(this._map);\r\n\t\tthis._moveMarker = this._createMarker(center, this.options.moveIcon);\r\n\t},\r\n\r\n\t_createResizeMarker: function () {\r\n\t\t// To avoid an undefined check in L.Edit.SimpleShape.removeHooks\r\n\t\tthis._resizeMarkers = [];\r\n\t},\r\n\r\n\t_move: function (latlng) {\r\n\t\tif (this._resizeMarkers.length) {\r\n\t\t\tvar resizemarkerPoint = this._getResizeMarkerPoint(latlng);\r\n\t\t\t// Move the resize marker\r\n\t\t\tthis._resizeMarkers[0].setLatLng(resizemarkerPoint);\r\n\t\t}\r\n\r\n\t\t// Move the circle\r\n\t\tthis._shape.setLatLng(latlng);\r\n\r\n\t\tthis._map.fire(L.Draw.Event.EDITMOVE, {layer: this._shape});\r\n\t},\r\n});\r\n\r\nL.CircleMarker.addInitHook(function () {\r\n\tif (L.Edit.CircleMarker) {\r\n\t\tthis.editing = new L.Edit.CircleMarker(this);\r\n\r\n\t\tif (this.options.editable) {\r\n\t\t\tthis.editing.enable();\r\n\t\t}\r\n\t}\r\n\r\n\tthis.on('add', function () {\r\n\t\tif (this.editing && this.editing.enabled()) {\r\n\t\t\tthis.editing.addHooks();\r\n\t\t}\r\n\t});\r\n\r\n\tthis.on('remove', function () {\r\n\t\tif (this.editing && this.editing.enabled()) {\r\n\t\t\tthis.editing.removeHooks();\r\n\t\t}\r\n\t});\r\n});\r\n","L.Edit = L.Edit || {};\r\n/**\r\n * @class L.Edit.Circle\r\n * @aka Edit.Circle\r\n * @inherits L.Edit.CircleMarker\r\n */\r\nL.Edit.Circle = L.Edit.CircleMarker.extend({\r\n\r\n\t_createResizeMarker: function () {\r\n\t\tvar center = this._shape.getLatLng(),\r\n\t\t\tresizemarkerPoint = this._getResizeMarkerPoint(center);\r\n\r\n\t\tthis._resizeMarkers = [];\r\n\t\tthis._resizeMarkers.push(this._createMarker(resizemarkerPoint, this.options.resizeIcon));\r\n\t},\r\n\r\n\t_getResizeMarkerPoint: function (latlng) {\r\n\t\t// From L.shape.getBounds()\r\n\t\tvar delta = this._shape._radius * Math.cos(Math.PI / 4),\r\n\t\t\tpoint = this._map.project(latlng);\r\n\t\treturn this._map.unproject([point.x + delta, point.y - delta]);\r\n\t},\r\n\r\n\t_resize: function (latlng) {\r\n\t\tvar moveLatLng = this._moveMarker.getLatLng();\r\n\r\n\t\t// Calculate the radius based on the version\r\n\t\tif (L.GeometryUtil.isVersion07x()) {\r\n\t\t\tradius = moveLatLng.distanceTo(latlng);\r\n\t\t} else {\r\n\t\t\tradius = this._map.distance(moveLatLng, latlng);\r\n\t\t}\r\n\t\tthis._shape.setRadius(radius);\r\n\r\n\t\tif (this._map.editTooltip) {\r\n\t\t\tthis._map._editTooltip.updatePosition(latlng);\r\n\t\t\tthis._map._editTooltip.updateContent({\r\n\t\t\t\ttext: L.drawLocal.edit.handlers.edit.tooltip.subtext + '
' + L.drawLocal.edit.handlers.edit.tooltip.text,\r\n\t\t\t\tsubtext: L.drawLocal.draw.handlers.circle.radius + ': ' +\r\n\t\t\t\tL.GeometryUtil.readableDistance(radius, true, this.options.feet, this.options.nautic)\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\tthis._shape.setRadius(radius);\r\n\r\n\t\tthis._map.fire(L.Draw.Event.EDITRESIZE, {layer: this._shape});\r\n\t}\r\n});\r\n\r\nL.Circle.addInitHook(function () {\r\n\tif (L.Edit.Circle) {\r\n\t\tthis.editing = new L.Edit.Circle(this);\r\n\r\n\t\tif (this.options.editable) {\r\n\t\t\tthis.editing.enable();\r\n\t\t}\r\n\t}\r\n});\r\n","L.Map.mergeOptions({\r\n\ttouchExtend: true\r\n});\r\n\r\n/**\r\n * @class L.Map.TouchExtend\r\n * @aka TouchExtend\r\n */\r\nL.Map.TouchExtend = L.Handler.extend({\r\n\r\n\t// @method initialize(): void\r\n\t// Sets TouchExtend private accessor variables\r\n\tinitialize: function (map) {\r\n\t\tthis._map = map;\r\n\t\tthis._container = map._container;\r\n\t\tthis._pane = map._panes.overlayPane;\r\n\t},\r\n\r\n\t// @method addHooks(): void\r\n\t// Adds dom listener events to the map container\r\n\taddHooks: function () {\r\n\t\tL.DomEvent.on(this._container, 'touchstart', this._onTouchStart, this);\r\n\t\tL.DomEvent.on(this._container, 'touchend', this._onTouchEnd, this);\r\n\t\tL.DomEvent.on(this._container, 'touchmove', this._onTouchMove, this);\r\n\t\tif (this._detectIE()) {\r\n\t\t\tL.DomEvent.on(this._container, 'MSPointerDown', this._onTouchStart, this);\r\n\t\t\tL.DomEvent.on(this._container, 'MSPointerUp', this._onTouchEnd, this);\r\n\t\t\tL.DomEvent.on(this._container, 'MSPointerMove', this._onTouchMove, this);\r\n\t\t\tL.DomEvent.on(this._container, 'MSPointerCancel', this._onTouchCancel, this);\r\n\r\n\t\t} else {\r\n\t\t\tL.DomEvent.on(this._container, 'touchcancel', this._onTouchCancel, this);\r\n\t\t\tL.DomEvent.on(this._container, 'touchleave', this._onTouchLeave, this);\r\n\t\t}\r\n\t},\r\n\r\n\t// @method removeHooks(): void\r\n\t// Removes dom listener events from the map container\r\n\tremoveHooks: function () {\r\n\t\tL.DomEvent.off(this._container, 'touchstart', this._onTouchStart, this);\r\n\t\tL.DomEvent.off(this._container, 'touchend', this._onTouchEnd, this);\r\n\t\tL.DomEvent.off(this._container, 'touchmove', this._onTouchMove, this);\r\n\t\tif (this._detectIE()) {\r\n\t\t\tL.DomEvent.off(this._container, 'MSPointerDown', this._onTouchStart, this);\r\n\t\t\tL.DomEvent.off(this._container, 'MSPointerUp', this._onTouchEnd, this);\r\n\t\t\tL.DomEvent.off(this._container, 'MSPointerMove', this._onTouchMove, this);\r\n\t\t\tL.DomEvent.off(this._container, 'MSPointerCancel', this._onTouchCancel, this);\r\n\t\t} else {\r\n\t\t\tL.DomEvent.off(this._container, 'touchcancel', this._onTouchCancel, this);\r\n\t\t\tL.DomEvent.off(this._container, 'touchleave', this._onTouchLeave, this);\r\n\t\t}\r\n\t},\r\n\r\n\t_touchEvent: function (e, type) {\r\n\t\t// #TODO: fix the pageX error that is do a bug in Android where a single touch triggers two click events\r\n\t\t// _filterClick is what leaflet uses as a workaround.\r\n\t\t// This is a problem with more things than just android. Another problem is touchEnd has no touches in\r\n\t\t// its touch list.\r\n\t\tvar touchEvent = {};\r\n\t\tif (typeof e.touches !== 'undefined') {\r\n\t\t\tif (!e.touches.length) {\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\t\t\ttouchEvent = e.touches[0];\r\n\t\t} else if (e.pointerType === 'touch') {\r\n\t\t\ttouchEvent = e;\r\n\t\t\tif (!this._filterClick(e)) {\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\t\t} else {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tvar containerPoint = this._map.mouseEventToContainerPoint(touchEvent),\r\n\t\t\tlayerPoint = this._map.mouseEventToLayerPoint(touchEvent),\r\n\t\t\tlatlng = this._map.layerPointToLatLng(layerPoint);\r\n\r\n\t\tthis._map.fire(type, {\r\n\t\t\tlatlng: latlng,\r\n\t\t\tlayerPoint: layerPoint,\r\n\t\t\tcontainerPoint: containerPoint,\r\n\t\t\tpageX: touchEvent.pageX,\r\n\t\t\tpageY: touchEvent.pageY,\r\n\t\t\toriginalEvent: e\r\n\t\t});\r\n\t},\r\n\r\n\t/** Borrowed from Leaflet and modified for bool ops **/\r\n\t_filterClick: function (e) {\r\n\t\tvar timeStamp = (e.timeStamp || e.originalEvent.timeStamp),\r\n\t\t\telapsed = L.DomEvent._lastClick && (timeStamp - L.DomEvent._lastClick);\r\n\r\n\t\t// are they closer together than 500ms yet more than 100ms?\r\n\t\t// Android typically triggers them ~300ms apart while multiple listeners\r\n\t\t// on the same event should be triggered far faster;\r\n\t\t// or check if click is simulated on the element, and if it is, reject any non-simulated events\r\n\t\tif ((elapsed && elapsed > 100 && elapsed < 500) || (e.target._simulatedClick && !e._simulated)) {\r\n\t\t\tL.DomEvent.stop(e);\r\n\t\t\treturn false;\r\n\t\t}\r\n\t\tL.DomEvent._lastClick = timeStamp;\r\n\t\treturn true;\r\n\t},\r\n\r\n\t_onTouchStart: function (e) {\r\n\t\tif (!this._map._loaded) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tvar type = 'touchstart';\r\n\t\tthis._touchEvent(e, type);\r\n\r\n\t},\r\n\r\n\t_onTouchEnd: function (e) {\r\n\t\tif (!this._map._loaded) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tvar type = 'touchend';\r\n\t\tthis._touchEvent(e, type);\r\n\t},\r\n\r\n\t_onTouchCancel: function (e) {\r\n\t\tif (!this._map._loaded) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tvar type = 'touchcancel';\r\n\t\tif (this._detectIE()) {\r\n\t\t\ttype = 'pointercancel';\r\n\t\t}\r\n\t\tthis._touchEvent(e, type);\r\n\t},\r\n\r\n\t_onTouchLeave: function (e) {\r\n\t\tif (!this._map._loaded) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tvar type = 'touchleave';\r\n\t\tthis._touchEvent(e, type);\r\n\t},\r\n\r\n\t_onTouchMove: function (e) {\r\n\t\tif (!this._map._loaded) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tvar type = 'touchmove';\r\n\t\tthis._touchEvent(e, type);\r\n\t},\r\n\r\n\t_detectIE: function () {\r\n\t\tvar ua = window.navigator.userAgent;\r\n\r\n\t\tvar msie = ua.indexOf('MSIE ');\r\n\t\tif (msie > 0) {\r\n\t\t\t// IE 10 or older => return version number\r\n\t\t\treturn parseInt(ua.substring(msie + 5, ua.indexOf('.', msie)), 10);\r\n\t\t}\r\n\r\n\t\tvar trident = ua.indexOf('Trident/');\r\n\t\tif (trident > 0) {\r\n\t\t\t// IE 11 => return version number\r\n\t\t\tvar rv = ua.indexOf('rv:');\r\n\t\t\treturn parseInt(ua.substring(rv + 3, ua.indexOf('.', rv)), 10);\r\n\t\t}\r\n\r\n\t\tvar edge = ua.indexOf('Edge/');\r\n\t\tif (edge > 0) {\r\n\t\t\t// IE 12 => return version number\r\n\t\t\treturn parseInt(ua.substring(edge + 5, ua.indexOf('.', edge)), 10);\r\n\t\t}\r\n\r\n\t\t// other browser\r\n\t\treturn false;\r\n\t}\r\n});\r\n\r\nL.Map.addInitHook('addHandler', 'touchExtend', L.Map.TouchExtend);\r\n\r\n\r\n/**\r\n * @class L.Marker.Touch\r\n * @aka Marker.Touch\r\n *\r\n * This isn't full Touch support. This is just to get markers to also support dom touch events after creation\r\n * #TODO: find a better way of getting markers to support touch.\r\n */\r\nL.Marker.Touch = L.Marker.extend({\r\n\r\n\t_initInteraction: function () {\r\n\t\tif (!this.addInteractiveTarget) {\r\n\t\t\t// 0.7.x support\r\n\t\t\treturn this._initInteractionLegacy();\r\n\t\t}\r\n\t\t// TODO this may need be updated to re-add touch events for 1.0+\r\n\t\treturn L.Marker.prototype._initInteraction.apply(this);\r\n\t},\r\n\r\n\t// This is an exact copy of https://github.com/Leaflet/Leaflet/blob/v0.7/src/layer/marker/Marker.js\r\n\t// with the addition of the touch events\r\n\t_initInteractionLegacy: function () {\r\n\r\n\t\tif (!this.options.clickable) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\t// TODO refactor into something shared with Map/Path/etc. to DRY it up\r\n\r\n\t\tvar icon = this._icon,\r\n\t\t\tevents = ['dblclick',\r\n\t\t\t\t'mousedown',\r\n\t\t\t\t'mouseover',\r\n\t\t\t\t'mouseout',\r\n\t\t\t\t'contextmenu',\r\n\t\t\t\t'touchstart',\r\n\t\t\t\t'touchend',\r\n\t\t\t\t'touchmove'];\r\n\t\tif (this._detectIE) {\r\n\t\t\tevents.concat(['MSPointerDown',\r\n\t\t\t\t'MSPointerUp',\r\n\t\t\t\t'MSPointerMove',\r\n\t\t\t\t'MSPointerCancel']);\r\n\t\t} else {\r\n\t\t\tevents.concat(['touchcancel']);\r\n\t\t}\r\n\r\n\t\tL.DomUtil.addClass(icon, 'leaflet-clickable');\r\n\t\tL.DomEvent.on(icon, 'click', this._onMouseClick, this);\r\n\t\tL.DomEvent.on(icon, 'keypress', this._onKeyPress, this);\r\n\r\n\t\tfor (var i = 0; i < events.length; i++) {\r\n\t\t\tL.DomEvent.on(icon, events[i], this._fireMouseEvent, this);\r\n\t\t}\r\n\r\n\t\tif (L.Handler.MarkerDrag) {\r\n\t\t\tthis.dragging = new L.Handler.MarkerDrag(this);\r\n\r\n\t\t\tif (this.options.draggable) {\r\n\t\t\t\tthis.dragging.enable();\r\n\t\t\t}\r\n\t\t}\r\n\t},\r\n\r\n\t_detectIE: function () {\r\n\t\tvar ua = window.navigator.userAgent;\r\n\r\n\t\tvar msie = ua.indexOf('MSIE ');\r\n\t\tif (msie > 0) {\r\n\t\t\t// IE 10 or older => return version number\r\n\t\t\treturn parseInt(ua.substring(msie + 5, ua.indexOf('.', msie)), 10);\r\n\t\t}\r\n\r\n\t\tvar trident = ua.indexOf('Trident/');\r\n\t\tif (trident > 0) {\r\n\t\t\t// IE 11 => return version number\r\n\t\t\tvar rv = ua.indexOf('rv:');\r\n\t\t\treturn parseInt(ua.substring(rv + 3, ua.indexOf('.', rv)), 10);\r\n\t\t}\r\n\r\n\t\tvar edge = ua.indexOf('Edge/');\r\n\t\tif (edge > 0) {\r\n\t\t\t// IE 12 => return version number\r\n\t\t\treturn parseInt(ua.substring(edge + 5, ua.indexOf('.', edge)), 10);\r\n\t\t}\r\n\r\n\t\t// other browser\r\n\t\treturn false;\r\n\t}\r\n});\r\n","/**\r\n * @class L.LatLngUtil\r\n * @aka LatLngUtil\r\n */\r\nL.LatLngUtil = {\r\n\t// Clones a LatLngs[], returns [][]\r\n\r\n\t// @method cloneLatLngs(LatLngs[]): L.LatLngs[]\r\n\t// Clone the latLng point or points or nested points and return an array with those points\r\n\tcloneLatLngs: function (latlngs) {\r\n\t\tvar clone = [];\r\n\t\tfor (var i = 0, l = latlngs.length; i < l; i++) {\r\n\t\t\t// Check for nested array (Polyline/Polygon)\r\n\t\t\tif (Array.isArray(latlngs[i])) {\r\n\t\t\t\tclone.push(L.LatLngUtil.cloneLatLngs(latlngs[i]));\r\n\t\t\t} else {\r\n\t\t\t\tclone.push(this.cloneLatLng(latlngs[i]));\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn clone;\r\n\t},\r\n\r\n\t// @method cloneLatLng(LatLng): L.LatLng\r\n\t// Clone the latLng and return a new LatLng object.\r\n\tcloneLatLng: function (latlng) {\r\n\t\treturn L.latLng(latlng.lat, latlng.lng);\r\n\t}\r\n};\r\n","(function () {\r\n\r\n\tvar defaultPrecision = {\r\n\t\tkm: 2,\r\n\t\tha: 2,\r\n\t\tm: 0,\r\n\t\tmi: 2,\r\n\t\tac: 2,\r\n\t\tyd: 0,\r\n\t\tft: 0,\r\n\t\tnm: 2\r\n\t};\r\n\r\n\r\n\t/**\r\n\t * @class L.GeometryUtil\r\n\t * @aka GeometryUtil\r\n\t */\r\n\tL.GeometryUtil = L.extend(L.GeometryUtil || {}, {\r\n\t\t// Ported from the OpenLayers implementation. See https://github.com/openlayers/openlayers/blob/master/lib/OpenLayers/Geometry/LinearRing.js#L270\r\n\r\n\t\t// @method geodesicArea(): number\r\n\t\tgeodesicArea: function (latLngs) {\r\n\t\t\tvar pointsCount = latLngs.length,\r\n\t\t\t\tarea = 0.0,\r\n\t\t\t\td2r = Math.PI / 180,\r\n\t\t\t\tp1, p2;\r\n\r\n\t\t\tif (pointsCount > 2) {\r\n\t\t\t\tfor (var i = 0; i < pointsCount; i++) {\r\n\t\t\t\t\tp1 = latLngs[i];\r\n\t\t\t\t\tp2 = latLngs[(i + 1) % pointsCount];\r\n\t\t\t\t\tarea += ((p2.lng - p1.lng) * d2r) *\r\n\t\t\t\t\t\t(2 + Math.sin(p1.lat * d2r) + Math.sin(p2.lat * d2r));\r\n\t\t\t\t}\r\n\t\t\t\tarea = area * 6378137.0 * 6378137.0 / 2.0;\r\n\t\t\t}\r\n\r\n\t\t\treturn Math.abs(area);\r\n\t\t},\r\n\r\n\t\t// @method formattedNumber(n, precision): string\r\n\t\t// Returns n in specified number format (if defined) and precision\r\n\t\tformattedNumber: function (n, precision) {\r\n\t\t\tvar formatted = parseFloat(n).toFixed(precision),\r\n\t\t\t\tformat = L.drawLocal.format && L.drawLocal.format.numeric,\r\n\t\t\t\tdelimiters = format && format.delimiters,\r\n\t\t\t\tthousands = delimiters && delimiters.thousands,\r\n\t\t\t\tdecimal = delimiters && delimiters.decimal;\r\n\r\n\t\t\tif (thousands || decimal) {\r\n\t\t\t\tvar splitValue = formatted.split('.');\r\n\t\t\t\tformatted = thousands ? splitValue[0].replace(/(\\d)(?=(\\d{3})+(?!\\d))/g, '$1' + thousands) : splitValue[0];\r\n\t\t\t\tdecimal = decimal || '.';\r\n\t\t\t\tif (splitValue.length > 1) {\r\n\t\t\t\t\tformatted = formatted + decimal + splitValue[1];\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\treturn formatted;\r\n\t\t},\r\n\r\n\t\t// @method readableArea(area, isMetric, precision): string\r\n\t\t// Returns a readable area string in yards or metric.\r\n\t\t// The value will be rounded as defined by the precision option object.\r\n\t\treadableArea: function (area, isMetric, precision) {\r\n\t\t\tvar areaStr,\r\n\t\t\t\tunits,\r\n\t\t\t\tprecision = L.Util.extend({}, defaultPrecision, precision);\r\n\r\n\t\t\tif (isMetric) {\r\n\t\t\t\tunits = ['ha', 'm'];\r\n\t\t\t\ttype = typeof isMetric;\r\n\t\t\t\tif (type === 'string') {\r\n\t\t\t\t\tunits = [isMetric];\r\n\t\t\t\t} else if (type !== 'boolean') {\r\n\t\t\t\t\tunits = isMetric;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif (area >= 1000000 && units.indexOf('km') !== -1) {\r\n\t\t\t\t\tareaStr = L.GeometryUtil.formattedNumber(area * 0.000001, precision['km']) + ' km²';\r\n\t\t\t\t} else if (area >= 10000 && units.indexOf('ha') !== -1) {\r\n\t\t\t\t\tareaStr = L.GeometryUtil.formattedNumber(area * 0.0001, precision['ha']) + ' ha';\r\n\t\t\t\t} else {\r\n\t\t\t\t\tareaStr = L.GeometryUtil.formattedNumber(area, precision['m']) + ' m²';\r\n\t\t\t\t}\r\n\t\t\t} else {\r\n\t\t\t\tarea /= 0.836127; // Square yards in 1 meter\r\n\r\n\t\t\t\tif (area >= 3097600) { //3097600 square yards in 1 square mile\r\n\t\t\t\t\tareaStr = L.GeometryUtil.formattedNumber(area / 3097600, precision['mi']) + ' mi²';\r\n\t\t\t\t} else if (area >= 4840) { //4840 square yards in 1 acre\r\n\t\t\t\t\tareaStr = L.GeometryUtil.formattedNumber(area / 4840, precision['ac']) + ' acres';\r\n\t\t\t\t} else {\r\n\t\t\t\t\tareaStr = L.GeometryUtil.formattedNumber(area, precision['yd']) + ' yd²';\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\treturn areaStr;\r\n\t\t},\r\n\r\n\t\t// @method readableDistance(distance, units): string\r\n\t\t// Converts a metric distance to one of [ feet, nauticalMile, metric or yards ] string\r\n\t\t//\r\n\t\t// @alternative\r\n\t\t// @method readableDistance(distance, isMetric, useFeet, isNauticalMile, precision): string\r\n\t\t// Converts metric distance to distance string.\r\n\t\t// The value will be rounded as defined by the precision option object.\r\n\t\treadableDistance: function (distance, isMetric, isFeet, isNauticalMile, precision) {\r\n\t\t\tvar distanceStr,\r\n\t\t\t\tunits,\r\n\t\t\t\tprecision = L.Util.extend({}, defaultPrecision, precision);\r\n\r\n\t\t\tif (isMetric) {\r\n\t\t\t\tunits = typeof isMetric == 'string' ? isMetric : 'metric';\r\n\t\t\t} else if (isFeet) {\r\n\t\t\t\tunits = 'feet';\r\n\t\t\t} else if (isNauticalMile) {\r\n\t\t\t\tunits = 'nauticalMile';\r\n\t\t\t} else {\r\n\t\t\t\tunits = 'yards';\r\n\t\t\t}\r\n\r\n\t\t\tswitch (units) {\r\n\t\t\t\tcase 'metric':\r\n\t\t\t\t\t// show metres when distance is < 1km, then show km\r\n\t\t\t\t\tif (distance > 1000) {\r\n\t\t\t\t\t\tdistanceStr = L.GeometryUtil.formattedNumber(distance / 1000, precision['km']) + ' km';\r\n\t\t\t\t\t} else {\r\n\t\t\t\t\t\tdistanceStr = L.GeometryUtil.formattedNumber(distance, precision['m']) + ' m';\r\n\t\t\t\t\t}\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase 'feet':\r\n\t\t\t\t\tdistance *= 1.09361 * 3;\r\n\t\t\t\t\tdistanceStr = L.GeometryUtil.formattedNumber(distance, precision['ft']) + ' ft';\r\n\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase 'nauticalMile':\r\n\t\t\t\t\tdistance *= 0.53996;\r\n\t\t\t\t\tdistanceStr = L.GeometryUtil.formattedNumber(distance / 1000, precision['nm']) + ' nm';\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase 'yards':\r\n\t\t\t\tdefault:\r\n\t\t\t\t\tdistance *= 1.09361;\r\n\r\n\t\t\t\t\tif (distance > 1760) {\r\n\t\t\t\t\t\tdistanceStr = L.GeometryUtil.formattedNumber(distance / 1760, precision['mi']) + ' miles';\r\n\t\t\t\t\t} else {\r\n\t\t\t\t\t\tdistanceStr = L.GeometryUtil.formattedNumber(distance, precision['yd']) + ' yd';\r\n\t\t\t\t\t}\r\n\t\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t\treturn distanceStr;\r\n\t\t},\r\n\r\n\t\t// @method isVersion07x(): boolean\r\n\t\t// Returns true if the Leaflet version is 0.7.x, false otherwise.\r\n\t\tisVersion07x: function () {\r\n\t\t\tvar version = L.version.split('.');\r\n\t\t\t//If Version is == 0.7.*\r\n\t\t\treturn parseInt(version[0], 10) === 0 && parseInt(version[1], 10) === 7;\r\n\t\t},\r\n\t});\r\n\r\n})();\r\n","/**\r\n * @class L.LineUtil\r\n * @aka Util\r\n * @aka L.Utils\r\n */\r\nL.Util.extend(L.LineUtil, {\r\n\r\n\t// @method segmentsIntersect(): boolean\r\n\t// Checks to see if two line segments intersect. Does not handle degenerate cases.\r\n\t// http://compgeom.cs.uiuc.edu/~jeffe/teaching/373/notes/x06-sweepline.pdf\r\n\tsegmentsIntersect: function (/*Point*/ p, /*Point*/ p1, /*Point*/ p2, /*Point*/ p3) {\r\n\t\treturn this._checkCounterclockwise(p, p2, p3) !==\r\n\t\t\tthis._checkCounterclockwise(p1, p2, p3) &&\r\n\t\t\tthis._checkCounterclockwise(p, p1, p2) !==\r\n\t\t\tthis._checkCounterclockwise(p, p1, p3);\r\n\t},\r\n\r\n\t// check to see if points are in counterclockwise order\r\n\t_checkCounterclockwise: function (/*Point*/ p, /*Point*/ p1, /*Point*/ p2) {\r\n\t\treturn (p2.y - p.y) * (p1.x - p.x) > (p1.y - p.y) * (p2.x - p.x);\r\n\t}\r\n});\r\n","/**\r\n * @class L.Polyline\r\n * @aka Polyline\r\n */\r\nL.Polyline.include({\r\n\r\n\t// @method intersects(): boolean\r\n\t// Check to see if this polyline has any linesegments that intersect.\r\n\t// NOTE: does not support detecting intersection for degenerate cases.\r\n\tintersects: function () {\r\n\t\tvar points = this._getProjectedPoints(),\r\n\t\t\tlen = points ? points.length : 0,\r\n\t\t\ti, p, p1;\r\n\r\n\t\tif (this._tooFewPointsForIntersection()) {\r\n\t\t\treturn false;\r\n\t\t}\r\n\r\n\t\tfor (i = len - 1; i >= 3; i--) {\r\n\t\t\tp = points[i - 1];\r\n\t\t\tp1 = points[i];\r\n\r\n\r\n\t\t\tif (this._lineSegmentsIntersectsRange(p, p1, i - 2)) {\r\n\t\t\t\treturn true;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn false;\r\n\t},\r\n\r\n\t// @method newLatLngIntersects(): boolean\r\n\t// Check for intersection if new latlng was added to this polyline.\r\n\t// NOTE: does not support detecting intersection for degenerate cases.\r\n\tnewLatLngIntersects: function (latlng, skipFirst) {\r\n\t\t// Cannot check a polyline for intersecting lats/lngs when not added to the map\r\n\t\tif (!this._map) {\r\n\t\t\treturn false;\r\n\t\t}\r\n\r\n\t\treturn this.newPointIntersects(this._map.latLngToLayerPoint(latlng), skipFirst);\r\n\t},\r\n\r\n\t// @method newPointIntersects(): boolean\r\n\t// Check for intersection if new point was added to this polyline.\r\n\t// newPoint must be a layer point.\r\n\t// NOTE: does not support detecting intersection for degenerate cases.\r\n\tnewPointIntersects: function (newPoint, skipFirst) {\r\n\t\tvar points = this._getProjectedPoints(),\r\n\t\t\tlen = points ? points.length : 0,\r\n\t\t\tlastPoint = points ? points[len - 1] : null,\r\n\t\t\t// The previous previous line segment. Previous line segment doesn't need testing.\r\n\t\t\tmaxIndex = len - 2;\r\n\r\n\t\tif (this._tooFewPointsForIntersection(1)) {\r\n\t\t\treturn false;\r\n\t\t}\r\n\r\n\t\treturn this._lineSegmentsIntersectsRange(lastPoint, newPoint, maxIndex, skipFirst ? 1 : 0);\r\n\t},\r\n\r\n\t// Polylines with 2 sides can only intersect in cases where points are collinear (we don't support detecting these).\r\n\t// Cannot have intersection when < 3 line segments (< 4 points)\r\n\t_tooFewPointsForIntersection: function (extraPoints) {\r\n\t\tvar points = this._getProjectedPoints(),\r\n\t\t\tlen = points ? points.length : 0;\r\n\t\t// Increment length by extraPoints if present\r\n\t\tlen += extraPoints || 0;\r\n\r\n\t\treturn !points || len <= 3;\r\n\t},\r\n\r\n\t// Checks a line segment intersections with any line segments before its predecessor.\r\n\t// Don't need to check the predecessor as will never intersect.\r\n\t_lineSegmentsIntersectsRange: function (p, p1, maxIndex, minIndex) {\r\n\t\tvar points = this._getProjectedPoints(),\r\n\t\t\tp2, p3;\r\n\r\n\t\tminIndex = minIndex || 0;\r\n\r\n\t\t// Check all previous line segments (beside the immediately previous) for intersections\r\n\t\tfor (var j = maxIndex; j > minIndex; j--) {\r\n\t\t\tp2 = points[j - 1];\r\n\t\t\tp3 = points[j];\r\n\r\n\t\t\tif (L.LineUtil.segmentsIntersect(p, p1, p2, p3)) {\r\n\t\t\t\treturn true;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn false;\r\n\t},\r\n\r\n\t_getProjectedPoints: function () {\r\n\t\tif (!this._defaultShape) {\r\n\t\t\treturn this._originalPoints;\r\n\t\t}\r\n\t\tvar points = [],\r\n\t\t\t_shape = this._defaultShape();\r\n\r\n\t\tfor (var i = 0; i < _shape.length; i++) {\r\n\t\t\tpoints.push(this._map.latLngToLayerPoint(_shape[i]));\r\n\t\t}\r\n\t\treturn points;\r\n\t}\r\n});\r\n","/**\r\n * @class L.Polygon\r\n * @aka Polygon\r\n */\r\nL.Polygon.include({\r\n\r\n\t// @method intersects(): boolean\r\n\t// Checks a polygon for any intersecting line segments. Ignores holes.\r\n\tintersects: function () {\r\n\t\tvar polylineIntersects,\r\n\t\t\tpoints = this._getProjectedPoints(),\r\n\t\t\tlen, firstPoint, lastPoint, maxIndex;\r\n\r\n\t\tif (this._tooFewPointsForIntersection()) {\r\n\t\t\treturn false;\r\n\t\t}\r\n\r\n\t\tpolylineIntersects = L.Polyline.prototype.intersects.call(this);\r\n\r\n\t\t// If already found an intersection don't need to check for any more.\r\n\t\tif (polylineIntersects) {\r\n\t\t\treturn true;\r\n\t\t}\r\n\r\n\t\tlen = points.length;\r\n\t\tfirstPoint = points[0];\r\n\t\tlastPoint = points[len - 1];\r\n\t\tmaxIndex = len - 2;\r\n\r\n\t\t// Check the line segment between last and first point. Don't need to check the first line segment (minIndex = 1)\r\n\t\treturn this._lineSegmentsIntersectsRange(lastPoint, firstPoint, maxIndex, 1);\r\n\t}\r\n});\r\n","/**\r\n * @class L.Control.Draw\r\n * @aka L.Draw\r\n */\r\nL.Control.Draw = L.Control.extend({\r\n\r\n\t// Options\r\n\toptions: {\r\n\t\tposition: 'topleft',\r\n\t\tdraw: {},\r\n\t\tedit: false\r\n\t},\r\n\r\n\t// @method initialize(): void\r\n\t// Initializes draw control, toolbars from the options\r\n\tinitialize: function (options) {\r\n\t\tif (L.version < '0.7') {\r\n\t\t\tthrow new Error('Leaflet.draw 0.2.3+ requires Leaflet 0.7.0+. Download latest from https://github.com/Leaflet/Leaflet/');\r\n\t\t}\r\n\r\n\t\tL.Control.prototype.initialize.call(this, options);\r\n\r\n\t\tvar toolbar;\r\n\r\n\t\tthis._toolbars = {};\r\n\r\n\t\t// Initialize toolbars\r\n\t\tif (L.DrawToolbar && this.options.draw) {\r\n\t\t\ttoolbar = new L.DrawToolbar(this.options.draw);\r\n\r\n\t\t\tthis._toolbars[L.DrawToolbar.TYPE] = toolbar;\r\n\r\n\t\t\t// Listen for when toolbar is enabled\r\n\t\t\tthis._toolbars[L.DrawToolbar.TYPE].on('enable', this._toolbarEnabled, this);\r\n\t\t}\r\n\r\n\t\tif (L.EditToolbar && this.options.edit) {\r\n\t\t\ttoolbar = new L.EditToolbar(this.options.edit);\r\n\r\n\t\t\tthis._toolbars[L.EditToolbar.TYPE] = toolbar;\r\n\r\n\t\t\t// Listen for when toolbar is enabled\r\n\t\t\tthis._toolbars[L.EditToolbar.TYPE].on('enable', this._toolbarEnabled, this);\r\n\t\t}\r\n\t\tL.toolbar = this; //set global var for editing the toolbar\r\n\t},\r\n\r\n\t// @method onAdd(): container\r\n\t// Adds the toolbar container to the map\r\n\tonAdd: function (map) {\r\n\t\tvar container = L.DomUtil.create('div', 'leaflet-draw'),\r\n\t\t\taddedTopClass = false,\r\n\t\t\ttopClassName = 'leaflet-draw-toolbar-top',\r\n\t\t\ttoolbarContainer;\r\n\r\n\t\tfor (var toolbarId in this._toolbars) {\r\n\t\t\tif (this._toolbars.hasOwnProperty(toolbarId)) {\r\n\t\t\t\ttoolbarContainer = this._toolbars[toolbarId].addToolbar(map);\r\n\r\n\t\t\t\tif (toolbarContainer) {\r\n\t\t\t\t\t// Add class to the first toolbar to remove the margin\r\n\t\t\t\t\tif (!addedTopClass) {\r\n\t\t\t\t\t\tif (!L.DomUtil.hasClass(toolbarContainer, topClassName)) {\r\n\t\t\t\t\t\t\tL.DomUtil.addClass(toolbarContainer.childNodes[0], topClassName);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\taddedTopClass = true;\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tcontainer.appendChild(toolbarContainer);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn container;\r\n\t},\r\n\r\n\t// @method onRemove(): void\r\n\t// Removes the toolbars from the map toolbar container\r\n\tonRemove: function () {\r\n\t\tfor (var toolbarId in this._toolbars) {\r\n\t\t\tif (this._toolbars.hasOwnProperty(toolbarId)) {\r\n\t\t\t\tthis._toolbars[toolbarId].removeToolbar();\r\n\t\t\t}\r\n\t\t}\r\n\t},\r\n\r\n\t// @method setDrawingOptions(options): void\r\n\t// Sets options to all toolbar instances\r\n\tsetDrawingOptions: function (options) {\r\n\t\tfor (var toolbarId in this._toolbars) {\r\n\t\t\tif (this._toolbars[toolbarId] instanceof L.DrawToolbar) {\r\n\t\t\t\tthis._toolbars[toolbarId].setOptions(options);\r\n\t\t\t}\r\n\t\t}\r\n\t},\r\n\r\n\t_toolbarEnabled: function (e) {\r\n\t\tvar enabledToolbar = e.target;\r\n\r\n\t\tfor (var toolbarId in this._toolbars) {\r\n\t\t\tif (this._toolbars[toolbarId] !== enabledToolbar) {\r\n\t\t\t\tthis._toolbars[toolbarId].disable();\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n});\r\n\r\nL.Map.mergeOptions({\r\n\tdrawControlTooltips: true,\r\n\tdrawControl: false\r\n});\r\n\r\nL.Map.addInitHook(function () {\r\n\tif (this.options.drawControl) {\r\n\t\tthis.drawControl = new L.Control.Draw();\r\n\t\tthis.addControl(this.drawControl);\r\n\t}\r\n});\r\n","/**\r\n * @class L.Draw.Toolbar\r\n * @aka Toolbar\r\n *\r\n * The toolbar class of the API — it is used to create the ui\r\n * This will be depreciated\r\n *\r\n * @example\r\n *\r\n * ```js\r\n * var toolbar = L.Toolbar();\r\n * toolbar.addToolbar(map);\r\n * ```\r\n *\r\n * ### Disabling a toolbar\r\n *\r\n * If you do not want a particular toolbar in your app you can turn it off by setting the toolbar to false.\r\n *\r\n * ```js\r\n * var drawControl = new L.Control.Draw({\r\n * draw: false,\r\n * edit: {\r\n * featureGroup: editableLayers\r\n * }\r\n * });\r\n * ```\r\n *\r\n * ### Disabling a toolbar item\r\n *\r\n * If you want to turn off a particular toolbar item, set it to false. The following disables drawing polygons and\r\n * markers. It also turns off the ability to edit layers.\r\n *\r\n * ```js\r\n * var drawControl = new L.Control.Draw({\r\n * draw: {\r\n * polygon: false,\r\n * marker: false\r\n * },\r\n * edit: {\r\n * featureGroup: editableLayers,\r\n * edit: false\r\n * }\r\n * });\r\n * ```\r\n */\r\nL.Toolbar = L.Class.extend({\r\n\t// @section Methods for modifying the toolbar\r\n\r\n\t// @method initialize(options): void\r\n\t// Toolbar constructor\r\n\tinitialize: function (options) {\r\n\t\tL.setOptions(this, options);\r\n\r\n\t\tthis._modes = {};\r\n\t\tthis._actionButtons = [];\r\n\t\tthis._activeMode = null;\r\n\r\n\t\tvar version = L.version.split('.');\r\n\t\t//If Version is >= 1.2.0\r\n\t\tif (parseInt(version[0], 10) === 1 && parseInt(version[1], 10) >= 2) {\r\n\t\t\tL.Toolbar.include(L.Evented.prototype);\r\n\t\t} else {\r\n\t\t\tL.Toolbar.include(L.Mixin.Events);\r\n\t\t}\r\n\t},\r\n\r\n\t// @method enabled(): boolean\r\n\t// Gets a true/false of whether the toolbar is enabled\r\n\tenabled: function () {\r\n\t\treturn this._activeMode !== null;\r\n\t},\r\n\r\n\t// @method disable(): void\r\n\t// Disables the toolbar\r\n\tdisable: function () {\r\n\t\tif (!this.enabled()) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tthis._activeMode.handler.disable();\r\n\t},\r\n\r\n\t// @method addToolbar(map): L.DomUtil\r\n\t// Adds the toolbar to the map and returns the toolbar dom element\r\n\taddToolbar: function (map) {\r\n\t\tvar container = L.DomUtil.create('div', 'leaflet-draw-section'),\r\n\t\t\tbuttonIndex = 0,\r\n\t\t\tbuttonClassPrefix = this._toolbarClass || '',\r\n\t\t\tmodeHandlers = this.getModeHandlers(map),\r\n\t\t\ti;\r\n\r\n\t\tthis._toolbarContainer = L.DomUtil.create('div', 'leaflet-draw-toolbar leaflet-bar');\r\n\t\tthis._map = map;\r\n\r\n\t\tfor (i = 0; i < modeHandlers.length; i++) {\r\n\t\t\tif (modeHandlers[i].enabled) {\r\n\t\t\t\tthis._initModeHandler(\r\n\t\t\t\t\tmodeHandlers[i].handler,\r\n\t\t\t\t\tthis._toolbarContainer,\r\n\t\t\t\t\tbuttonIndex++,\r\n\t\t\t\t\tbuttonClassPrefix,\r\n\t\t\t\t\tmodeHandlers[i].title\r\n\t\t\t\t);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// if no buttons were added, do not add the toolbar\r\n\t\tif (!buttonIndex) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\t// Save button index of the last button, -1 as we would have ++ after the last button\r\n\t\tthis._lastButtonIndex = --buttonIndex;\r\n\r\n\t\t// Create empty actions part of the toolbar\r\n\t\tthis._actionsContainer = L.DomUtil.create('ul', 'leaflet-draw-actions');\r\n\r\n\t\t// Add draw and cancel containers to the control container\r\n\t\tcontainer.appendChild(this._toolbarContainer);\r\n\t\tcontainer.appendChild(this._actionsContainer);\r\n\r\n\t\treturn container;\r\n\t},\r\n\r\n\t// @method removeToolbar(): void\r\n\t// Removes the toolbar and drops the handler event listeners\r\n\tremoveToolbar: function () {\r\n\t\t// Dispose each handler\r\n\t\tfor (var handlerId in this._modes) {\r\n\t\t\tif (this._modes.hasOwnProperty(handlerId)) {\r\n\t\t\t\t// Unbind handler button\r\n\t\t\t\tthis._disposeButton(\r\n\t\t\t\t\tthis._modes[handlerId].button,\r\n\t\t\t\t\tthis._modes[handlerId].handler.enable,\r\n\t\t\t\t\tthis._modes[handlerId].handler\r\n\t\t\t\t);\r\n\r\n\t\t\t\t// Make sure is disabled\r\n\t\t\t\tthis._modes[handlerId].handler.disable();\r\n\r\n\t\t\t\t// Unbind handler\r\n\t\t\t\tthis._modes[handlerId].handler\r\n\t\t\t\t\t.off('enabled', this._handlerActivated, this)\r\n\t\t\t\t\t.off('disabled', this._handlerDeactivated, this);\r\n\t\t\t}\r\n\t\t}\r\n\t\tthis._modes = {};\r\n\r\n\t\t// Dispose the actions toolbar\r\n\t\tfor (var i = 0, l = this._actionButtons.length; i < l; i++) {\r\n\t\t\tthis._disposeButton(\r\n\t\t\t\tthis._actionButtons[i].button,\r\n\t\t\t\tthis._actionButtons[i].callback,\r\n\t\t\t\tthis\r\n\t\t\t);\r\n\t\t}\r\n\t\tthis._actionButtons = [];\r\n\t\tthis._actionsContainer = null;\r\n\t},\r\n\r\n\t_initModeHandler: function (handler, container, buttonIndex, classNamePredix, buttonTitle) {\r\n\t\tvar type = handler.type;\r\n\r\n\t\tthis._modes[type] = {};\r\n\r\n\t\tthis._modes[type].handler = handler;\r\n\r\n\t\tthis._modes[type].button = this._createButton({\r\n\t\t\ttype: type,\r\n\t\t\ttitle: buttonTitle,\r\n\t\t\tclassName: classNamePredix + '-' + type,\r\n\t\t\tcontainer: container,\r\n\t\t\tcallback: this._modes[type].handler.enable,\r\n\t\t\tcontext: this._modes[type].handler\r\n\t\t});\r\n\r\n\t\tthis._modes[type].buttonIndex = buttonIndex;\r\n\r\n\t\tthis._modes[type].handler\r\n\t\t\t.on('enabled', this._handlerActivated, this)\r\n\t\t\t.on('disabled', this._handlerDeactivated, this);\r\n\t},\r\n\r\n\t/* Detect iOS based on browser User Agent, based on:\r\n\t * http://stackoverflow.com/a/9039885 */\r\n\t_detectIOS: function () {\r\n\t\tvar iOS = (/iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream);\r\n\t\treturn iOS;\r\n\t},\r\n\r\n\t_createButton: function (options) {\r\n\r\n\t\tvar link = L.DomUtil.create('a', options.className || '', options.container);\r\n\t\t// Screen reader tag\r\n\t\tvar sr = L.DomUtil.create('span', 'sr-only', options.container);\r\n\r\n\t\tlink.href = '#';\r\n\t\tlink.appendChild(sr);\r\n\r\n\t\tif (options.title) {\r\n\t\t\tlink.title = options.title;\r\n\t\t\tsr.innerHTML = options.title;\r\n\t\t}\r\n\r\n\t\tif (options.text) {\r\n\t\t\tlink.innerHTML = options.text;\r\n\t\t\tsr.innerHTML = options.text;\r\n\t\t}\r\n\r\n\t\t/* iOS does not use click events */\r\n\t\tvar buttonEvent = this._detectIOS() ? 'touchstart' : 'click';\r\n\r\n\t\tL.DomEvent\r\n\t\t\t.on(link, 'click', L.DomEvent.stopPropagation)\r\n\t\t\t.on(link, 'mousedown', L.DomEvent.stopPropagation)\r\n\t\t\t.on(link, 'dblclick', L.DomEvent.stopPropagation)\r\n\t\t\t.on(link, 'touchstart', L.DomEvent.stopPropagation)\r\n\t\t\t.on(link, 'click', L.DomEvent.preventDefault)\r\n\t\t\t.on(link, buttonEvent, options.callback, options.context);\r\n\r\n\t\treturn link;\r\n\t},\r\n\r\n\t_disposeButton: function (button, callback) {\r\n\t\t/* iOS does not use click events */\r\n\t\tvar buttonEvent = this._detectIOS() ? 'touchstart' : 'click';\r\n\r\n\t\tL.DomEvent\r\n\t\t\t.off(button, 'click', L.DomEvent.stopPropagation)\r\n\t\t\t.off(button, 'mousedown', L.DomEvent.stopPropagation)\r\n\t\t\t.off(button, 'dblclick', L.DomEvent.stopPropagation)\r\n\t\t\t.off(button, 'touchstart', L.DomEvent.stopPropagation)\r\n\t\t\t.off(button, 'click', L.DomEvent.preventDefault)\r\n\t\t\t.off(button, buttonEvent, callback);\r\n\t},\r\n\r\n\t_handlerActivated: function (e) {\r\n\t\t// Disable active mode (if present)\r\n\t\tthis.disable();\r\n\r\n\t\t// Cache new active feature\r\n\t\tthis._activeMode = this._modes[e.handler];\r\n\r\n\t\tL.DomUtil.addClass(this._activeMode.button, 'leaflet-draw-toolbar-button-enabled');\r\n\r\n\t\tthis._showActionsToolbar();\r\n\r\n\t\tthis.fire('enable');\r\n\t},\r\n\r\n\t_handlerDeactivated: function () {\r\n\t\tthis._hideActionsToolbar();\r\n\r\n\t\tL.DomUtil.removeClass(this._activeMode.button, 'leaflet-draw-toolbar-button-enabled');\r\n\r\n\t\tthis._activeMode = null;\r\n\r\n\t\tthis.fire('disable');\r\n\t},\r\n\r\n\t_createActions: function (handler) {\r\n\t\tvar container = this._actionsContainer,\r\n\t\t\tbuttons = this.getActions(handler),\r\n\t\t\tl = buttons.length,\r\n\t\t\tli, di, dl, button;\r\n\r\n\t\t// Dispose the actions toolbar (todo: dispose only not used buttons)\r\n\t\tfor (di = 0, dl = this._actionButtons.length; di < dl; di++) {\r\n\t\t\tthis._disposeButton(this._actionButtons[di].button, this._actionButtons[di].callback);\r\n\t\t}\r\n\t\tthis._actionButtons = [];\r\n\r\n\t\t// Remove all old buttons\r\n\t\twhile (container.firstChild) {\r\n\t\t\tcontainer.removeChild(container.firstChild);\r\n\t\t}\r\n\r\n\t\tfor (var i = 0; i < l; i++) {\r\n\t\t\tif ('enabled' in buttons[i] && !buttons[i].enabled) {\r\n\t\t\t\tcontinue;\r\n\t\t\t}\r\n\r\n\t\t\tli = L.DomUtil.create('li', '', container);\r\n\r\n\t\t\tbutton = this._createButton({\r\n\t\t\t\ttitle: buttons[i].title,\r\n\t\t\t\ttext: buttons[i].text,\r\n\t\t\t\tcontainer: li,\r\n\t\t\t\tcallback: buttons[i].callback,\r\n\t\t\t\tcontext: buttons[i].context\r\n\t\t\t});\r\n\r\n\t\t\tthis._actionButtons.push({\r\n\t\t\t\tbutton: button,\r\n\t\t\t\tcallback: buttons[i].callback\r\n\t\t\t});\r\n\t\t}\r\n\t},\r\n\r\n\t_showActionsToolbar: function () {\r\n\t\tvar buttonIndex = this._activeMode.buttonIndex,\r\n\t\t\tlastButtonIndex = this._lastButtonIndex,\r\n\t\t\ttoolbarPosition = this._activeMode.button.offsetTop - 1;\r\n\r\n\t\t// Recreate action buttons on every click\r\n\t\tthis._createActions(this._activeMode.handler);\r\n\r\n\t\t// Correctly position the cancel button\r\n\t\tthis._actionsContainer.style.top = toolbarPosition + 'px';\r\n\r\n\t\tif (buttonIndex === 0) {\r\n\t\t\tL.DomUtil.addClass(this._toolbarContainer, 'leaflet-draw-toolbar-notop');\r\n\t\t\tL.DomUtil.addClass(this._actionsContainer, 'leaflet-draw-actions-top');\r\n\t\t}\r\n\r\n\t\tif (buttonIndex === lastButtonIndex) {\r\n\t\t\tL.DomUtil.addClass(this._toolbarContainer, 'leaflet-draw-toolbar-nobottom');\r\n\t\t\tL.DomUtil.addClass(this._actionsContainer, 'leaflet-draw-actions-bottom');\r\n\t\t}\r\n\r\n\t\tthis._actionsContainer.style.display = 'block';\r\n\t\tthis._map.fire(L.Draw.Event.TOOLBAROPENED);\r\n\t},\r\n\r\n\t_hideActionsToolbar: function () {\r\n\t\tthis._actionsContainer.style.display = 'none';\r\n\r\n\t\tL.DomUtil.removeClass(this._toolbarContainer, 'leaflet-draw-toolbar-notop');\r\n\t\tL.DomUtil.removeClass(this._toolbarContainer, 'leaflet-draw-toolbar-nobottom');\r\n\t\tL.DomUtil.removeClass(this._actionsContainer, 'leaflet-draw-actions-top');\r\n\t\tL.DomUtil.removeClass(this._actionsContainer, 'leaflet-draw-actions-bottom');\r\n\t\tthis._map.fire(L.Draw.Event.TOOLBARCLOSED);\r\n\t}\r\n});\r\n","L.Draw = L.Draw || {};\r\n/**\r\n * @class L.Draw.Tooltip\r\n * @aka Tooltip\r\n *\r\n * The tooltip class — it is used to display the tooltip while drawing\r\n * This will be depreciated\r\n *\r\n * @example\r\n *\r\n * ```js\r\n * var tooltip = L.Draw.Tooltip();\r\n * ```\r\n *\r\n */\r\nL.Draw.Tooltip = L.Class.extend({\r\n\r\n\t// @section Methods for modifying draw state\r\n\r\n\t// @method initialize(map): void\r\n\t// Tooltip constructor\r\n\tinitialize: function (map) {\r\n\t\tthis._map = map;\r\n\t\tthis._popupPane = map._panes.popupPane;\r\n\t\tthis._visible = false;\r\n\r\n\t\tthis._container = map.options.drawControlTooltips ?\r\n\t\t\tL.DomUtil.create('div', 'leaflet-draw-tooltip', this._popupPane) : null;\r\n\t\tthis._singleLineLabel = false;\r\n\r\n\t\tthis._map.on('mouseout', this._onMouseOut, this);\r\n\t},\r\n\r\n\t// @method dispose(): void\r\n\t// Remove Tooltip DOM and unbind events\r\n\tdispose: function () {\r\n\t\tthis._map.off('mouseout', this._onMouseOut, this);\r\n\r\n\t\tif (this._container) {\r\n\t\t\tthis._popupPane.removeChild(this._container);\r\n\t\t\tthis._container = null;\r\n\t\t}\r\n\t},\r\n\r\n\t// @method updateContent(labelText): this\r\n\t// Changes the tooltip text to string in function call\r\n\tupdateContent: function (labelText) {\r\n\t\tif (!this._container) {\r\n\t\t\treturn this;\r\n\t\t}\r\n\t\tlabelText.subtext = labelText.subtext || '';\r\n\r\n\t\t// update the vertical position (only if changed)\r\n\t\tif (labelText.subtext.length === 0 && !this._singleLineLabel) {\r\n\t\t\tL.DomUtil.addClass(this._container, 'leaflet-draw-tooltip-single');\r\n\t\t\tthis._singleLineLabel = true;\r\n\t\t}\r\n\t\telse if (labelText.subtext.length > 0 && this._singleLineLabel) {\r\n\t\t\tL.DomUtil.removeClass(this._container, 'leaflet-draw-tooltip-single');\r\n\t\t\tthis._singleLineLabel = false;\r\n\t\t}\r\n\r\n\t\tthis._container.innerHTML =\r\n\t\t\t(labelText.subtext.length > 0 ?\r\n\t\t\t\t'' + labelText.subtext + '' + '
' : '') +\r\n\t\t\t'' + labelText.text + '';\r\n\r\n\t\tif (!labelText.text && !labelText.subtext) {\r\n\t\t\tthis._visible = false;\r\n\t\t\tthis._container.style.visibility = 'hidden';\r\n\t\t} else {\r\n\t\t\tthis._visible = true;\r\n\t\t\tthis._container.style.visibility = 'inherit';\r\n\t\t}\r\n\r\n\t\treturn this;\r\n\t},\r\n\r\n\t// @method updatePosition(latlng): this\r\n\t// Changes the location of the tooltip\r\n\tupdatePosition: function (latlng) {\r\n\t\tvar pos = this._map.latLngToLayerPoint(latlng),\r\n\t\t\ttooltipContainer = this._container;\r\n\r\n\t\tif (this._container) {\r\n\t\t\tif (this._visible) {\r\n\t\t\t\ttooltipContainer.style.visibility = 'inherit';\r\n\t\t\t}\r\n\t\t\tL.DomUtil.setPosition(tooltipContainer, pos);\r\n\t\t}\r\n\r\n\t\treturn this;\r\n\t},\r\n\r\n\t// @method showAsError(): this\r\n\t// Applies error class to tooltip\r\n\tshowAsError: function () {\r\n\t\tif (this._container) {\r\n\t\t\tL.DomUtil.addClass(this._container, 'leaflet-error-draw-tooltip');\r\n\t\t}\r\n\t\treturn this;\r\n\t},\r\n\r\n\t// @method removeError(): this\r\n\t// Removes the error class from the tooltip\r\n\tremoveError: function () {\r\n\t\tif (this._container) {\r\n\t\t\tL.DomUtil.removeClass(this._container, 'leaflet-error-draw-tooltip');\r\n\t\t}\r\n\t\treturn this;\r\n\t},\r\n\r\n\t_onMouseOut: function () {\r\n\t\tif (this._container) {\r\n\t\t\tthis._container.style.visibility = 'hidden';\r\n\t\t}\r\n\t}\r\n});\r\n","/**\r\n * @class L.DrawToolbar\r\n * @aka Toolbar\r\n */\r\nL.DrawToolbar = L.Toolbar.extend({\r\n\r\n\tstatics: {\r\n\t\tTYPE: 'draw'\r\n\t},\r\n\r\n\toptions: {\r\n\t\tpolyline: {},\r\n\t\tpolygon: {},\r\n\t\trectangle: {},\r\n\t\tcircle: {},\r\n\t\tmarker: {},\r\n\t\tcirclemarker: {}\r\n\t},\r\n\r\n\t// @method initialize(): void\r\n\tinitialize: function (options) {\r\n\t\t// Ensure that the options are merged correctly since L.extend is only shallow\r\n\t\tfor (var type in this.options) {\r\n\t\t\tif (this.options.hasOwnProperty(type)) {\r\n\t\t\t\tif (options[type]) {\r\n\t\t\t\t\toptions[type] = L.extend({}, this.options[type], options[type]);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tthis._toolbarClass = 'leaflet-draw-draw';\r\n\t\tL.Toolbar.prototype.initialize.call(this, options);\r\n\t},\r\n\r\n\t// @method getModeHandlers(): object\r\n\t// Get mode handlers information\r\n\tgetModeHandlers: function (map) {\r\n\t\treturn [\r\n\t\t\t{\r\n\t\t\t\tenabled: this.options.polyline,\r\n\t\t\t\thandler: new L.Draw.Polyline(map, this.options.polyline),\r\n\t\t\t\ttitle: L.drawLocal.draw.toolbar.buttons.polyline\r\n\t\t\t},\r\n\t\t\t{\r\n\t\t\t\tenabled: this.options.polygon,\r\n\t\t\t\thandler: new L.Draw.Polygon(map, this.options.polygon),\r\n\t\t\t\ttitle: L.drawLocal.draw.toolbar.buttons.polygon\r\n\t\t\t},\r\n\t\t\t{\r\n\t\t\t\tenabled: this.options.rectangle,\r\n\t\t\t\thandler: new L.Draw.Rectangle(map, this.options.rectangle),\r\n\t\t\t\ttitle: L.drawLocal.draw.toolbar.buttons.rectangle\r\n\t\t\t},\r\n\t\t\t{\r\n\t\t\t\tenabled: this.options.circle,\r\n\t\t\t\thandler: new L.Draw.Circle(map, this.options.circle),\r\n\t\t\t\ttitle: L.drawLocal.draw.toolbar.buttons.circle\r\n\t\t\t},\r\n\t\t\t{\r\n\t\t\t\tenabled: this.options.marker,\r\n\t\t\t\thandler: new L.Draw.Marker(map, this.options.marker),\r\n\t\t\t\ttitle: L.drawLocal.draw.toolbar.buttons.marker\r\n\t\t\t},\r\n\t\t\t{\r\n\t\t\t\tenabled: this.options.circlemarker,\r\n\t\t\t\thandler: new L.Draw.CircleMarker(map, this.options.circlemarker),\r\n\t\t\t\ttitle: L.drawLocal.draw.toolbar.buttons.circlemarker\r\n\t\t\t}\r\n\t\t];\r\n\t},\r\n\r\n\t// @method getActions(): object\r\n\t// Get action information\r\n\tgetActions: function (handler) {\r\n\t\treturn [\r\n\t\t\t{\r\n\t\t\t\tenabled: handler.completeShape,\r\n\t\t\t\ttitle: L.drawLocal.draw.toolbar.finish.title,\r\n\t\t\t\ttext: L.drawLocal.draw.toolbar.finish.text,\r\n\t\t\t\tcallback: handler.completeShape,\r\n\t\t\t\tcontext: handler\r\n\t\t\t},\r\n\t\t\t{\r\n\t\t\t\tenabled: handler.deleteLastVertex,\r\n\t\t\t\ttitle: L.drawLocal.draw.toolbar.undo.title,\r\n\t\t\t\ttext: L.drawLocal.draw.toolbar.undo.text,\r\n\t\t\t\tcallback: handler.deleteLastVertex,\r\n\t\t\t\tcontext: handler\r\n\t\t\t},\r\n\t\t\t{\r\n\t\t\t\ttitle: L.drawLocal.draw.toolbar.actions.title,\r\n\t\t\t\ttext: L.drawLocal.draw.toolbar.actions.text,\r\n\t\t\t\tcallback: this.disable,\r\n\t\t\t\tcontext: this\r\n\t\t\t}\r\n\t\t];\r\n\t},\r\n\r\n\t// @method setOptions(): void\r\n\t// Sets the options to the toolbar\r\n\tsetOptions: function (options) {\r\n\t\tL.setOptions(this, options);\r\n\r\n\t\tfor (var type in this._modes) {\r\n\t\t\tif (this._modes.hasOwnProperty(type) && options.hasOwnProperty(type)) {\r\n\t\t\t\tthis._modes[type].handler.setOptions(options[type]);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n});\r\n","/*L.Map.mergeOptions({\r\n editControl: true\r\n });*/\r\n/**\r\n * @class L.EditToolbar\r\n * @aka EditToolbar\r\n */\r\nL.EditToolbar = L.Toolbar.extend({\r\n\tstatics: {\r\n\t\tTYPE: 'edit'\r\n\t},\r\n\r\n\toptions: {\r\n\t\tedit: {\r\n\t\t\tselectedPathOptions: {\r\n\t\t\t\tdashArray: '10, 10',\r\n\r\n\t\t\t\tfill: true,\r\n\t\t\t\tfillColor: '#fe57a1',\r\n\t\t\t\tfillOpacity: 0.1,\r\n\r\n\t\t\t\t// Whether to user the existing layers color\r\n\t\t\t\tmaintainColor: false\r\n\t\t\t}\r\n\t\t},\r\n\t\tremove: {},\r\n\t\tpoly: null,\r\n\t\tfeatureGroup: null /* REQUIRED! TODO: perhaps if not set then all layers on the map are selectable? */\r\n\t},\r\n\r\n\t// @method intialize(): void\r\n\tinitialize: function (options) {\r\n\t\t// Need to set this manually since null is an acceptable value here\r\n\t\tif (options.edit) {\r\n\t\t\tif (typeof options.edit.selectedPathOptions === 'undefined') {\r\n\t\t\t\toptions.edit.selectedPathOptions = this.options.edit.selectedPathOptions;\r\n\t\t\t}\r\n\t\t\toptions.edit.selectedPathOptions = L.extend({}, this.options.edit.selectedPathOptions, options.edit.selectedPathOptions);\r\n\t\t}\r\n\r\n\t\tif (options.remove) {\r\n\t\t\toptions.remove = L.extend({}, this.options.remove, options.remove);\r\n\t\t}\r\n\r\n\t\tif (options.poly) {\r\n\t\t\toptions.poly = L.extend({}, this.options.poly, options.poly);\r\n\t\t}\r\n\r\n\t\tthis._toolbarClass = 'leaflet-draw-edit';\r\n\t\tL.Toolbar.prototype.initialize.call(this, options);\r\n\r\n\t\tthis._selectedFeatureCount = 0;\r\n\t},\r\n\r\n\t// @method getModeHandlers(): object\r\n\t// Get mode handlers information\r\n\tgetModeHandlers: function (map) {\r\n\t\tvar featureGroup = this.options.featureGroup;\r\n\t\treturn [\r\n\t\t\t{\r\n\t\t\t\tenabled: this.options.edit,\r\n\t\t\t\thandler: new L.EditToolbar.Edit(map, {\r\n\t\t\t\t\tfeatureGroup: featureGroup,\r\n\t\t\t\t\tselectedPathOptions: this.options.edit.selectedPathOptions,\r\n\t\t\t\t\tpoly: this.options.poly\r\n\t\t\t\t}),\r\n\t\t\t\ttitle: L.drawLocal.edit.toolbar.buttons.edit\r\n\t\t\t},\r\n\t\t\t{\r\n\t\t\t\tenabled: this.options.remove,\r\n\t\t\t\thandler: new L.EditToolbar.Delete(map, {\r\n\t\t\t\t\tfeatureGroup: featureGroup\r\n\t\t\t\t}),\r\n\t\t\t\ttitle: L.drawLocal.edit.toolbar.buttons.remove\r\n\t\t\t}\r\n\t\t];\r\n\t},\r\n\r\n\t// @method getActions(): object\r\n\t// Get actions information\r\n\tgetActions: function (handler) {\r\n\t\tvar actions = [\r\n\t\t\t{\r\n\t\t\t\ttitle: L.drawLocal.edit.toolbar.actions.save.title,\r\n\t\t\t\ttext: L.drawLocal.edit.toolbar.actions.save.text,\r\n\t\t\t\tcallback: this._save,\r\n\t\t\t\tcontext: this\r\n\t\t\t},\r\n\t\t\t{\r\n\t\t\t\ttitle: L.drawLocal.edit.toolbar.actions.cancel.title,\r\n\t\t\t\ttext: L.drawLocal.edit.toolbar.actions.cancel.text,\r\n\t\t\t\tcallback: this.disable,\r\n\t\t\t\tcontext: this\r\n\t\t\t}\r\n\t\t];\r\n\r\n\t\tif (handler.removeAllLayers) {\r\n\t\t\tactions.push({\r\n\t\t\t\ttitle: L.drawLocal.edit.toolbar.actions.clearAll.title,\r\n\t\t\t\ttext: L.drawLocal.edit.toolbar.actions.clearAll.text,\r\n\t\t\t\tcallback: this._clearAllLayers,\r\n\t\t\t\tcontext: this\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\treturn actions;\r\n\t},\r\n\r\n\t// @method addToolbar(map): L.DomUtil\r\n\t// Adds the toolbar to the map\r\n\taddToolbar: function (map) {\r\n\t\tvar container = L.Toolbar.prototype.addToolbar.call(this, map);\r\n\r\n\t\tthis._checkDisabled();\r\n\r\n\t\tthis.options.featureGroup.on('layeradd layerremove', this._checkDisabled, this);\r\n\r\n\t\treturn container;\r\n\t},\r\n\r\n\t// @method removeToolbar(): void\r\n\t// Removes the toolbar from the map\r\n\tremoveToolbar: function () {\r\n\t\tthis.options.featureGroup.off('layeradd layerremove', this._checkDisabled, this);\r\n\r\n\t\tL.Toolbar.prototype.removeToolbar.call(this);\r\n\t},\r\n\r\n\t// @method disable(): void\r\n\t// Disables the toolbar\r\n\tdisable: function () {\r\n\t\tif (!this.enabled()) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tthis._activeMode.handler.revertLayers();\r\n\r\n\t\tL.Toolbar.prototype.disable.call(this);\r\n\t},\r\n\r\n\t_save: function () {\r\n\t\tthis._activeMode.handler.save();\r\n\t\tif (this._activeMode) {\r\n\t\t\tthis._activeMode.handler.disable();\r\n\t\t}\r\n\t},\r\n\r\n\t_clearAllLayers: function () {\r\n\t\tthis._activeMode.handler.removeAllLayers();\r\n\t\tif (this._activeMode) {\r\n\t\t\tthis._activeMode.handler.disable();\r\n\t\t}\r\n\t},\r\n\r\n\t_checkDisabled: function () {\r\n\t\tvar featureGroup = this.options.featureGroup,\r\n\t\t\thasLayers = featureGroup.getLayers().length !== 0,\r\n\t\t\tbutton;\r\n\r\n\t\tif (this.options.edit) {\r\n\t\t\tbutton = this._modes[L.EditToolbar.Edit.TYPE].button;\r\n\r\n\t\t\tif (hasLayers) {\r\n\t\t\t\tL.DomUtil.removeClass(button, 'leaflet-disabled');\r\n\t\t\t} else {\r\n\t\t\t\tL.DomUtil.addClass(button, 'leaflet-disabled');\r\n\t\t\t}\r\n\r\n\t\t\tbutton.setAttribute(\r\n\t\t\t\t'title',\r\n\t\t\t\thasLayers ?\r\n\t\t\t\t\tL.drawLocal.edit.toolbar.buttons.edit\r\n\t\t\t\t\t: L.drawLocal.edit.toolbar.buttons.editDisabled\r\n\t\t\t);\r\n\t\t}\r\n\r\n\t\tif (this.options.remove) {\r\n\t\t\tbutton = this._modes[L.EditToolbar.Delete.TYPE].button;\r\n\r\n\t\t\tif (hasLayers) {\r\n\t\t\t\tL.DomUtil.removeClass(button, 'leaflet-disabled');\r\n\t\t\t} else {\r\n\t\t\t\tL.DomUtil.addClass(button, 'leaflet-disabled');\r\n\t\t\t}\r\n\r\n\t\t\tbutton.setAttribute(\r\n\t\t\t\t'title',\r\n\t\t\t\thasLayers ?\r\n\t\t\t\t\tL.drawLocal.edit.toolbar.buttons.remove\r\n\t\t\t\t\t: L.drawLocal.edit.toolbar.buttons.removeDisabled\r\n\t\t\t);\r\n\t\t}\r\n\t}\r\n});\r\n","/**\r\n * @class L.EditToolbar.Edit\r\n * @aka EditToolbar.Edit\r\n */\r\nL.EditToolbar.Edit = L.Handler.extend({\r\n\tstatics: {\r\n\t\tTYPE: 'edit'\r\n\t},\r\n\r\n\t// @method intialize(): void\r\n\tinitialize: function (map, options) {\r\n\t\tL.Handler.prototype.initialize.call(this, map);\r\n\r\n\t\tL.setOptions(this, options);\r\n\r\n\t\t// Store the selectable layer group for ease of access\r\n\t\tthis._featureGroup = options.featureGroup;\r\n\r\n\t\tif (!(this._featureGroup instanceof L.FeatureGroup)) {\r\n\t\t\tthrow new Error('options.featureGroup must be a L.FeatureGroup');\r\n\t\t}\r\n\r\n\t\tthis._uneditedLayerProps = {};\r\n\r\n\t\t// Save the type so super can fire, need to do this as cannot do this.TYPE :(\r\n\t\tthis.type = L.EditToolbar.Edit.TYPE;\r\n\r\n\t\tvar version = L.version.split('.');\r\n\t\t//If Version is >= 1.2.0\r\n\t\tif (parseInt(version[0], 10) === 1 && parseInt(version[1], 10) >= 2) {\r\n\t\t\tL.EditToolbar.Edit.include(L.Evented.prototype);\r\n\t\t} else {\r\n\t\t\tL.EditToolbar.Edit.include(L.Mixin.Events);\r\n\t\t}\r\n\t},\r\n\r\n\t// @method enable(): void\r\n\t// Enable the edit toolbar\r\n\tenable: function () {\r\n\t\tif (this._enabled || !this._hasAvailableLayers()) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tthis.fire('enabled', {handler: this.type});\r\n\t\t//this disable other handlers\r\n\r\n\t\tthis._map.fire(L.Draw.Event.EDITSTART, {handler: this.type});\r\n\t\t//allow drawLayer to be updated before beginning edition.\r\n\r\n\t\tL.Handler.prototype.enable.call(this);\r\n\t\tthis._featureGroup\r\n\t\t\t.on('layeradd', this._enableLayerEdit, this)\r\n\t\t\t.on('layerremove', this._disableLayerEdit, this);\r\n\t},\r\n\r\n\t// @method disable(): void\r\n\t// Disable the edit toolbar\r\n\tdisable: function () {\r\n\t\tif (!this._enabled) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tthis._featureGroup\r\n\t\t\t.off('layeradd', this._enableLayerEdit, this)\r\n\t\t\t.off('layerremove', this._disableLayerEdit, this);\r\n\t\tL.Handler.prototype.disable.call(this);\r\n\t\tthis._map.fire(L.Draw.Event.EDITSTOP, {handler: this.type});\r\n\t\tthis.fire('disabled', {handler: this.type});\r\n\t},\r\n\r\n\t// @method addHooks(): void\r\n\t// Add listener hooks for this handler\r\n\taddHooks: function () {\r\n\t\tvar map = this._map;\r\n\r\n\t\tif (map) {\r\n\t\t\tmap.getContainer().focus();\r\n\r\n\t\t\tthis._featureGroup.eachLayer(this._enableLayerEdit, this);\r\n\r\n\t\t\tthis._tooltip = new L.Draw.Tooltip(this._map);\r\n\t\t\tthis._tooltip.updateContent({\r\n\t\t\t\ttext: L.drawLocal.edit.handlers.edit.tooltip.text,\r\n\t\t\t\tsubtext: L.drawLocal.edit.handlers.edit.tooltip.subtext\r\n\t\t\t});\r\n\r\n\t\t\t// Quickly access the tooltip to update for intersection checking\r\n\t\t\tmap._editTooltip = this._tooltip;\r\n\r\n\t\t\tthis._updateTooltip();\r\n\r\n\t\t\tthis._map\r\n\t\t\t\t.on('mousemove', this._onMouseMove, this)\r\n\t\t\t\t.on('touchmove', this._onMouseMove, this)\r\n\t\t\t\t.on('MSPointerMove', this._onMouseMove, this)\r\n\t\t\t\t.on(L.Draw.Event.EDITVERTEX, this._updateTooltip, this);\r\n\t\t}\r\n\t},\r\n\r\n\t// @method removeHooks(): void\r\n\t// Remove listener hooks for this handler\r\n\tremoveHooks: function () {\r\n\t\tif (this._map) {\r\n\t\t\t// Clean up selected layers.\r\n\t\t\tthis._featureGroup.eachLayer(this._disableLayerEdit, this);\r\n\t\t\tthis._map._editTooltip.dispose();\r\n\t\t\tthis._map._editTooltip = null;\r\n\t\t\t// Clear the backups of the original layers\r\n\t\t\tthis._uneditedLayerProps = {};\r\n\r\n\t\t\tthis._tooltip.dispose();\r\n\t\t\tthis._tooltip = null;\r\n\r\n\t\t\tthis._map\r\n\t\t\t\t.off('mousemove', this._onMouseMove, this)\r\n\t\t\t\t.off('touchmove', this._onMouseMove, this)\r\n\t\t\t\t.off('MSPointerMove', this._onMouseMove, this)\r\n\t\t\t\t.off(L.Draw.Event.EDITVERTEX, this._updateTooltip, this);\r\n\t\t}\r\n\t},\r\n\r\n\t// @method revertLayers(): void\r\n\t// Revert each layer's geometry changes\r\n\trevertLayers: function () {\r\n\t\tthis._featureGroup.eachLayer(function (layer) {\r\n\t\t\tthis._revertLayer(layer);\r\n\t\t}, this);\r\n\t},\r\n\r\n\t// @method save(): void\r\n\t// Save the layer geometries\r\n\tsave: function () {\r\n\t\tvar editedLayers = new L.LayerGroup();\r\n\t\tthis._featureGroup.eachLayer(function (layer) {\r\n\t\t\tif (layer.edited) {\r\n\t\t\t\teditedLayers.addLayer(layer);\r\n\t\t\t\tlayer.edited = false;\r\n\t\t\t}\r\n\t\t});\r\n\t\tthis._map.fire(L.Draw.Event.EDITED, {layers: editedLayers});\r\n\t},\r\n\r\n\t_backupLayer: function (layer) {\r\n\t\tvar id = L.Util.stamp(layer);\r\n\r\n\t\tif (!this._uneditedLayerProps[id]) {\r\n\t\t\t// Polyline, Polygon or Rectangle\r\n\t\t\tif (layer instanceof L.Polyline || layer instanceof L.Polygon || layer instanceof L.Rectangle) {\r\n\t\t\t\tthis._uneditedLayerProps[id] = {\r\n\t\t\t\t\tlatlngs: L.LatLngUtil.cloneLatLngs(layer.getLatLngs())\r\n\t\t\t\t};\r\n\t\t\t} else if (layer instanceof L.Circle) {\r\n\t\t\t\tthis._uneditedLayerProps[id] = {\r\n\t\t\t\t\tlatlng: L.LatLngUtil.cloneLatLng(layer.getLatLng()),\r\n\t\t\t\t\tradius: layer.getRadius()\r\n\t\t\t\t};\r\n\t\t\t} else if (layer instanceof L.Marker || layer instanceof L.CircleMarker) { // Marker\r\n\t\t\t\tthis._uneditedLayerProps[id] = {\r\n\t\t\t\t\tlatlng: L.LatLngUtil.cloneLatLng(layer.getLatLng())\r\n\t\t\t\t};\r\n\t\t\t}\r\n\t\t}\r\n\t},\r\n\r\n\t_getTooltipText: function () {\r\n\t\treturn ({\r\n\t\t\ttext: L.drawLocal.edit.handlers.edit.tooltip.text,\r\n\t\t\tsubtext: L.drawLocal.edit.handlers.edit.tooltip.subtext\r\n\t\t});\r\n\t},\r\n\r\n\t_updateTooltip: function () {\r\n\t\tthis._tooltip.updateContent(this._getTooltipText());\r\n\t},\r\n\r\n\t_revertLayer: function (layer) {\r\n\t\tvar id = L.Util.stamp(layer);\r\n\t\tlayer.edited = false;\r\n\t\tif (this._uneditedLayerProps.hasOwnProperty(id)) {\r\n\t\t\t// Polyline, Polygon or Rectangle\r\n\t\t\tif (layer instanceof L.Polyline || layer instanceof L.Polygon || layer instanceof L.Rectangle) {\r\n\t\t\t\tlayer.setLatLngs(this._uneditedLayerProps[id].latlngs);\r\n\t\t\t} else if (layer instanceof L.Circle) {\r\n\t\t\t\tlayer.setLatLng(this._uneditedLayerProps[id].latlng);\r\n\t\t\t\tlayer.setRadius(this._uneditedLayerProps[id].radius);\r\n\t\t\t} else if (layer instanceof L.Marker || layer instanceof L.CircleMarker) { // Marker or CircleMarker\r\n\t\t\t\tlayer.setLatLng(this._uneditedLayerProps[id].latlng);\r\n\t\t\t}\r\n\r\n\t\t\tlayer.fire('revert-edited', {layer: layer});\r\n\t\t}\r\n\t},\r\n\r\n\t_enableLayerEdit: function (e) {\r\n\t\tvar layer = e.layer || e.target || e,\r\n\t\t\tpathOptions, poly;\r\n\r\n\t\t// Back up this layer (if haven't before)\r\n\t\tthis._backupLayer(layer);\r\n\r\n\t\tif (this.options.poly) {\r\n\t\t\tpoly = L.Util.extend({}, this.options.poly);\r\n\t\t\tlayer.options.poly = poly;\r\n\t\t}\r\n\r\n\t\t// Set different style for editing mode\r\n\t\tif (this.options.selectedPathOptions) {\r\n\t\t\tpathOptions = L.Util.extend({}, this.options.selectedPathOptions);\r\n\r\n\t\t\t// Use the existing color of the layer\r\n\t\t\tif (pathOptions.maintainColor) {\r\n\t\t\t\tpathOptions.color = layer.options.color;\r\n\t\t\t\tpathOptions.fillColor = layer.options.fillColor;\r\n\t\t\t}\r\n\r\n\t\t\tlayer.options.original = L.extend({}, layer.options);\r\n\t\t\tlayer.options.editing = pathOptions;\r\n\r\n\t\t}\r\n\r\n\t\tif (layer instanceof L.Marker) {\r\n\t\t\tif (layer.editing) {\r\n\t\t\t\tlayer.editing.enable();\r\n\t\t\t}\r\n\t\t\tlayer.dragging.enable();\r\n\t\t\tlayer\r\n\t\t\t\t.on('dragend', this._onMarkerDragEnd)\r\n\t\t\t\t// #TODO: remove when leaflet finally fixes their draggable so it's touch friendly again.\r\n\t\t\t\t.on('touchmove', this._onTouchMove, this)\r\n\t\t\t\t.on('MSPointerMove', this._onTouchMove, this)\r\n\t\t\t\t.on('touchend', this._onMarkerDragEnd, this)\r\n\t\t\t\t.on('MSPointerUp', this._onMarkerDragEnd, this);\r\n\t\t} else {\r\n\t\t\tlayer.editing.enable();\r\n\t\t}\r\n\t},\r\n\r\n\t_disableLayerEdit: function (e) {\r\n\t\tvar layer = e.layer || e.target || e;\r\n\r\n\t\tlayer.edited = false;\r\n\t\tif (layer.editing) {\r\n\t\t\tlayer.editing.disable();\r\n\t\t}\r\n\r\n\t\tdelete layer.options.editing;\r\n\t\tdelete layer.options.original;\r\n\t\t// Reset layer styles to that of before select\r\n\t\tif (this._selectedPathOptions) {\r\n\t\t\tif (layer instanceof L.Marker) {\r\n\t\t\t\tthis._toggleMarkerHighlight(layer);\r\n\t\t\t} else {\r\n\t\t\t\t// reset the layer style to what is was before being selected\r\n\t\t\t\tlayer.setStyle(layer.options.previousOptions);\r\n\t\t\t\t// remove the cached options for the layer object\r\n\t\t\t\tdelete layer.options.previousOptions;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (layer instanceof L.Marker) {\r\n\t\t\tlayer.dragging.disable();\r\n\t\t\tlayer\r\n\t\t\t\t.off('dragend', this._onMarkerDragEnd, this)\r\n\t\t\t\t.off('touchmove', this._onTouchMove, this)\r\n\t\t\t\t.off('MSPointerMove', this._onTouchMove, this)\r\n\t\t\t\t.off('touchend', this._onMarkerDragEnd, this)\r\n\t\t\t\t.off('MSPointerUp', this._onMarkerDragEnd, this);\r\n\t\t} else {\r\n\t\t\tlayer.editing.disable();\r\n\t\t}\r\n\t},\r\n\r\n\t_onMouseMove: function (e) {\r\n\t\tthis._tooltip.updatePosition(e.latlng);\r\n\t},\r\n\r\n\t_onMarkerDragEnd: function (e) {\r\n\t\tvar layer = e.target;\r\n\t\tlayer.edited = true;\r\n\t\tthis._map.fire(L.Draw.Event.EDITMOVE, {layer: layer});\r\n\t},\r\n\r\n\t_onTouchMove: function (e) {\r\n\t\tvar touchEvent = e.originalEvent.changedTouches[0],\r\n\t\t\tlayerPoint = this._map.mouseEventToLayerPoint(touchEvent),\r\n\t\t\tlatlng = this._map.layerPointToLatLng(layerPoint);\r\n\t\te.target.setLatLng(latlng);\r\n\t},\r\n\r\n\t_hasAvailableLayers: function () {\r\n\t\treturn this._featureGroup.getLayers().length !== 0;\r\n\t}\r\n});\r\n","/**\r\n * @class L.EditToolbar.Delete\r\n * @aka EditToolbar.Delete\r\n */\r\nL.EditToolbar.Delete = L.Handler.extend({\r\n\tstatics: {\r\n\t\tTYPE: 'remove' // not delete as delete is reserved in js\r\n\t},\r\n\r\n\t// @method intialize(): void\r\n\tinitialize: function (map, options) {\r\n\t\tL.Handler.prototype.initialize.call(this, map);\r\n\r\n\t\tL.Util.setOptions(this, options);\r\n\r\n\t\t// Store the selectable layer group for ease of access\r\n\t\tthis._deletableLayers = this.options.featureGroup;\r\n\r\n\t\tif (!(this._deletableLayers instanceof L.FeatureGroup)) {\r\n\t\t\tthrow new Error('options.featureGroup must be a L.FeatureGroup');\r\n\t\t}\r\n\r\n\t\t// Save the type so super can fire, need to do this as cannot do this.TYPE :(\r\n\t\tthis.type = L.EditToolbar.Delete.TYPE;\r\n\r\n\t\tvar version = L.version.split('.');\r\n\t\t//If Version is >= 1.2.0\r\n\t\tif (parseInt(version[0], 10) === 1 && parseInt(version[1], 10) >= 2) {\r\n\t\t\tL.EditToolbar.Delete.include(L.Evented.prototype);\r\n\t\t} else {\r\n\t\t\tL.EditToolbar.Delete.include(L.Mixin.Events);\r\n\t\t}\r\n\r\n\t},\r\n\r\n\t// @method enable(): void\r\n\t// Enable the delete toolbar\r\n\tenable: function () {\r\n\t\tif (this._enabled || !this._hasAvailableLayers()) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tthis.fire('enabled', {handler: this.type});\r\n\r\n\t\tthis._map.fire(L.Draw.Event.DELETESTART, {handler: this.type});\r\n\r\n\t\tL.Handler.prototype.enable.call(this);\r\n\r\n\t\tthis._deletableLayers\r\n\t\t\t.on('layeradd', this._enableLayerDelete, this)\r\n\t\t\t.on('layerremove', this._disableLayerDelete, this);\r\n\t},\r\n\r\n\t// @method disable(): void\r\n\t// Disable the delete toolbar\r\n\tdisable: function () {\r\n\t\tif (!this._enabled) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tthis._deletableLayers\r\n\t\t\t.off('layeradd', this._enableLayerDelete, this)\r\n\t\t\t.off('layerremove', this._disableLayerDelete, this);\r\n\r\n\t\tL.Handler.prototype.disable.call(this);\r\n\r\n\t\tthis._map.fire(L.Draw.Event.DELETESTOP, {handler: this.type});\r\n\r\n\t\tthis.fire('disabled', {handler: this.type});\r\n\t},\r\n\r\n\t// @method addHooks(): void\r\n\t// Add listener hooks to this handler\r\n\taddHooks: function () {\r\n\t\tvar map = this._map;\r\n\r\n\t\tif (map) {\r\n\t\t\tmap.getContainer().focus();\r\n\r\n\t\t\tthis._deletableLayers.eachLayer(this._enableLayerDelete, this);\r\n\t\t\tthis._deletedLayers = new L.LayerGroup();\r\n\r\n\t\t\tthis._tooltip = new L.Draw.Tooltip(this._map);\r\n\t\t\tthis._tooltip.updateContent({text: L.drawLocal.edit.handlers.remove.tooltip.text});\r\n\r\n\t\t\tthis._map.on('mousemove', this._onMouseMove, this);\r\n\t\t}\r\n\t},\r\n\r\n\t// @method removeHooks(): void\r\n\t// Remove listener hooks from this handler\r\n\tremoveHooks: function () {\r\n\t\tif (this._map) {\r\n\t\t\tthis._deletableLayers.eachLayer(this._disableLayerDelete, this);\r\n\t\t\tthis._deletedLayers = null;\r\n\r\n\t\t\tthis._tooltip.dispose();\r\n\t\t\tthis._tooltip = null;\r\n\r\n\t\t\tthis._map.off('mousemove', this._onMouseMove, this);\r\n\t\t}\r\n\t},\r\n\r\n\t// @method revertLayers(): void\r\n\t// Revert the deleted layers back to their prior state.\r\n\trevertLayers: function () {\r\n\t\t// Iterate of the deleted layers and add them back into the featureGroup\r\n\t\tthis._deletedLayers.eachLayer(function (layer) {\r\n\t\t\tthis._deletableLayers.addLayer(layer);\r\n\t\t\tlayer.fire('revert-deleted', {layer: layer});\r\n\t\t}, this);\r\n\t},\r\n\r\n\t// @method save(): void\r\n\t// Save deleted layers\r\n\tsave: function () {\r\n\t\tthis._map.fire(L.Draw.Event.DELETED, {layers: this._deletedLayers});\r\n\t},\r\n\r\n\t// @method removeAllLayers(): void\r\n\t// Remove all delateable layers\r\n\tremoveAllLayers: function () {\r\n\t\t// Iterate of the delateable layers and add remove them\r\n\t\tthis._deletableLayers.eachLayer(function (layer) {\r\n\t\t\tthis._removeLayer({layer: layer});\r\n\t\t}, this);\r\n\t\tthis.save();\r\n\t},\r\n\r\n\t_enableLayerDelete: function (e) {\r\n\t\tvar layer = e.layer || e.target || e;\r\n\r\n\t\tlayer.on('click', this._removeLayer, this);\r\n\t},\r\n\r\n\t_disableLayerDelete: function (e) {\r\n\t\tvar layer = e.layer || e.target || e;\r\n\r\n\t\tlayer.off('click', this._removeLayer, this);\r\n\r\n\t\t// Remove from the deleted layers so we can't accidentally revert if the user presses cancel\r\n\t\tthis._deletedLayers.removeLayer(layer);\r\n\t},\r\n\r\n\t_removeLayer: function (e) {\r\n\t\tvar layer = e.layer || e.target || e;\r\n\r\n\t\tthis._deletableLayers.removeLayer(layer);\r\n\r\n\t\tthis._deletedLayers.addLayer(layer);\r\n\r\n\t\tlayer.fire('deleted');\r\n\t},\r\n\r\n\t_onMouseMove: function (e) {\r\n\t\tthis._tooltip.updatePosition(e.latlng);\r\n\t},\r\n\r\n\t_hasAvailableLayers: function () {\r\n\t\treturn this._deletableLayers.getLayers().length !== 0;\r\n\t}\r\n});\r\n"]} \ No newline at end of file +{"version":3,"sources":["src/Leaflet.draw.js","src/Leaflet.Draw.Event.js","src/draw/handler/Draw.Feature.js","src/draw/handler/Draw.Polyline.js","src/draw/handler/Draw.Polygon.js","src/draw/handler/Draw.SimpleShape.js","src/draw/handler/Draw.Rectangle.js","src/draw/handler/Draw.Marker.js","src/draw/handler/Draw.CircleMarker.js","src/draw/handler/Draw.Circle.js","src/edit/handler/Edit.Marker.js","src/edit/handler/Edit.Poly.js","src/edit/handler/Edit.SimpleShape.js","src/edit/handler/Edit.Rectangle.js","src/edit/handler/Edit.CircleMarker.js","src/edit/handler/Edit.Circle.js","src/ext/TouchEvents.js","src/ext/LatLngUtil.js","src/ext/GeometryUtil.js","src/ext/LineUtil.Intersect.js","src/ext/Polyline.Intersect.js","src/ext/Polygon.Intersect.js","src/Control.Draw.js","src/Toolbar.js","src/Tooltip.js","src/draw/DrawToolbar.js","src/edit/EditToolbar.js","src/edit/handler/EditToolbar.Edit.js","src/edit/handler/EditToolbar.Delete.js"],"names":[],"mappings":";;;;;;;yCAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC7LA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AChLA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACxGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AChlBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACjIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACvHA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AClGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC/HA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC1CA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACnFA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACpFA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACxgBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACrOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC7HA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACrDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC1DA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AChRA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC5BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACrKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACtBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC1GA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACjCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACtHA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC9UA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACtHA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC9GA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AClMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACnSA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","sourcesContent":["/**\r\n * Leaflet.draw assumes that you have already included the Leaflet library.\r\n */\r\nL.drawVersion = \"1.0.3+638b962\";\r\n/**\r\n * @class L.Draw\r\n * @aka Draw\r\n *\r\n *\r\n * To add the draw toolbar set the option drawControl: true in the map options.\r\n *\r\n * @example\r\n * ```js\r\n * var map = L.map('map', {drawControl: true}).setView([51.505, -0.09], 13);\r\n *\r\n * L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {\r\n * attribution: '© OpenStreetMap contributors'\r\n * }).addTo(map);\r\n * ```\r\n *\r\n * ### Adding the edit toolbar\r\n * To use the edit toolbar you must initialise the Leaflet.draw control and manually add it to the map.\r\n *\r\n * ```js\r\n * var map = L.map('map').setView([51.505, -0.09], 13);\r\n *\r\n * L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {\r\n * attribution: '© OpenStreetMap contributors'\r\n * }).addTo(map);\r\n *\r\n * // FeatureGroup is to store editable layers\r\n * var drawnItems = new L.FeatureGroup();\r\n * map.addLayer(drawnItems);\r\n *\r\n * var drawControl = new L.Control.Draw({\r\n * edit: {\r\n * featureGroup: drawnItems\r\n * }\r\n * });\r\n * map.addControl(drawControl);\r\n * ```\r\n *\r\n * The key here is the featureGroup option. This tells the plugin which FeatureGroup contains the layers that\r\n * should be editable. The featureGroup can contain 0 or more features with geometry types Point, LineString, and Polygon.\r\n * Leaflet.draw does not work with multigeometry features such as MultiPoint, MultiLineString, MultiPolygon,\r\n * or GeometryCollection. If you need to add multigeometry features to the draw plugin, convert them to a\r\n * FeatureCollection of non-multigeometries (Points, LineStrings, or Polygons).\r\n */\r\nL.Draw = {};\r\n\r\n/**\r\n * @class L.drawLocal\r\n * @aka L.drawLocal\r\n *\r\n * The core toolbar class of the API — it is used to create the toolbar ui\r\n *\r\n * @example\r\n * ```js\r\n * var modifiedDraw = L.drawLocal.extend({\r\n * draw: {\r\n * toolbar: {\r\n * buttons: {\r\n * polygon: 'Draw an awesome polygon'\r\n * }\r\n * }\r\n * }\r\n * });\r\n * ```\r\n *\r\n * The default state for the control is the draw toolbar just below the zoom control.\r\n * This will allow map users to draw vectors and markers.\r\n * **Please note the edit toolbar is not enabled by default.**\r\n */\r\nL.drawLocal = {\r\n\t// format: {\r\n\t// \tnumeric: {\r\n\t// \t\tdelimiters: {\r\n\t// \t\t\tthousands: ',',\r\n\t// \t\t\tdecimal: '.'\r\n\t// \t\t}\r\n\t// \t}\r\n\t// },\r\n\tdraw: {\r\n\t\ttoolbar: {\r\n\t\t\t// #TODO: this should be reorganized where actions are nested in actions\r\n\t\t\t// ex: actions.undo or actions.cancel\r\n\t\t\tactions: {\r\n\t\t\t\ttitle: 'Cancel drawing',\r\n\t\t\t\ttext: 'Cancel'\r\n\t\t\t},\r\n\t\t\tfinish: {\r\n\t\t\t\ttitle: 'Finish drawing',\r\n\t\t\t\ttext: 'Finish'\r\n\t\t\t},\r\n\t\t\tundo: {\r\n\t\t\t\ttitle: 'Delete last point drawn',\r\n\t\t\t\ttext: 'Delete last point'\r\n\t\t\t},\r\n\t\t\tbuttons: {\r\n\t\t\t\tpolyline: 'Draw a polyline',\r\n\t\t\t\tpolygon: 'Draw a polygon',\r\n\t\t\t\trectangle: 'Draw a rectangle',\r\n\t\t\t\tcircle: 'Draw a circle',\r\n\t\t\t\tmarker: 'Draw a marker',\r\n\t\t\t\tcirclemarker: 'Draw a circlemarker'\r\n\t\t\t}\r\n\t\t},\r\n\t\thandlers: {\r\n\t\t\tcircle: {\r\n\t\t\t\ttooltip: {\r\n\t\t\t\t\tstart: 'Click and drag to draw circle.'\r\n\t\t\t\t},\r\n\t\t\t\tradius: 'Radius'\r\n\t\t\t},\r\n\t\t\tcirclemarker: {\r\n\t\t\t\ttooltip: {\r\n\t\t\t\t\tstart: 'Click map to place circle marker.'\r\n\t\t\t\t}\r\n\t\t\t},\r\n\t\t\tmarker: {\r\n\t\t\t\ttooltip: {\r\n\t\t\t\t\tstart: 'Click map to place marker.'\r\n\t\t\t\t}\r\n\t\t\t},\r\n\t\t\tpolygon: {\r\n\t\t\t\ttooltip: {\r\n\t\t\t\t\tstart: 'Click to start drawing shape.',\r\n\t\t\t\t\tcont: 'Click to continue drawing shape.',\r\n\t\t\t\t\tend: 'Click first point to close this shape.'\r\n\t\t\t\t}\r\n\t\t\t},\r\n\t\t\tpolyline: {\r\n\t\t\t\terror: 'Error: shape edges cannot cross!',\r\n\t\t\t\ttooltip: {\r\n\t\t\t\t\tstart: 'Click to start drawing line.',\r\n\t\t\t\t\tcont: 'Click to continue drawing line.',\r\n\t\t\t\t\tend: 'Click last point to finish line.'\r\n\t\t\t\t}\r\n\t\t\t},\r\n\t\t\trectangle: {\r\n\t\t\t\ttooltip: {\r\n\t\t\t\t\tstart: 'Click and drag to draw rectangle.'\r\n\t\t\t\t}\r\n\t\t\t},\r\n\t\t\tsimpleshape: {\r\n\t\t\t\ttooltip: {\r\n\t\t\t\t\tend: 'Release mouse to finish drawing.'\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t},\r\n\tedit: {\r\n\t\ttoolbar: {\r\n\t\t\tactions: {\r\n\t\t\t\tsave: {\r\n\t\t\t\t\ttitle: 'Save changes',\r\n\t\t\t\t\ttext: 'Save'\r\n\t\t\t\t},\r\n\t\t\t\tcancel: {\r\n\t\t\t\t\ttitle: 'Cancel editing, discards all changes',\r\n\t\t\t\t\ttext: 'Cancel'\r\n\t\t\t\t},\r\n\t\t\t\tclearAll: {\r\n\t\t\t\t\ttitle: 'Clear all layers',\r\n\t\t\t\t\ttext: 'Clear All'\r\n\t\t\t\t}\r\n\t\t\t},\r\n\t\t\tbuttons: {\r\n\t\t\t\tedit: 'Edit layers',\r\n\t\t\t\teditDisabled: 'No layers to edit',\r\n\t\t\t\tremove: 'Delete layers',\r\n\t\t\t\tremoveDisabled: 'No layers to delete'\r\n\t\t\t}\r\n\t\t},\r\n\t\thandlers: {\r\n\t\t\tedit: {\r\n\t\t\t\ttooltip: {\r\n\t\t\t\t\ttext: 'Drag handles or markers to edit features.',\r\n\t\t\t\t\tsubtext: 'Click cancel to undo changes.'\r\n\t\t\t\t}\r\n\t\t\t},\r\n\t\t\tremove: {\r\n\t\t\t\ttooltip: {\r\n\t\t\t\t\ttext: 'Click on a feature to remove.'\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n};\r\n","/**\r\n * ### Events\r\n * Once you have successfully added the Leaflet.draw plugin to your map you will want to respond to the different\r\n * actions users can initiate. The following events will be triggered on the map:\r\n *\r\n * @class L.Draw.Event\r\n * @aka Draw.Event\r\n *\r\n * Use `L.Draw.Event.EVENTNAME` constants to ensure events are correct.\r\n *\r\n * @example\r\n * ```js\r\n * map.on(L.Draw.Event.CREATED; function (e) {\r\n * var type = e.layerType,\r\n * layer = e.layer;\r\n *\r\n * if (type === 'marker') {\r\n * // Do marker specific actions\r\n * }\r\n *\r\n * // Do whatever else you need to. (save to db; add to map etc)\r\n * map.addLayer(layer);\r\n *});\r\n * ```\r\n */\r\nL.Draw.Event = {};\r\n/**\r\n * @event draw:created: PolyLine; Polygon; Rectangle; Circle; Marker | String\r\n *\r\n * Layer that was just created.\r\n * The type of layer this is. One of: `polyline`; `polygon`; `rectangle`; `circle`; `marker`\r\n * Triggered when a new vector or marker has been created.\r\n *\r\n */\r\nL.Draw.Event.CREATED = 'draw:created';\r\n\r\n/**\r\n * @event draw:edited: LayerGroup\r\n *\r\n * List of all layers just edited on the map.\r\n *\r\n *\r\n * Triggered when layers in the FeatureGroup; initialised with the plugin; have been edited and saved.\r\n *\r\n * @example\r\n * ```js\r\n * map.on('draw:edited', function (e) {\r\n * var layers = e.layers;\r\n * layers.eachLayer(function (layer) {\r\n * //do whatever you want; most likely save back to db\r\n * });\r\n * });\r\n * ```\r\n */\r\nL.Draw.Event.EDITED = 'draw:edited';\r\n\r\n/**\r\n * @event draw:deleted: LayerGroup\r\n *\r\n * List of all layers just removed from the map.\r\n *\r\n * Triggered when layers have been removed (and saved) from the FeatureGroup.\r\n */\r\nL.Draw.Event.DELETED = 'draw:deleted';\r\n\r\n/**\r\n * @event draw:drawstart: String\r\n *\r\n * The type of layer this is. One of:`polyline`; `polygon`; `rectangle`; `circle`; `marker`\r\n *\r\n * Triggered when the user has chosen to draw a particular vector or marker.\r\n */\r\nL.Draw.Event.DRAWSTART = 'draw:drawstart';\r\n\r\n/**\r\n * @event draw:drawstop: String\r\n *\r\n * The type of layer this is. One of: `polyline`; `polygon`; `rectangle`; `circle`; `marker`\r\n *\r\n * Triggered when the user has finished a particular vector or marker.\r\n */\r\n\r\nL.Draw.Event.DRAWSTOP = 'draw:drawstop';\r\n\r\n/**\r\n * @event draw:drawvertex: LayerGroup\r\n *\r\n * List of all layers just being added from the map.\r\n *\r\n * Triggered when a vertex is created on a polyline or polygon.\r\n */\r\nL.Draw.Event.DRAWVERTEX = 'draw:drawvertex';\r\n\r\n/**\r\n * @event draw:editstart: String\r\n *\r\n * The type of edit this is. One of: `edit`\r\n *\r\n * Triggered when the user starts edit mode by clicking the edit tool button.\r\n */\r\n\r\nL.Draw.Event.EDITSTART = 'draw:editstart';\r\n\r\n/**\r\n * @event draw:editmove: ILayer\r\n *\r\n * Layer that was just moved.\r\n *\r\n * Triggered as the user moves a rectangle; circle or marker.\r\n */\r\nL.Draw.Event.EDITMOVE = 'draw:editmove';\r\n\r\n/**\r\n * @event draw:editresize: ILayer\r\n *\r\n * Layer that was just moved.\r\n *\r\n * Triggered as the user resizes a rectangle or circle.\r\n */\r\nL.Draw.Event.EDITRESIZE = 'draw:editresize';\r\n\r\n/**\r\n * @event draw:editvertex: LayerGroup\r\n *\r\n * List of all layers just being edited from the map.\r\n *\r\n * Triggered when a vertex is edited on a polyline or polygon.\r\n */\r\nL.Draw.Event.EDITVERTEX = 'draw:editvertex';\r\n\r\n/**\r\n * @event draw:editstop: String\r\n *\r\n * The type of edit this is. One of: `edit`\r\n *\r\n * Triggered when the user has finshed editing (edit mode) and saves edits.\r\n */\r\nL.Draw.Event.EDITSTOP = 'draw:editstop';\r\n\r\n/**\r\n * @event draw:deletestart: String\r\n *\r\n * The type of edit this is. One of: `remove`\r\n *\r\n * Triggered when the user starts remove mode by clicking the remove tool button.\r\n */\r\nL.Draw.Event.DELETESTART = 'draw:deletestart';\r\n\r\n/**\r\n * @event draw:deletestop: String\r\n *\r\n * The type of edit this is. One of: `remove`\r\n *\r\n * Triggered when the user has finished removing shapes (remove mode) and saves.\r\n */\r\nL.Draw.Event.DELETESTOP = 'draw:deletestop';\r\n\r\n/**\r\n * @event draw:toolbaropened: String\r\n *\r\n * Triggered when a toolbar is opened.\r\n */\r\nL.Draw.Event.TOOLBAROPENED = 'draw:toolbaropened';\r\n\r\n/**\r\n * @event draw:toolbarclosed: String\r\n *\r\n * Triggered when a toolbar is closed.\r\n */\r\nL.Draw.Event.TOOLBARCLOSED = 'draw:toolbarclosed';\r\n\r\n/**\r\n * @event draw:markercontext: String\r\n *\r\n * Triggered when a marker is right clicked.\r\n */\r\nL.Draw.Event.MARKERCONTEXT = 'draw:markercontext';","L.Draw = L.Draw || {};\r\n\r\n/**\r\n * @class L.Draw.Feature\r\n * @aka Draw.Feature\r\n */\r\nL.Draw.Feature = L.Handler.extend({\r\n\r\n\t// @method initialize(): void\r\n\tinitialize: function (map, options) {\r\n\t\tthis._map = map;\r\n\t\tthis._container = map._container;\r\n\t\tthis._overlayPane = map._panes.overlayPane;\r\n\t\tthis._popupPane = map._panes.popupPane;\r\n\r\n\t\t// Merge default shapeOptions options with custom shapeOptions\r\n\t\tif (options && options.shapeOptions) {\r\n\t\t\toptions.shapeOptions = L.Util.extend({}, this.options.shapeOptions, options.shapeOptions);\r\n\t\t}\r\n\t\tL.setOptions(this, options);\r\n\r\n\t\tvar version = L.version.split('.');\r\n\t\t//If Version is >= 1.2.0\r\n\t\tif (parseInt(version[0], 10) === 1 && parseInt(version[1], 10) >= 2) {\r\n\t\t\tL.Draw.Feature.include(L.Evented.prototype);\r\n\t\t} else {\r\n\t\t\tL.Draw.Feature.include(L.Mixin.Events);\r\n\t\t}\r\n\t},\r\n\r\n\t// @method enable(): void\r\n\t// Enables this handler\r\n\tenable: function () {\r\n\t\tif (this._enabled) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tL.Handler.prototype.enable.call(this);\r\n\r\n\t\tthis.fire('enabled', {handler: this.type});\r\n\r\n\t\tthis._map.fire(L.Draw.Event.DRAWSTART, {layerType: this.type});\r\n\t},\r\n\r\n\t// @method disable(): void\r\n\tdisable: function () {\r\n\t\tif (!this._enabled) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tL.Handler.prototype.disable.call(this);\r\n\r\n\t\tthis._map.fire(L.Draw.Event.DRAWSTOP, {layerType: this.type});\r\n\r\n\t\tthis.fire('disabled', {handler: this.type});\r\n\t},\r\n\r\n\t// @method addHooks(): void\r\n\t// Add's event listeners to this handler\r\n\taddHooks: function () {\r\n\t\tvar map = this._map;\r\n\r\n\t\tif (map) {\r\n\t\t\tL.DomUtil.disableTextSelection();\r\n\r\n\t\t\tmap.getContainer().focus();\r\n\r\n\t\t\tthis._tooltip = new L.Draw.Tooltip(this._map);\r\n\r\n\t\t\tL.DomEvent.on(this._container, 'keyup', this._cancelDrawing, this);\r\n\t\t}\r\n\t},\r\n\r\n\t// @method removeHooks(): void\r\n\t// Removes event listeners from this handler\r\n\tremoveHooks: function () {\r\n\t\tif (this._map) {\r\n\t\t\tL.DomUtil.enableTextSelection();\r\n\r\n\t\t\tthis._tooltip.dispose();\r\n\t\t\tthis._tooltip = null;\r\n\r\n\t\t\tL.DomEvent.off(this._container, 'keyup', this._cancelDrawing, this);\r\n\t\t}\r\n\t},\r\n\r\n\t// @method setOptions(object): void\r\n\t// Sets new options to this handler\r\n\tsetOptions: function (options) {\r\n\t\tL.setOptions(this, options);\r\n\t},\r\n\r\n\t_fireCreatedEvent: function (layer) {\r\n\t\tthis._map.fire(L.Draw.Event.CREATED, {layer: layer, layerType: this.type});\r\n\t},\r\n\r\n\t// Cancel drawing when the escape key is pressed\r\n\t_cancelDrawing: function (e) {\r\n\t\tif (e.keyCode === 27) {\r\n\t\t\tthis._map.fire('draw:canceled', {layerType: this.type});\r\n\t\t\tthis.disable();\r\n\t\t}\r\n\t}\r\n});\r\n","/**\r\n * @class L.Draw.Polyline\r\n * @aka Draw.Polyline\r\n * @inherits L.Draw.Feature\r\n */\r\nL.Draw.Polyline = L.Draw.Feature.extend({\r\n\tstatics: {\r\n\t\tTYPE: 'polyline'\r\n\t},\r\n\r\n\tPoly: L.Polyline,\r\n\r\n\toptions: {\r\n\t\tallowIntersection: true,\r\n\t\trepeatMode: false,\r\n\t\tdrawError: {\r\n\t\t\tcolor: '#b00b00',\r\n\t\t\ttimeout: 2500\r\n\t\t},\r\n\t\ticon: new L.DivIcon({\r\n\t\t\ticonSize: new L.Point(8, 8),\r\n\t\t\tclassName: 'leaflet-div-icon leaflet-editing-icon'\r\n\t\t}),\r\n\t\ttouchIcon: new L.DivIcon({\r\n\t\t\ticonSize: new L.Point(20, 20),\r\n\t\t\tclassName: 'leaflet-div-icon leaflet-editing-icon leaflet-touch-icon'\r\n\t\t}),\r\n\t\tguidelineDistance: 20,\r\n\t\tmaxGuideLineLength: 4000,\r\n\t\tshapeOptions: {\r\n\t\t\tstroke: true,\r\n\t\t\tcolor: '#3388ff',\r\n\t\t\tweight: 4,\r\n\t\t\topacity: 0.5,\r\n\t\t\tfill: false,\r\n\t\t\tclickable: true\r\n\t\t},\r\n\t\tmetric: true, // Whether to use the metric measurement system or imperial\r\n\t\tfeet: true, // When not metric, to use feet instead of yards for display.\r\n\t\tnautic: false, // When not metric, not feet use nautic mile for display\r\n\t\tshowLength: true, // Whether to display distance in the tooltip\r\n\t\tzIndexOffset: 2000, // This should be > than the highest z-index any map layers\r\n\t\tfactor: 1, // To change distance calculation\r\n\t\tmaxPoints: 0 // Once this number of points are placed, finish shape\r\n\t},\r\n\r\n\t// @method initialize(): void\r\n\tinitialize: function (map, options) {\r\n\t\t// if touch, switch to touch icon\r\n\t\tif (L.Browser.touch) {\r\n\t\t\tthis.options.icon = this.options.touchIcon;\r\n\t\t}\r\n\r\n\t\t// Need to set this here to ensure the correct message is used.\r\n\t\tthis.options.drawError.message = L.drawLocal.draw.handlers.polyline.error;\r\n\r\n\t\t// Merge default drawError options with custom options\r\n\t\tif (options && options.drawError) {\r\n\t\t\toptions.drawError = L.Util.extend({}, this.options.drawError, options.drawError);\r\n\t\t}\r\n\r\n\t\t// Save the type so super can fire, need to do this as cannot do this.TYPE :(\r\n\t\tthis.type = L.Draw.Polyline.TYPE;\r\n\r\n\t\tL.Draw.Feature.prototype.initialize.call(this, map, options);\r\n\t},\r\n\r\n\t// @method addHooks(): void\r\n\t// Add listener hooks to this handler\r\n\taddHooks: function () {\r\n\t\tL.Draw.Feature.prototype.addHooks.call(this);\r\n\t\tif (this._map) {\r\n\t\t\tthis._markers = [];\r\n\r\n\t\t\tthis._markerGroup = new L.LayerGroup();\r\n\t\t\tthis._map.addLayer(this._markerGroup);\r\n\r\n\t\t\tthis._poly = new L.Polyline([], this.options.shapeOptions);\r\n\r\n\t\t\tthis._tooltip.updateContent(this._getTooltipText());\r\n\r\n\t\t\t// Make a transparent marker that will used to catch click events. These click\r\n\t\t\t// events will create the vertices. We need to do this so we can ensure that\r\n\t\t\t// we can create vertices over other map layers (markers, vector layers). We\r\n\t\t\t// also do not want to trigger any click handlers of objects we are clicking on\r\n\t\t\t// while drawing.\r\n\t\t\tif (!this._mouseMarker) {\r\n\t\t\t\tthis._mouseMarker = L.marker(this._map.getCenter(), {\r\n\t\t\t\t\ticon: L.divIcon({\r\n\t\t\t\t\t\tclassName: 'leaflet-mouse-marker',\r\n\t\t\t\t\t\ticonAnchor: [20, 20],\r\n\t\t\t\t\t\ticonSize: [40, 40]\r\n\t\t\t\t\t}),\r\n\t\t\t\t\topacity: 0,\r\n\t\t\t\t\tzIndexOffset: this.options.zIndexOffset\r\n\t\t\t\t});\r\n\t\t\t}\r\n\r\n\t\t\tthis._mouseMarker\r\n\t\t\t\t.on('mouseout', this._onMouseOut, this)\r\n\t\t\t\t.on('mousemove', this._onMouseMove, this) // Necessary to prevent 0.8 stutter\r\n\t\t\t\t.on('mousedown', this._onMouseDown, this)\r\n\t\t\t\t.on('mouseup', this._onMouseUp, this) // Necessary for 0.8 compatibility\r\n\t\t\t\t.addTo(this._map);\r\n\r\n\t\t\tthis._map\r\n\t\t\t\t.on('mouseup', this._onMouseUp, this) // Necessary for 0.7 compatibility\r\n\t\t\t\t.on('mousemove', this._onMouseMove, this)\r\n\t\t\t\t.on('zoomlevelschange', this._onZoomEnd, this)\r\n\t\t\t\t.on('touchstart', this._onTouch, this)\r\n\t\t\t\t.on('zoomend', this._onZoomEnd, this);\r\n\r\n\t\t}\r\n\t},\r\n\r\n\t// @method removeHooks(): void\r\n\t// Remove listener hooks from this handler.\r\n\tremoveHooks: function () {\r\n\t\tL.Draw.Feature.prototype.removeHooks.call(this);\r\n\r\n\t\tthis._clearHideErrorTimeout();\r\n\r\n\t\tthis._cleanUpShape();\r\n\r\n\t\t// remove markers from map\r\n\t\tthis._map.removeLayer(this._markerGroup);\r\n\t\tdelete this._markerGroup;\r\n\t\tdelete this._markers;\r\n\r\n\t\tthis._map.removeLayer(this._poly);\r\n\t\tdelete this._poly;\r\n\r\n\t\tthis._mouseMarker\r\n\t\t\t.off('mousedown', this._onMouseDown, this)\r\n\t\t\t.off('mouseout', this._onMouseOut, this)\r\n\t\t\t.off('mouseup', this._onMouseUp, this)\r\n\t\t\t.off('mousemove', this._onMouseMove, this);\r\n\t\tthis._map.removeLayer(this._mouseMarker);\r\n\t\tdelete this._mouseMarker;\r\n\r\n\t\t// clean up DOM\r\n\t\tthis._clearGuides();\r\n\r\n\t\tthis._map\r\n\t\t\t.off('mouseup', this._onMouseUp, this)\r\n\t\t\t.off('mousemove', this._onMouseMove, this)\r\n\t\t\t.off('zoomlevelschange', this._onZoomEnd, this)\r\n\t\t\t.off('zoomend', this._onZoomEnd, this)\r\n\t\t\t.off('touchstart', this._onTouch, this)\r\n\t\t\t.off('click', this._onTouch, this);\r\n\t},\r\n\r\n\t// @method deleteLastVertex(): void\r\n\t// Remove the last vertex from the polyline, removes polyline from map if only one point exists.\r\n\tdeleteLastVertex: function () {\r\n\t\tif (this._markers.length <= 1) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tvar lastMarker = this._markers.pop(),\r\n\t\t\tpoly = this._poly,\r\n\t\t\t// Replaces .spliceLatLngs()\r\n\t\t\tlatlngs = poly.getLatLngs(),\r\n\t\t\tlatlng = latlngs.splice(-1, 1)[0];\r\n\t\tthis._poly.setLatLngs(latlngs);\r\n\r\n\t\tthis._markerGroup.removeLayer(lastMarker);\r\n\r\n\t\tif (poly.getLatLngs().length < 2) {\r\n\t\t\tthis._map.removeLayer(poly);\r\n\t\t}\r\n\r\n\t\tthis._vertexChanged(latlng, false);\r\n\t},\r\n\r\n\t// @method addVertex(): void\r\n\t// Add a vertex to the end of the polyline\r\n\taddVertex: function (latlng) {\r\n\t\tvar markersLength = this._markers.length;\r\n\t\t// markersLength must be greater than or equal to 2 before intersections can occur\r\n\t\tif (markersLength >= 2 && !this.options.allowIntersection && this._poly.newLatLngIntersects(latlng)) {\r\n\t\t\tthis._showErrorTooltip();\r\n\t\t\treturn;\r\n\t\t}\r\n\t\telse if (this._errorShown) {\r\n\t\t\tthis._hideErrorTooltip();\r\n\t\t}\r\n\r\n\t\tthis._markers.push(this._createMarker(latlng));\r\n\r\n\t\tthis._poly.addLatLng(latlng);\r\n\r\n\t\tif (this._poly.getLatLngs().length === 2) {\r\n\t\t\tthis._map.addLayer(this._poly);\r\n\t\t}\r\n\r\n\t\tthis._vertexChanged(latlng, true);\r\n\t},\r\n\r\n\t// @method completeShape(): void\r\n\t// Closes the polyline between the first and last points\r\n\tcompleteShape: function () {\r\n\t\tif (this._markers.length <= 1 || !this._shapeIsValid()) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tthis._fireCreatedEvent();\r\n\t\tthis.disable();\r\n\r\n\t\tif (this.options.repeatMode) {\r\n\t\t\tthis.enable();\r\n\t\t}\r\n\t},\r\n\r\n\t_finishShape: function () {\r\n\t\tvar latlngs = this._poly._defaultShape ? this._poly._defaultShape() : this._poly.getLatLngs();\r\n\t\tvar intersects = this._poly.newLatLngIntersects(latlngs[latlngs.length - 1]);\r\n\r\n\t\tif ((!this.options.allowIntersection && intersects) || !this._shapeIsValid()) {\r\n\t\t\tthis._showErrorTooltip();\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tthis._fireCreatedEvent();\r\n\t\tthis.disable();\r\n\t\tif (this.options.repeatMode) {\r\n\t\t\tthis.enable();\r\n\t\t}\r\n\t},\r\n\r\n\t// Called to verify the shape is valid when the user tries to finish it\r\n\t// Return false if the shape is not valid\r\n\t_shapeIsValid: function () {\r\n\t\treturn true;\r\n\t},\r\n\r\n\t_onZoomEnd: function () {\r\n\t\tif (this._markers !== null) {\r\n\t\t\tthis._updateGuide();\r\n\t\t}\r\n\t},\r\n\r\n\t_onMouseMove: function (e) {\r\n\t\tvar newPos = this._map.mouseEventToLayerPoint(e.originalEvent);\r\n\t\tvar latlng = this._map.layerPointToLatLng(newPos);\r\n\r\n\t\t// Save latlng\r\n\t\t// should this be moved to _updateGuide() ?\r\n\t\tthis._currentLatLng = latlng;\r\n\r\n\t\tthis._updateTooltip(latlng);\r\n\r\n\t\t// Update the guide line\r\n\t\tthis._updateGuide(newPos);\r\n\r\n\t\t// Update the mouse marker position\r\n\t\tthis._mouseMarker.setLatLng(latlng);\r\n\r\n\t\tL.DomEvent.preventDefault(e.originalEvent);\r\n\t},\r\n\r\n\t_vertexChanged: function (latlng, added) {\r\n\t\tthis._map.fire(L.Draw.Event.DRAWVERTEX, {layers: this._markerGroup});\r\n\t\tthis._updateFinishHandler();\r\n\r\n\t\tthis._updateRunningMeasure(latlng, added);\r\n\r\n\t\tthis._clearGuides();\r\n\r\n\t\tthis._updateTooltip();\r\n\t},\r\n\r\n\t_onMouseDown: function (e) {\r\n\t\tif (!this._clickHandled && !this._touchHandled && !this._disableMarkers) {\r\n\t\t\tthis._onMouseMove(e);\r\n\t\t\tthis._clickHandled = true;\r\n\t\t\tthis._disableNewMarkers();\r\n\t\t\tvar originalEvent = e.originalEvent;\r\n\t\t\tvar clientX = originalEvent.clientX;\r\n\t\t\tvar clientY = originalEvent.clientY;\r\n\t\t\tthis._startPoint.call(this, clientX, clientY);\r\n\t\t}\r\n\t},\r\n\r\n\t_startPoint: function (clientX, clientY) {\r\n\t\tthis._mouseDownOrigin = L.point(clientX, clientY);\r\n\t},\r\n\r\n\t_onMouseUp: function (e) {\r\n\t\tvar originalEvent = e.originalEvent;\r\n\t\tvar clientX = originalEvent.clientX;\r\n\t\tvar clientY = originalEvent.clientY;\r\n\t\tthis._endPoint.call(this, clientX, clientY, e);\r\n\t\tthis._clickHandled = null;\r\n\t},\r\n\r\n\t_endPoint: function (clientX, clientY, e) {\r\n\t\tif (this._mouseDownOrigin) {\r\n\t\t\tvar dragCheckDistance = L.point(clientX, clientY)\r\n\t\t\t\t.distanceTo(this._mouseDownOrigin);\r\n\t\t\tvar lastPtDistance = this._calculateFinishDistance(e.latlng);\r\n\t\t\tif (this.options.maxPoints > 1 && this.options.maxPoints == this._markers.length + 1) {\r\n\t\t\t\tthis.addVertex(e.latlng);\r\n\t\t\t\tthis._finishShape();\r\n\t\t\t} else if (lastPtDistance < 10 && L.Browser.touch) {\r\n\t\t\t\tthis._finishShape();\r\n\t\t\t} else if (Math.abs(dragCheckDistance) < 9 * (window.devicePixelRatio || 1)) {\r\n\t\t\t\tthis.addVertex(e.latlng);\r\n\t\t\t}\r\n\t\t\tthis._enableNewMarkers(); // after a short pause, enable new markers\r\n\t\t}\r\n\t\tthis._mouseDownOrigin = null;\r\n\t},\r\n\r\n\t// ontouch prevented by clickHandled flag because some browsers fire both click/touch events,\r\n\t// causing unwanted behavior\r\n\t_onTouch: function (e) {\r\n\t\tvar originalEvent = e.originalEvent;\r\n\t\tvar clientX;\r\n\t\tvar clientY;\r\n\t\tif (originalEvent.touches && originalEvent.touches[0] && !this._clickHandled && !this._touchHandled && !this._disableMarkers) {\r\n\t\t\tclientX = originalEvent.touches[0].clientX;\r\n\t\t\tclientY = originalEvent.touches[0].clientY;\r\n\t\t\tthis._disableNewMarkers();\r\n\t\t\tthis._touchHandled = true;\r\n\t\t\tthis._startPoint.call(this, clientX, clientY);\r\n\t\t\tthis._endPoint.call(this, clientX, clientY, e);\r\n\t\t\tthis._touchHandled = null;\r\n\t\t}\r\n\t\tthis._clickHandled = null;\r\n\t},\r\n\r\n\t_onMouseOut: function () {\r\n\t\tif (this._tooltip) {\r\n\t\t\tthis._tooltip._onMouseOut.call(this._tooltip);\r\n\t\t}\r\n\t},\r\n\r\n\t// calculate if we are currently within close enough distance\r\n\t// of the closing point (first point for shapes, last point for lines)\r\n\t// this is semi-ugly code but the only reliable way i found to get the job done\r\n\t// note: calculating point.distanceTo between mouseDownOrigin and last marker did NOT work\r\n\t_calculateFinishDistance: function (potentialLatLng) {\r\n\t\tvar lastPtDistance;\r\n\t\tif (this._markers.length > 0) {\r\n\t\t\tvar finishMarker;\r\n\t\t\tif (this.type === L.Draw.Polyline.TYPE) {\r\n\t\t\t\tfinishMarker = this._markers[this._markers.length - 1];\r\n\t\t\t} else if (this.type === L.Draw.Polygon.TYPE) {\r\n\t\t\t\tfinishMarker = this._markers[0];\r\n\t\t\t} else {\r\n\t\t\t\treturn Infinity;\r\n\t\t\t}\r\n\t\t\tvar lastMarkerPoint = this._map.latLngToContainerPoint(finishMarker.getLatLng()),\r\n\t\t\t\tpotentialMarker = new L.Marker(potentialLatLng, {\r\n\t\t\t\t\ticon: this.options.icon,\r\n\t\t\t\t\tzIndexOffset: this.options.zIndexOffset * 2\r\n\t\t\t\t});\r\n\t\t\tvar potentialMarkerPint = this._map.latLngToContainerPoint(potentialMarker.getLatLng());\r\n\t\t\tlastPtDistance = lastMarkerPoint.distanceTo(potentialMarkerPint);\r\n\t\t} else {\r\n\t\t\tlastPtDistance = Infinity;\r\n\t\t}\r\n\t\treturn lastPtDistance;\r\n\t},\r\n\r\n\t_updateFinishHandler: function () {\r\n\t\tvar markerCount = this._markers.length;\r\n\t\t// The last marker should have a click handler to close the polyline\r\n\t\tif (markerCount > 1) {\r\n\t\t\tthis._markers[markerCount - 1].on('click', this._finishShape, this);\r\n\t\t}\r\n\r\n\t\t// Remove the old marker click handler (as only the last point should close the polyline)\r\n\t\tif (markerCount > 2) {\r\n\t\t\tthis._markers[markerCount - 2].off('click', this._finishShape, this);\r\n\t\t}\r\n\t},\r\n\r\n\t_createMarker: function (latlng) {\r\n\t\tvar marker = new L.Marker(latlng, {\r\n\t\t\ticon: this.options.icon,\r\n\t\t\tzIndexOffset: this.options.zIndexOffset * 2\r\n\t\t});\r\n\r\n\t\tthis._markerGroup.addLayer(marker);\r\n\r\n\t\treturn marker;\r\n\t},\r\n\r\n\t_updateGuide: function (newPos) {\r\n\t\tvar markerCount = this._markers ? this._markers.length : 0;\r\n\r\n\t\tif (markerCount > 0) {\r\n\t\t\tnewPos = newPos || this._map.latLngToLayerPoint(this._currentLatLng);\r\n\r\n\t\t\t// draw the guide line\r\n\t\t\tthis._clearGuides();\r\n\t\t\tthis._drawGuide(\r\n\t\t\t\tthis._map.latLngToLayerPoint(this._markers[markerCount - 1].getLatLng()),\r\n\t\t\t\tnewPos\r\n\t\t\t);\r\n\t\t}\r\n\t},\r\n\r\n\t_updateTooltip: function (latLng) {\r\n\t\tvar text = this._getTooltipText();\r\n\r\n\t\tif (latLng) {\r\n\t\t\tthis._tooltip.updatePosition(latLng);\r\n\t\t}\r\n\r\n\t\tif (!this._errorShown) {\r\n\t\t\tthis._tooltip.updateContent(text);\r\n\t\t}\r\n\t},\r\n\r\n\t_drawGuide: function (pointA, pointB) {\r\n\t\tvar length = Math.floor(Math.sqrt(Math.pow((pointB.x - pointA.x), 2) + Math.pow((pointB.y - pointA.y), 2))),\r\n\t\t\tguidelineDistance = this.options.guidelineDistance,\r\n\t\t\tmaxGuideLineLength = this.options.maxGuideLineLength,\r\n\t\t\t// Only draw a guideline with a max length\r\n\t\t\ti = length > maxGuideLineLength ? length - maxGuideLineLength : guidelineDistance,\r\n\t\t\tfraction,\r\n\t\t\tdashPoint,\r\n\t\t\tdash;\r\n\r\n\t\t//create the guides container if we haven't yet\r\n\t\tif (!this._guidesContainer) {\r\n\t\t\tthis._guidesContainer = L.DomUtil.create('div', 'leaflet-draw-guides', this._overlayPane);\r\n\t\t}\r\n\r\n\t\t//draw a dash every GuildeLineDistance\r\n\t\tfor (; i < length; i += this.options.guidelineDistance) {\r\n\t\t\t//work out fraction along line we are\r\n\t\t\tfraction = i / length;\r\n\r\n\t\t\t//calculate new x,y point\r\n\t\t\tdashPoint = {\r\n\t\t\t\tx: Math.floor((pointA.x * (1 - fraction)) + (fraction * pointB.x)),\r\n\t\t\t\ty: Math.floor((pointA.y * (1 - fraction)) + (fraction * pointB.y))\r\n\t\t\t};\r\n\r\n\t\t\t//add guide dash to guide container\r\n\t\t\tdash = L.DomUtil.create('div', 'leaflet-draw-guide-dash', this._guidesContainer);\r\n\t\t\tdash.style.backgroundColor =\r\n\t\t\t\t!this._errorShown ? this.options.shapeOptions.color : this.options.drawError.color;\r\n\r\n\t\t\tL.DomUtil.setPosition(dash, dashPoint);\r\n\t\t}\r\n\t},\r\n\r\n\t_updateGuideColor: function (color) {\r\n\t\tif (this._guidesContainer) {\r\n\t\t\tfor (var i = 0, l = this._guidesContainer.childNodes.length; i < l; i++) {\r\n\t\t\t\tthis._guidesContainer.childNodes[i].style.backgroundColor = color;\r\n\t\t\t}\r\n\t\t}\r\n\t},\r\n\r\n\t// removes all child elements (guide dashes) from the guides container\r\n\t_clearGuides: function () {\r\n\t\tif (this._guidesContainer) {\r\n\t\t\twhile (this._guidesContainer.firstChild) {\r\n\t\t\t\tthis._guidesContainer.removeChild(this._guidesContainer.firstChild);\r\n\t\t\t}\r\n\t\t}\r\n\t},\r\n\r\n\t_getTooltipText: function () {\r\n\t\tvar showLength = this.options.showLength,\r\n\t\t\tlabelText, distanceStr;\r\n\t\tif (this._markers.length === 0) {\r\n\t\t\tlabelText = {\r\n\t\t\t\ttext: L.drawLocal.draw.handlers.polyline.tooltip.start\r\n\t\t\t};\r\n\t\t} else {\r\n\t\t\tdistanceStr = showLength ? this._getMeasurementString() : '';\r\n\r\n\t\t\tif (this._markers.length === 1) {\r\n\t\t\t\tlabelText = {\r\n\t\t\t\t\ttext: L.drawLocal.draw.handlers.polyline.tooltip.cont,\r\n\t\t\t\t\tsubtext: distanceStr\r\n\t\t\t\t};\r\n\t\t\t} else {\r\n\t\t\t\tlabelText = {\r\n\t\t\t\t\ttext: L.drawLocal.draw.handlers.polyline.tooltip.end,\r\n\t\t\t\t\tsubtext: distanceStr\r\n\t\t\t\t};\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn labelText;\r\n\t},\r\n\r\n\t_updateRunningMeasure: function (latlng, added) {\r\n\t\tvar markersLength = this._markers.length,\r\n\t\t\tpreviousMarkerIndex, distance;\r\n\r\n\t\tif (this._markers.length === 1) {\r\n\t\t\tthis._measurementRunningTotal = 0;\r\n\t\t} else {\r\n\t\t\tpreviousMarkerIndex = markersLength - (added ? 2 : 1);\r\n\r\n\t\t\t// Calculate the distance based on the version\r\n\t\t\tif (L.GeometryUtil.isVersion07x()) {\r\n\t\t\t\tdistance = latlng.distanceTo(this._markers[previousMarkerIndex].getLatLng()) * (this.options.factor || 1);\r\n\t\t\t} else {\r\n\t\t\t\tdistance = this._map.distance(latlng, this._markers[previousMarkerIndex].getLatLng()) * (this.options.factor || 1);\r\n\t\t\t}\r\n\r\n\t\t\tthis._measurementRunningTotal += distance * (added ? 1 : -1);\r\n\t\t}\r\n\t},\r\n\r\n\t_getMeasurementString: function () {\r\n\t\tvar currentLatLng = this._currentLatLng,\r\n\t\t\tpreviousLatLng = this._markers[this._markers.length - 1].getLatLng(),\r\n\t\t\tdistance;\r\n\r\n\t\t// Calculate the distance from the last fixed point to the mouse position based on the version\r\n\t\tif (L.GeometryUtil.isVersion07x()) {\r\n\t\t\tdistance = previousLatLng && currentLatLng && currentLatLng.distanceTo ? this._measurementRunningTotal + currentLatLng.distanceTo(previousLatLng) * (this.options.factor || 1) : this._measurementRunningTotal || 0;\r\n\t\t} else {\r\n\t\t\tdistance = previousLatLng && currentLatLng ? this._measurementRunningTotal + this._map.distance(currentLatLng, previousLatLng) * (this.options.factor || 1) : this._measurementRunningTotal || 0;\r\n\t\t}\r\n\r\n\t\treturn L.GeometryUtil.readableDistance(distance, this.options.metric, this.options.feet, this.options.nautic, this.options.precision);\r\n\t},\r\n\r\n\t_showErrorTooltip: function () {\r\n\t\tthis._errorShown = true;\r\n\r\n\t\t// Update tooltip\r\n\t\tthis._tooltip\r\n\t\t\t.showAsError()\r\n\t\t\t.updateContent({text: this.options.drawError.message});\r\n\r\n\t\t// Update shape\r\n\t\tthis._updateGuideColor(this.options.drawError.color);\r\n\t\tthis._poly.setStyle({color: this.options.drawError.color});\r\n\r\n\t\t// Hide the error after 2 seconds\r\n\t\tthis._clearHideErrorTimeout();\r\n\t\tthis._hideErrorTimeout = setTimeout(L.Util.bind(this._hideErrorTooltip, this), this.options.drawError.timeout);\r\n\t},\r\n\r\n\t_hideErrorTooltip: function () {\r\n\t\tthis._errorShown = false;\r\n\r\n\t\tthis._clearHideErrorTimeout();\r\n\r\n\t\t// Revert tooltip\r\n\t\tthis._tooltip\r\n\t\t\t.removeError()\r\n\t\t\t.updateContent(this._getTooltipText());\r\n\r\n\t\t// Revert shape\r\n\t\tthis._updateGuideColor(this.options.shapeOptions.color);\r\n\t\tthis._poly.setStyle({color: this.options.shapeOptions.color});\r\n\t},\r\n\r\n\t_clearHideErrorTimeout: function () {\r\n\t\tif (this._hideErrorTimeout) {\r\n\t\t\tclearTimeout(this._hideErrorTimeout);\r\n\t\t\tthis._hideErrorTimeout = null;\r\n\t\t}\r\n\t},\r\n\r\n\t// disable new markers temporarily;\r\n\t// this is to prevent duplicated touch/click events in some browsers\r\n\t_disableNewMarkers: function () {\r\n\t\tthis._disableMarkers = true;\r\n\t},\r\n\r\n\t// see _disableNewMarkers\r\n\t_enableNewMarkers: function () {\r\n\t\tsetTimeout(function () {\r\n\t\t\tthis._disableMarkers = false;\r\n\t\t}.bind(this), 50);\r\n\t},\r\n\r\n\t_cleanUpShape: function () {\r\n\t\tif (this._markers.length > 1) {\r\n\t\t\tthis._markers[this._markers.length - 1].off('click', this._finishShape, this);\r\n\t\t}\r\n\t},\r\n\r\n\t_fireCreatedEvent: function () {\r\n\t\tvar poly = new this.Poly(this._poly.getLatLngs(), this.options.shapeOptions);\r\n\t\tL.Draw.Feature.prototype._fireCreatedEvent.call(this, poly);\r\n\t}\r\n});\r\n","/**\r\n * @class L.Draw.Polygon\r\n * @aka Draw.Polygon\r\n * @inherits L.Draw.Polyline\r\n */\r\nL.Draw.Polygon = L.Draw.Polyline.extend({\r\n\tstatics: {\r\n\t\tTYPE: 'polygon'\r\n\t},\r\n\r\n\tPoly: L.Polygon,\r\n\r\n\toptions: {\r\n\t\tshowArea: false,\r\n\t\tshowLength: false,\r\n\t\tshapeOptions: {\r\n\t\t\tstroke: true,\r\n\t\t\tcolor: '#3388ff',\r\n\t\t\tweight: 4,\r\n\t\t\topacity: 0.5,\r\n\t\t\tfill: true,\r\n\t\t\tfillColor: null, //same as color by default\r\n\t\t\tfillOpacity: 0.2,\r\n\t\t\tclickable: true\r\n\t\t},\r\n\t\t// Whether to use the metric measurement system (truthy) or not (falsy).\r\n\t\t// Also defines the units to use for the metric system as an array of\r\n\t\t// strings (e.g. `['ha', 'm']`).\r\n\t\tmetric: true,\r\n\t\tfeet: true, // When not metric, to use feet instead of yards for display.\r\n\t\tnautic: false, // When not metric, not feet use nautic mile for display\r\n\t\t// Defines the precision for each type of unit (e.g. {km: 2, ft: 0}\r\n\t\tprecision: {}\r\n\t},\r\n\r\n\t// @method initialize(): void\r\n\tinitialize: function (map, options) {\r\n\t\tL.Draw.Polyline.prototype.initialize.call(this, map, options);\r\n\r\n\t\t// Save the type so super can fire, need to do this as cannot do this.TYPE :(\r\n\t\tthis.type = L.Draw.Polygon.TYPE;\r\n\t},\r\n\r\n\t_updateFinishHandler: function () {\r\n\t\tvar markerCount = this._markers.length;\r\n\r\n\t\t// The first marker should have a click handler to close the polygon\r\n\t\tif (markerCount === 1) {\r\n\t\t\tthis._markers[0].on('click', this._finishShape, this);\r\n\t\t}\r\n\r\n\t\t// Add and update the double click handler\r\n\t\tif (markerCount > 2) {\r\n\t\t\tthis._markers[markerCount - 1].on('dblclick', this._finishShape, this);\r\n\t\t\t// Only need to remove handler if has been added before\r\n\t\t\tif (markerCount > 3) {\r\n\t\t\t\tthis._markers[markerCount - 2].off('dblclick', this._finishShape, this);\r\n\t\t\t}\r\n\t\t}\r\n\t},\r\n\r\n\t_getTooltipText: function () {\r\n\t\tvar text, subtext;\r\n\r\n\t\tif (this._markers.length === 0) {\r\n\t\t\ttext = L.drawLocal.draw.handlers.polygon.tooltip.start;\r\n\t\t} else if (this._markers.length < 3) {\r\n\t\t\ttext = L.drawLocal.draw.handlers.polygon.tooltip.cont;\r\n\t\t\tsubtext = this._getMeasurementString();\r\n\t\t} else {\r\n\t\t\ttext = L.drawLocal.draw.handlers.polygon.tooltip.end;\r\n\t\t\tsubtext = this._getMeasurementString();\r\n\t\t}\r\n\r\n\t\treturn {\r\n\t\t\ttext: text,\r\n\t\t\tsubtext: subtext\r\n\t\t};\r\n\t},\r\n\r\n\t_getMeasurementString: function () {\r\n\t\tvar area = this._area,\r\n\t\t\tmeasurementString = '';\r\n\r\n\r\n\t\tif (!area && !this.options.showLength) {\r\n\t\t\treturn null;\r\n\t\t}\r\n\r\n\t\tif (this.options.showLength) {\r\n\t\t\tmeasurementString = L.Draw.Polyline.prototype._getMeasurementString.call(this);\r\n\t\t}\r\n\r\n\t\tif (area) {\r\n\t\t\tmeasurementString += '
' + L.GeometryUtil.readableArea(area, this.options.metric, this.options.precision);\r\n\t\t}\r\n\r\n\t\treturn measurementString;\r\n\t},\r\n\r\n\t_shapeIsValid: function () {\r\n\t\treturn this._markers.length >= 3;\r\n\t},\r\n\r\n\t_vertexChanged: function (latlng, added) {\r\n\t\tvar latLngs;\r\n\r\n\t\t// Check to see if we should show the area\r\n\t\tif (!this.options.allowIntersection && this.options.showArea) {\r\n\t\t\tlatLngs = this._poly.getLatLngs();\r\n\r\n\t\t\tthis._area = L.GeometryUtil.geodesicArea(latLngs);\r\n\t\t}\r\n\r\n\t\tL.Draw.Polyline.prototype._vertexChanged.call(this, latlng, added);\r\n\t},\r\n\r\n\t_cleanUpShape: function () {\r\n\t\tvar markerCount = this._markers.length;\r\n\r\n\t\tif (markerCount > 0) {\r\n\t\t\tthis._markers[0].off('click', this._finishShape, this);\r\n\r\n\t\t\tif (markerCount > 2) {\r\n\t\t\t\tthis._markers[markerCount - 1].off('dblclick', this._finishShape, this);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n});\r\n","L.SimpleShape = {};\r\n/**\r\n * @class L.Draw.SimpleShape\r\n * @aka Draw.SimpleShape\r\n * @inherits L.Draw.Feature\r\n */\r\nL.Draw.SimpleShape = L.Draw.Feature.extend({\r\n\toptions: {\r\n\t\trepeatMode: false\r\n\t},\r\n\r\n\t// @method initialize(): void\r\n\tinitialize: function (map, options) {\r\n\t\tthis._endLabelText = L.drawLocal.draw.handlers.simpleshape.tooltip.end;\r\n\r\n\t\tL.Draw.Feature.prototype.initialize.call(this, map, options);\r\n\t},\r\n\r\n\t// @method addHooks(): void\r\n\t// Add listener hooks to this handler.\r\n\taddHooks: function () {\r\n\t\tL.Draw.Feature.prototype.addHooks.call(this);\r\n\t\tif (this._map) {\r\n\t\t\tthis._mapDraggable = this._map.dragging.enabled();\r\n\r\n\t\t\tif (this._mapDraggable) {\r\n\t\t\t\tthis._map.dragging.disable();\r\n\t\t\t}\r\n\r\n\t\t\t//TODO refactor: move cursor to styles\r\n\t\t\tthis._container.style.cursor = 'crosshair';\r\n\r\n\t\t\tthis._tooltip.updateContent({text: this._initialLabelText});\r\n\r\n\t\t\tthis._map\r\n\t\t\t\t.on('mousedown', this._onMouseDown, this)\r\n\t\t\t\t.on('mousemove', this._onMouseMove, this)\r\n\t\t\t\t.on('touchstart', this._onMouseDown, this)\r\n\t\t\t\t.on('touchmove', this._onMouseMove, this);\r\n\r\n\t\t\t// we should prevent default, otherwise default behavior (scrolling) will fire,\r\n\t\t\t// and that will cause document.touchend to fire and will stop the drawing\r\n\t\t\t// (circle, rectangle) in touch mode.\r\n\t\t\t// (update): we have to send passive now to prevent scroll, because by default it is {passive: true} now, which means,\r\n\t\t\t// handler can't event.preventDefault\r\n\t\t\t// check the news https://developers.google.com/web/updates/2016/06/passive-event-listeners\r\n\t\t\tdocument.addEventListener('touchstart', L.DomEvent.preventDefault, {passive: false});\r\n\t\t}\r\n\t},\r\n\r\n\t// @method removeHooks(): void\r\n\t// Remove listener hooks from this handler.\r\n\tremoveHooks: function () {\r\n\t\tL.Draw.Feature.prototype.removeHooks.call(this);\r\n\t\tif (this._map) {\r\n\t\t\tif (this._mapDraggable) {\r\n\t\t\t\tthis._map.dragging.enable();\r\n\t\t\t}\r\n\r\n\t\t\t//TODO refactor: move cursor to styles\r\n\t\t\tthis._container.style.cursor = '';\r\n\r\n\t\t\tthis._map\r\n\t\t\t\t.off('mousedown', this._onMouseDown, this)\r\n\t\t\t\t.off('mousemove', this._onMouseMove, this)\r\n\t\t\t\t.off('touchstart', this._onMouseDown, this)\r\n\t\t\t\t.off('touchmove', this._onMouseMove, this);\r\n\r\n\t\t\tL.DomEvent.off(document, 'mouseup', this._onMouseUp, this);\r\n\t\t\tL.DomEvent.off(document, 'touchend', this._onMouseUp, this);\r\n\r\n\t\t\tdocument.removeEventListener('touchstart', L.DomEvent.preventDefault);\r\n\r\n\t\t\t// If the box element doesn't exist they must not have moved the mouse, so don't need to destroy/return\r\n\t\t\tif (this._shape) {\r\n\t\t\t\tthis._map.removeLayer(this._shape);\r\n\t\t\t\tdelete this._shape;\r\n\t\t\t}\r\n\t\t}\r\n\t\tthis._isDrawing = false;\r\n\t},\r\n\r\n\t_getTooltipText: function () {\r\n\t\treturn {\r\n\t\t\ttext: this._endLabelText\r\n\t\t};\r\n\t},\r\n\r\n\t_onMouseDown: function (e) {\r\n\t\tthis._isDrawing = true;\r\n\t\tthis._startLatLng = e.latlng;\r\n\r\n\t\tL.DomEvent\r\n\t\t\t.on(document, 'mouseup', this._onMouseUp, this)\r\n\t\t\t.on(document, 'touchend', this._onMouseUp, this)\r\n\t\t\t.preventDefault(e.originalEvent);\r\n\t},\r\n\r\n\t_onMouseMove: function (e) {\r\n\t\tvar latlng = e.latlng;\r\n\r\n\t\tthis._tooltip.updatePosition(latlng);\r\n\t\tif (this._isDrawing) {\r\n\t\t\tthis._tooltip.updateContent(this._getTooltipText());\r\n\t\t\tthis._drawShape(latlng);\r\n\t\t}\r\n\t},\r\n\r\n\t_onMouseUp: function () {\r\n\t\tif (this._shape) {\r\n\t\t\tthis._fireCreatedEvent();\r\n\t\t}\r\n\r\n\t\tthis.disable();\r\n\t\tif (this.options.repeatMode) {\r\n\t\t\tthis.enable();\r\n\t\t}\r\n\t}\r\n});\r\n","/**\r\n * @class L.Draw.Rectangle\r\n * @aka Draw.Rectangle\r\n * @inherits L.Draw.SimpleShape\r\n */\r\nL.Draw.Rectangle = L.Draw.SimpleShape.extend({\r\n\tstatics: {\r\n\t\tTYPE: 'rectangle'\r\n\t},\r\n\r\n\toptions: {\r\n\t\tshapeOptions: {\r\n\t\t\tstroke: true,\r\n\t\t\tcolor: '#3388ff',\r\n\t\t\tweight: 4,\r\n\t\t\topacity: 0.5,\r\n\t\t\tfill: true,\r\n\t\t\tfillColor: null, //same as color by default\r\n\t\t\tfillOpacity: 0.2,\r\n\t\t\tclickable: true\r\n\t\t},\r\n\t\tshowArea: true, //Whether to show the area in the tooltip\r\n\t\tmetric: true // Whether to use the metric measurement system or imperial\r\n\t},\r\n\r\n\t// @method initialize(): void\r\n\tinitialize: function (map, options) {\r\n\t\t// Save the type so super can fire, need to do this as cannot do this.TYPE :(\r\n\t\tthis.type = L.Draw.Rectangle.TYPE;\r\n\r\n\t\tthis._initialLabelText = L.drawLocal.draw.handlers.rectangle.tooltip.start;\r\n\r\n\t\tL.Draw.SimpleShape.prototype.initialize.call(this, map, options);\r\n\t},\r\n\r\n\t// @method disable(): void\r\n\tdisable: function () {\r\n\t\tif (!this._enabled) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tthis._isCurrentlyTwoClickDrawing = false;\r\n\t\tL.Draw.SimpleShape.prototype.disable.call(this);\r\n\t},\r\n\r\n\t_onMouseUp: function (e) {\r\n\t\tif (!this._shape && !this._isCurrentlyTwoClickDrawing) {\r\n\t\t\tthis._isCurrentlyTwoClickDrawing = true;\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\t// Make sure closing click is on map\r\n\t\tif (this._isCurrentlyTwoClickDrawing && !_hasAncestor(e.target, 'leaflet-pane')) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tL.Draw.SimpleShape.prototype._onMouseUp.call(this);\r\n\t},\r\n\r\n\t_drawShape: function (latlng) {\r\n\t\tif (!this._shape) {\r\n\t\t\tthis._shape = new L.Rectangle(new L.LatLngBounds(this._startLatLng, latlng), this.options.shapeOptions);\r\n\t\t\tthis._map.addLayer(this._shape);\r\n\t\t} else {\r\n\t\t\tthis._shape.setBounds(new L.LatLngBounds(this._startLatLng, latlng));\r\n\t\t}\r\n\t},\r\n\r\n\t_fireCreatedEvent: function () {\r\n\t\tvar rectangle = new L.Rectangle(this._shape.getBounds(), this.options.shapeOptions);\r\n\t\tL.Draw.SimpleShape.prototype._fireCreatedEvent.call(this, rectangle);\r\n\t},\r\n\r\n\t_getTooltipText: function () {\r\n\t\tvar tooltipText = L.Draw.SimpleShape.prototype._getTooltipText.call(this),\r\n\t\t\tshape = this._shape,\r\n\t\t\tshowArea = this.options.showArea,\r\n\t\t\tlatLngs, area, subtext;\r\n\r\n\t\tif (shape) {\r\n\t\t\tlatLngs = this._shape._defaultShape ? this._shape._defaultShape() : this._shape.getLatLngs();\r\n\t\t\tarea = L.GeometryUtil.geodesicArea(latLngs);\r\n\t\t\tsubtext = showArea ? L.GeometryUtil.readableArea(area, this.options.metric) : '';\r\n\t\t}\r\n\r\n\t\treturn {\r\n\t\t\ttext: tooltipText.text,\r\n\t\t\tsubtext: subtext\r\n\t\t};\r\n\t}\r\n});\r\n\r\nfunction _hasAncestor(el, cls) {\r\n\twhile ((el = el.parentElement) && !el.classList.contains(cls)) {\r\n\t\t;\r\n\t}\r\n\treturn el;\r\n}\r\n","/**\r\n * @class L.Draw.Marker\r\n * @aka Draw.Marker\r\n * @inherits L.Draw.Feature\r\n */\r\nL.Draw.Marker = L.Draw.Feature.extend({\r\n\tstatics: {\r\n\t\tTYPE: 'marker'\r\n\t},\r\n\r\n\toptions: {\r\n\t\ticon: new L.Icon.Default(),\r\n\t\trepeatMode: false,\r\n\t\tzIndexOffset: 2000 // This should be > than the highest z-index any markers\r\n\t},\r\n\r\n\t// @method initialize(): void\r\n\tinitialize: function (map, options) {\r\n\t\t// Save the type so super can fire, need to do this as cannot do this.TYPE :(\r\n\t\tthis.type = L.Draw.Marker.TYPE;\r\n\r\n\t\tthis._initialLabelText = L.drawLocal.draw.handlers.marker.tooltip.start;\r\n\r\n\t\tL.Draw.Feature.prototype.initialize.call(this, map, options);\r\n\t},\r\n\r\n\t// @method addHooks(): void\r\n\t// Add listener hooks to this handler.\r\n\taddHooks: function () {\r\n\t\tL.Draw.Feature.prototype.addHooks.call(this);\r\n\r\n\t\tif (this._map) {\r\n\t\t\tthis._tooltip.updateContent({text: this._initialLabelText});\r\n\r\n\t\t\t// Same mouseMarker as in Draw.Polyline\r\n\t\t\tif (!this._mouseMarker) {\r\n\t\t\t\tthis._mouseMarker = L.marker(this._map.getCenter(), {\r\n\t\t\t\t\ticon: L.divIcon({\r\n\t\t\t\t\t\tclassName: 'leaflet-mouse-marker',\r\n\t\t\t\t\t\ticonAnchor: [20, 20],\r\n\t\t\t\t\t\ticonSize: [40, 40]\r\n\t\t\t\t\t}),\r\n\t\t\t\t\topacity: 0,\r\n\t\t\t\t\tzIndexOffset: this.options.zIndexOffset\r\n\t\t\t\t});\r\n\t\t\t}\r\n\r\n\t\t\tthis._mouseMarker\r\n\t\t\t\t.on('click', this._onClick, this)\r\n\t\t\t\t.addTo(this._map);\r\n\r\n\t\t\tthis._map.on('mousemove', this._onMouseMove, this);\r\n\t\t\tthis._map.on('click', this._onTouch, this);\r\n\t\t}\r\n\t},\r\n\r\n\t// @method removeHooks(): void\r\n\t// Remove listener hooks from this handler.\r\n\tremoveHooks: function () {\r\n\t\tL.Draw.Feature.prototype.removeHooks.call(this);\r\n\r\n\t\tif (this._map) {\r\n\t\t\tthis._map\r\n\t\t\t\t.off('click', this._onClick, this)\r\n\t\t\t\t.off('click', this._onTouch, this);\r\n\t\t\tif (this._marker) {\r\n\t\t\t\tthis._marker.off('click', this._onClick, this);\r\n\t\t\t\tthis._map\r\n\t\t\t\t\t.removeLayer(this._marker);\r\n\t\t\t\tdelete this._marker;\r\n\t\t\t}\r\n\r\n\t\t\tthis._mouseMarker.off('click', this._onClick, this);\r\n\t\t\tthis._map.removeLayer(this._mouseMarker);\r\n\t\t\tdelete this._mouseMarker;\r\n\r\n\t\t\tthis._map.off('mousemove', this._onMouseMove, this);\r\n\t\t}\r\n\t},\r\n\r\n\t_onMouseMove: function (e) {\r\n\t\tvar latlng = e.latlng;\r\n\r\n\t\tthis._tooltip.updatePosition(latlng);\r\n\t\tthis._mouseMarker.setLatLng(latlng);\r\n\r\n\t\tif (!this._marker) {\r\n\t\t\tthis._marker = this._createMarker(latlng);\r\n\t\t\t// Bind to both marker and map to make sure we get the click event.\r\n\t\t\tthis._marker.on('click', this._onClick, this);\r\n\t\t\tthis._map\r\n\t\t\t\t.on('click', this._onClick, this)\r\n\t\t\t\t.addLayer(this._marker);\r\n\t\t}\r\n\t\telse {\r\n\t\t\tlatlng = this._mouseMarker.getLatLng();\r\n\t\t\tthis._marker.setLatLng(latlng);\r\n\t\t}\r\n\t},\r\n\r\n\t_createMarker: function (latlng) {\r\n\t\treturn new L.Marker(latlng, {\r\n\t\t\ticon: this.options.icon,\r\n\t\t\tzIndexOffset: this.options.zIndexOffset\r\n\t\t});\r\n\t},\r\n\r\n\t_onClick: function () {\r\n\t\tthis._fireCreatedEvent();\r\n\r\n\t\tthis.disable();\r\n\t\tif (this.options.repeatMode) {\r\n\t\t\tthis.enable();\r\n\t\t}\r\n\t},\r\n\r\n\t_onTouch: function (e) {\r\n\t\t// called on click & tap, only really does any thing on tap\r\n\t\tthis._onMouseMove(e); // creates & places marker\r\n\t\tthis._onClick(); // permanently places marker & ends interaction\r\n\t},\r\n\r\n\t_fireCreatedEvent: function () {\r\n\t\tvar marker = new L.Marker.Touch(this._marker.getLatLng(), {icon: this.options.icon});\r\n\t\tL.Draw.Feature.prototype._fireCreatedEvent.call(this, marker);\r\n\t}\r\n});\r\n","/**\r\n * @class L.Draw.CircleMarker\r\n * @aka Draw.CircleMarker\r\n * @inherits L.Draw.Marker\r\n */\r\nL.Draw.CircleMarker = L.Draw.Marker.extend({\r\n\tstatics: {\r\n\t\tTYPE: 'circlemarker'\r\n\t},\r\n\r\n\toptions: {\r\n\t\tstroke: true,\r\n\t\tcolor: '#3388ff',\r\n\t\tweight: 4,\r\n\t\topacity: 0.5,\r\n\t\tfill: true,\r\n\t\tfillColor: null, //same as color by default\r\n\t\tfillOpacity: 0.2,\r\n\t\tclickable: true,\r\n\t\tzIndexOffset: 2000 // This should be > than the highest z-index any markers\r\n\t},\r\n\r\n\t// @method initialize(): void\r\n\tinitialize: function (map, options) {\r\n\t\t// Save the type so super can fire, need to do this as cannot do this.TYPE :(\r\n\t\tthis.type = L.Draw.CircleMarker.TYPE;\r\n\r\n\t\tthis._initialLabelText = L.drawLocal.draw.handlers.circlemarker.tooltip.start;\r\n\r\n\t\tL.Draw.Feature.prototype.initialize.call(this, map, options);\r\n\t},\r\n\r\n\r\n\t_fireCreatedEvent: function () {\r\n\t\tvar circleMarker = new L.CircleMarker(this._marker.getLatLng(), this.options);\r\n\t\tL.Draw.Feature.prototype._fireCreatedEvent.call(this, circleMarker);\r\n\t},\r\n\r\n\t_createMarker: function (latlng) {\r\n\t\treturn new L.CircleMarker(latlng, this.options);\r\n\t}\r\n});\r\n","/**\r\n * @class L.Draw.Circle\r\n * @aka Draw.Circle\r\n * @inherits L.Draw.SimpleShape\r\n */\r\nL.Draw.Circle = L.Draw.SimpleShape.extend({\r\n\tstatics: {\r\n\t\tTYPE: 'circle'\r\n\t},\r\n\r\n\toptions: {\r\n\t\tshapeOptions: {\r\n\t\t\tstroke: true,\r\n\t\t\tcolor: '#3388ff',\r\n\t\t\tweight: 4,\r\n\t\t\topacity: 0.5,\r\n\t\t\tfill: true,\r\n\t\t\tfillColor: null, //same as color by default\r\n\t\t\tfillOpacity: 0.2,\r\n\t\t\tclickable: true\r\n\t\t},\r\n\t\tshowRadius: true,\r\n\t\tmetric: true, // Whether to use the metric measurement system or imperial\r\n\t\tfeet: true, // When not metric, use feet instead of yards for display\r\n\t\tnautic: false // When not metric, not feet use nautic mile for display\r\n\t},\r\n\r\n\t// @method initialize(): void\r\n\tinitialize: function (map, options) {\r\n\t\t// Save the type so super can fire, need to do this as cannot do this.TYPE :(\r\n\t\tthis.type = L.Draw.Circle.TYPE;\r\n\r\n\t\tthis._initialLabelText = L.drawLocal.draw.handlers.circle.tooltip.start;\r\n\r\n\t\tL.Draw.SimpleShape.prototype.initialize.call(this, map, options);\r\n\t},\r\n\r\n\t_drawShape: function (latlng) {\r\n\t\t// Calculate the distance based on the version\r\n\t\tif (L.GeometryUtil.isVersion07x()) {\r\n\t\t\tvar distance = this._startLatLng.distanceTo(latlng);\r\n\t\t} else {\r\n\t\t\tvar distance = this._map.distance(this._startLatLng, latlng);\r\n\t\t}\r\n\r\n\t\tif (!this._shape) {\r\n\t\t\tthis._shape = new L.Circle(this._startLatLng, distance, this.options.shapeOptions);\r\n\t\t\tthis._map.addLayer(this._shape);\r\n\t\t} else {\r\n\t\t\tthis._shape.setRadius(distance);\r\n\t\t}\r\n\t},\r\n\r\n\t_fireCreatedEvent: function () {\r\n\t\tvar circle = new L.Circle(this._startLatLng, this._shape.getRadius(), this.options.shapeOptions);\r\n\t\tL.Draw.SimpleShape.prototype._fireCreatedEvent.call(this, circle);\r\n\t},\r\n\r\n\t_onMouseMove: function (e) {\r\n\t\tvar latlng = e.latlng,\r\n\t\t\tshowRadius = this.options.showRadius,\r\n\t\t\tuseMetric = this.options.metric,\r\n\t\t\tradius;\r\n\r\n\t\tthis._tooltip.updatePosition(latlng);\r\n\t\tif (this._isDrawing) {\r\n\t\t\tthis._drawShape(latlng);\r\n\r\n\t\t\t// Get the new radius (rounded to 1 dp)\r\n\t\t\tradius = this._shape.getRadius().toFixed(1);\r\n\r\n\t\t\tvar subtext = '';\r\n\t\t\tif (showRadius) {\r\n\t\t\t\tsubtext = L.drawLocal.draw.handlers.circle.radius + ': ' +\r\n\t\t\t\t\tL.GeometryUtil.readableDistance(radius, useMetric, this.options.feet, this.options.nautic);\r\n\t\t\t}\r\n\t\t\tthis._tooltip.updateContent({\r\n\t\t\t\ttext: this._endLabelText,\r\n\t\t\t\tsubtext: subtext\r\n\t\t\t});\r\n\t\t}\r\n\t}\r\n});\r\n","L.Edit = L.Edit || {};\r\n\r\n/**\r\n * @class L.Edit.Marker\r\n * @aka Edit.Marker\r\n */\r\nL.Edit.Marker = L.Handler.extend({\r\n\t// @method initialize(): void\r\n\tinitialize: function (marker, options) {\r\n\t\tthis._marker = marker;\r\n\t\tL.setOptions(this, options);\r\n\t},\r\n\r\n\t// @method addHooks(): void\r\n\t// Add listener hooks to this handler\r\n\taddHooks: function () {\r\n\t\tvar marker = this._marker;\r\n\r\n\t\tmarker.dragging.enable();\r\n\t\tmarker.on('dragend', this._onDragEnd, marker);\r\n\t\tthis._toggleMarkerHighlight();\r\n\t},\r\n\r\n\t// @method removeHooks(): void\r\n\t// Remove listener hooks from this handler\r\n\tremoveHooks: function () {\r\n\t\tvar marker = this._marker;\r\n\r\n\t\tmarker.dragging.disable();\r\n\t\tmarker.off('dragend', this._onDragEnd, marker);\r\n\t\tthis._toggleMarkerHighlight();\r\n\t},\r\n\r\n\t_onDragEnd: function (e) {\r\n\t\tvar layer = e.target;\r\n\t\tlayer.edited = true;\r\n\t\tthis._map.fire(L.Draw.Event.EDITMOVE, {layer: layer});\r\n\t},\r\n\r\n\t_toggleMarkerHighlight: function () {\r\n\t\tvar icon = this._marker._icon;\r\n\r\n\t\t// Don't do anything if this layer is a marker but doesn't have an icon. Markers\r\n\t\t// should usually have icons. If using Leaflet.draw with Leaflet.markercluster there\r\n\t\t// is a chance that a marker doesn't.\r\n\t\tif (!icon) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\t// This is quite naughty, but I don't see another way of doing it. (short of setting a new icon)\r\n\t\ticon.style.display = 'none';\r\n\r\n\t\tif (L.DomUtil.hasClass(icon, 'leaflet-edit-marker-selected')) {\r\n\t\t\tL.DomUtil.removeClass(icon, 'leaflet-edit-marker-selected');\r\n\t\t\t// Offset as the border will make the icon move.\r\n\t\t\tthis._offsetMarker(icon, -4);\r\n\r\n\t\t} else {\r\n\t\t\tL.DomUtil.addClass(icon, 'leaflet-edit-marker-selected');\r\n\t\t\t// Offset as the border will make the icon move.\r\n\t\t\tthis._offsetMarker(icon, 4);\r\n\t\t}\r\n\r\n\t\ticon.style.display = '';\r\n\t},\r\n\r\n\t_offsetMarker: function (icon, offset) {\r\n\t\tvar iconMarginTop = parseInt(icon.style.marginTop, 10) - offset,\r\n\t\t\ticonMarginLeft = parseInt(icon.style.marginLeft, 10) - offset;\r\n\r\n\t\ticon.style.marginTop = iconMarginTop + 'px';\r\n\t\ticon.style.marginLeft = iconMarginLeft + 'px';\r\n\t}\r\n});\r\n\r\nL.Marker.addInitHook(function () {\r\n\tif (L.Edit.Marker) {\r\n\t\tthis.editing = new L.Edit.Marker(this);\r\n\r\n\t\tif (this.options.editable) {\r\n\t\t\tthis.editing.enable();\r\n\t\t}\r\n\t}\r\n});\r\n","L.Edit = L.Edit || {};\r\n\r\n/**\r\n * @class L.Edit.Polyline\r\n * @aka L.Edit.Poly\r\n * @aka Edit.Poly\r\n */\r\nL.Edit.Poly = L.Handler.extend({\r\n\t// @method initialize(): void\r\n\tinitialize: function (poly) {\r\n\r\n\t\tthis.latlngs = [poly._latlngs];\r\n\t\tif (poly._holes) {\r\n\t\t\tthis.latlngs = this.latlngs.concat(poly._holes);\r\n\t\t}\r\n\r\n\t\tthis._poly = poly;\r\n\r\n\t\tthis._poly.on('revert-edited', this._updateLatLngs, this);\r\n\t},\r\n\r\n\t// Compatibility method to normalize Poly* objects\r\n\t// between 0.7.x and 1.0+\r\n\t_defaultShape: function () {\r\n\t\tif (!L.Polyline._flat) {\r\n\t\t\treturn this._poly._latlngs;\r\n\t\t}\r\n\t\treturn L.Polyline._flat(this._poly._latlngs) ? this._poly._latlngs : this._poly._latlngs[0];\r\n\t},\r\n\r\n\t_eachVertexHandler: function (callback) {\r\n\t\tfor (var i = 0; i < this._verticesHandlers.length; i++) {\r\n\t\t\tcallback(this._verticesHandlers[i]);\r\n\t\t}\r\n\t},\r\n\r\n\t// @method addHooks(): void\r\n\t// Add listener hooks to this handler\r\n\taddHooks: function () {\r\n\t\tthis._initHandlers();\r\n\t\tthis._eachVertexHandler(function (handler) {\r\n\t\t\thandler.addHooks();\r\n\t\t});\r\n\t},\r\n\r\n\t// @method removeHooks(): void\r\n\t// Remove listener hooks from this handler\r\n\tremoveHooks: function () {\r\n\t\tthis._eachVertexHandler(function (handler) {\r\n\t\t\thandler.removeHooks();\r\n\t\t});\r\n\t},\r\n\r\n\t// @method updateMarkers(): void\r\n\t// Fire an update for each vertex handler\r\n\tupdateMarkers: function () {\r\n\t\tthis._eachVertexHandler(function (handler) {\r\n\t\t\thandler.updateMarkers();\r\n\t\t});\r\n\t},\r\n\r\n\t_initHandlers: function () {\r\n\t\tthis._verticesHandlers = [];\r\n\t\tfor (var i = 0; i < this.latlngs.length; i++) {\r\n\t\t\tthis._verticesHandlers.push(new L.Edit.PolyVerticesEdit(this._poly, this.latlngs[i], this._poly.options.poly));\r\n\t\t}\r\n\t},\r\n\r\n\t_updateLatLngs: function (e) {\r\n\t\tthis.latlngs = [e.layer._latlngs];\r\n\t\tif (e.layer._holes) {\r\n\t\t\tthis.latlngs = this.latlngs.concat(e.layer._holes);\r\n\t\t}\r\n\t}\r\n\r\n});\r\n\r\n/**\r\n * @class L.Edit.PolyVerticesEdit\r\n * @aka Edit.PolyVerticesEdit\r\n */\r\nL.Edit.PolyVerticesEdit = L.Handler.extend({\r\n\toptions: {\r\n\t\ticon: new L.DivIcon({\r\n\t\t\ticonSize: new L.Point(8, 8),\r\n\t\t\tclassName: 'leaflet-div-icon leaflet-editing-icon'\r\n\t\t}),\r\n\t\ttouchIcon: new L.DivIcon({\r\n\t\t\ticonSize: new L.Point(20, 20),\r\n\t\t\tclassName: 'leaflet-div-icon leaflet-editing-icon leaflet-touch-icon'\r\n\t\t}),\r\n\t\tdrawError: {\r\n\t\t\tcolor: '#b00b00',\r\n\t\t\ttimeout: 1000\r\n\t\t}\r\n\r\n\r\n\t},\r\n\r\n\t// @method intialize(): void\r\n\tinitialize: function (poly, latlngs, options) {\r\n\t\t// if touch, switch to touch icon\r\n\t\tif (L.Browser.touch) {\r\n\t\t\tthis.options.icon = this.options.touchIcon;\r\n\t\t}\r\n\t\tthis._poly = poly;\r\n\r\n\t\tif (options && options.drawError) {\r\n\t\t\toptions.drawError = L.Util.extend({}, this.options.drawError, options.drawError);\r\n\t\t}\r\n\r\n\t\tthis._latlngs = latlngs;\r\n\r\n\t\tL.setOptions(this, options);\r\n\t},\r\n\r\n\t// Compatibility method to normalize Poly* objects\r\n\t// between 0.7.x and 1.0+\r\n\t_defaultShape: function () {\r\n\t\tif (!L.Polyline._flat) {\r\n\t\t\treturn this._latlngs;\r\n\t\t}\r\n\t\treturn L.Polyline._flat(this._latlngs) ? this._latlngs : this._latlngs[0];\r\n\t},\r\n\r\n\t// @method addHooks(): void\r\n\t// Add listener hooks to this handler.\r\n\taddHooks: function () {\r\n\t\tvar poly = this._poly;\r\n\t\tvar path = poly._path;\r\n\r\n\t\tif (!(poly instanceof L.Polygon)) {\r\n\t\t\tpoly.options.fill = false;\r\n\t\t\tif (poly.options.editing) {\r\n\t\t\t\tpoly.options.editing.fill = false;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (path) {\r\n\t\t\tif (poly.options.editing && poly.options.editing.className) {\r\n\t\t\t\tif (poly.options.original.className) {\r\n\t\t\t\t\tpoly.options.original.className.split(' ').forEach(function (className) {\r\n\t\t\t\t\t\tL.DomUtil.removeClass(path, className);\r\n\t\t\t\t\t});\r\n\t\t\t\t}\r\n\t\t\t\tpoly.options.editing.className.split(' ').forEach(function (className) {\r\n\t\t\t\t\tL.DomUtil.addClass(path, className);\r\n\t\t\t\t});\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tpoly.setStyle(poly.options.editing);\r\n\r\n\t\tif (this._poly._map) {\r\n\r\n\t\t\tthis._map = this._poly._map; // Set map\r\n\r\n\t\t\tif (!this._markerGroup) {\r\n\t\t\t\tthis._initMarkers();\r\n\t\t\t}\r\n\t\t\tthis._poly._map.addLayer(this._markerGroup);\r\n\t\t}\r\n\t},\r\n\r\n\t// @method removeHooks(): void\r\n\t// Remove listener hooks from this handler.\r\n\tremoveHooks: function () {\r\n\t\tvar poly = this._poly;\r\n\t\tvar path = poly._path;\r\n\r\n\t\tif (path) {\r\n\t\t\tif (poly.options.editing && poly.options.editing.className) {\r\n\t\t\t\tpoly.options.editing.className.split(' ').forEach(function (className) {\r\n\t\t\t\t\tL.DomUtil.removeClass(path, className);\r\n\t\t\t\t});\r\n\t\t\t\tif (poly.options.original.className) {\r\n\t\t\t\t\tpoly.options.original.className.split(' ').forEach(function (className) {\r\n\t\t\t\t\t\tL.DomUtil.addClass(path, className);\r\n\t\t\t\t\t});\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tpoly.setStyle(poly.options.original);\r\n\r\n\t\tif (poly._map) {\r\n\t\t\tpoly._map.removeLayer(this._markerGroup);\r\n\t\t\tdelete this._markerGroup;\r\n\t\t\tdelete this._markers;\r\n\t\t}\r\n\t},\r\n\r\n\t// @method updateMarkers(): void\r\n\t// Clear markers and update their location\r\n\tupdateMarkers: function () {\r\n\t\tthis._markerGroup.clearLayers();\r\n\t\tthis._initMarkers();\r\n\t},\r\n\r\n\t_initMarkers: function () {\r\n\t\tif (!this._markerGroup) {\r\n\t\t\tthis._markerGroup = new L.LayerGroup();\r\n\t\t}\r\n\t\tthis._markers = [];\r\n\r\n\t\tvar latlngs = this._defaultShape(),\r\n\t\t\ti, j, len, marker;\r\n\r\n\t\tfor (i = 0, len = latlngs.length; i < len; i++) {\r\n\r\n\t\t\tmarker = this._createMarker(latlngs[i], i);\r\n\t\t\tmarker.on('click', this._onMarkerClick, this);\r\n\t\t\tmarker.on('contextmenu', this._onContextMenu, this);\r\n\t\t\tthis._markers.push(marker);\r\n\t\t}\r\n\r\n\t\tvar markerLeft, markerRight;\r\n\r\n\t\tfor (i = 0, j = len - 1; i < len; j = i++) {\r\n\t\t\tif (i === 0 && !(L.Polygon && (this._poly instanceof L.Polygon))) {\r\n\t\t\t\tcontinue;\r\n\t\t\t}\r\n\r\n\t\t\tmarkerLeft = this._markers[j];\r\n\t\t\tmarkerRight = this._markers[i];\r\n\r\n\t\t\tthis._createMiddleMarker(markerLeft, markerRight);\r\n\t\t\tthis._updatePrevNext(markerLeft, markerRight);\r\n\t\t}\r\n\t},\r\n\r\n\t_createMarker: function (latlng, index) {\r\n\t\t// Extending L.Marker in TouchEvents.js to include touch.\r\n\t\tvar marker = new L.Marker.Touch(latlng, {\r\n\t\t\tdraggable: true,\r\n\t\t\ticon: this.options.icon,\r\n\t\t});\r\n\r\n\t\tmarker._origLatLng = latlng;\r\n\t\tmarker._index = index;\r\n\r\n\t\tmarker\r\n\t\t\t.on('dragstart', this._onMarkerDragStart, this)\r\n\t\t\t.on('drag', this._onMarkerDrag, this)\r\n\t\t\t.on('dragend', this._fireEdit, this)\r\n\t\t\t.on('touchmove', this._onTouchMove, this)\r\n\t\t\t.on('touchend', this._fireEdit, this)\r\n\t\t\t.on('MSPointerMove', this._onTouchMove, this)\r\n\t\t\t.on('MSPointerUp', this._fireEdit, this);\r\n\r\n\t\tthis._markerGroup.addLayer(marker);\r\n\r\n\t\treturn marker;\r\n\t},\r\n\r\n\t_onMarkerDragStart: function () {\r\n\t\tthis._poly.fire('editstart');\r\n\t},\r\n\r\n\t_spliceLatLngs: function () {\r\n\t\tvar latlngs = this._defaultShape();\r\n\t\tvar removed = [].splice.apply(latlngs, arguments);\r\n\t\tthis._poly._convertLatLngs(latlngs, true);\r\n\t\tthis._poly.redraw();\r\n\t\treturn removed;\r\n\t},\r\n\r\n\t_removeMarker: function (marker) {\r\n\t\tvar i = marker._index;\r\n\r\n\t\tthis._markerGroup.removeLayer(marker);\r\n\t\tthis._markers.splice(i, 1);\r\n\t\tthis._spliceLatLngs(i, 1);\r\n\t\tthis._updateIndexes(i, -1);\r\n\r\n\t\tmarker\r\n\t\t\t.off('dragstart', this._onMarkerDragStart, this)\r\n\t\t\t.off('drag', this._onMarkerDrag, this)\r\n\t\t\t.off('dragend', this._fireEdit, this)\r\n\t\t\t.off('touchmove', this._onMarkerDrag, this)\r\n\t\t\t.off('touchend', this._fireEdit, this)\r\n\t\t\t.off('click', this._onMarkerClick, this)\r\n\t\t\t.off('MSPointerMove', this._onTouchMove, this)\r\n\t\t\t.off('MSPointerUp', this._fireEdit, this);\r\n\t},\r\n\r\n\t_fireEdit: function () {\r\n\t\tthis._poly.edited = true;\r\n\t\tthis._poly.fire('edit');\r\n\t\tthis._poly._map.fire(L.Draw.Event.EDITVERTEX, {layers: this._markerGroup, poly: this._poly});\r\n\t},\r\n\r\n\t_onMarkerDrag: function (e) {\r\n\t\tvar marker = e.target;\r\n\t\tvar poly = this._poly;\r\n\r\n\t\tvar oldOrigLatLng = L.LatLngUtil.cloneLatLng(marker._origLatLng);\r\n\t\tL.extend(marker._origLatLng, marker._latlng);\r\n\t\tif (poly.options.poly) {\r\n\t\t\tvar tooltip = poly._map._editTooltip; // Access the tooltip\r\n\r\n\t\t\t// If we don't allow intersections and the polygon intersects\r\n\t\t\tif (!poly.options.poly.allowIntersection && poly.intersects()) {\r\n\t\t\t\tL.extend(marker._origLatLng, oldOrigLatLng);\r\n\t\t\t\tmarker.setLatLng(oldOrigLatLng);\r\n\t\t\t\tvar originalColor = poly.options.color;\r\n\t\t\t\tpoly.setStyle({color: this.options.drawError.color});\r\n\t\t\t\tif (tooltip) {\r\n\t\t\t\t\ttooltip.updateContent({\r\n\t\t\t\t\t\ttext: L.drawLocal.draw.handlers.polyline.error\r\n\t\t\t\t\t});\r\n\t\t\t\t}\r\n\r\n\t\t\t\t// Reset everything back to normal after a second\r\n\t\t\t\tsetTimeout(function () {\r\n\t\t\t\t\tpoly.setStyle({color: originalColor});\r\n\t\t\t\t\tif (tooltip) {\r\n\t\t\t\t\t\ttooltip.updateContent({\r\n\t\t\t\t\t\t\ttext: L.drawLocal.edit.handlers.edit.tooltip.text,\r\n\t\t\t\t\t\t\tsubtext: L.drawLocal.edit.handlers.edit.tooltip.subtext\r\n\t\t\t\t\t\t});\r\n\t\t\t\t\t}\r\n\t\t\t\t}, 1000);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (marker._middleLeft) {\r\n\t\t\tmarker._middleLeft.setLatLng(this._getMiddleLatLng(marker._prev, marker));\r\n\t\t}\r\n\t\tif (marker._middleRight) {\r\n\t\t\tmarker._middleRight.setLatLng(this._getMiddleLatLng(marker, marker._next));\r\n\t\t}\r\n\r\n\t\t//refresh the bounds when draging\r\n\t\tthis._poly._bounds._southWest = L.latLng(Infinity, Infinity);\r\n\t\tthis._poly._bounds._northEast = L.latLng(-Infinity, -Infinity);\r\n\t\tvar latlngs = this._poly.getLatLngs();\r\n\t\tthis._poly._convertLatLngs(latlngs, true);\r\n\t\tthis._poly.redraw();\r\n\t\tthis._poly.fire('editdrag');\r\n\t},\r\n\r\n\t_onMarkerClick: function (e) {\r\n\r\n\t\tvar minPoints = L.Polygon && (this._poly instanceof L.Polygon) ? 4 : 3,\r\n\t\t\tmarker = e.target;\r\n\r\n\t\t// If removing this point would create an invalid polyline/polygon don't remove\r\n\t\tif (this._defaultShape().length < minPoints) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\t// remove the marker\r\n\t\tthis._removeMarker(marker);\r\n\r\n\t\t// update prev/next links of adjacent markers\r\n\t\tthis._updatePrevNext(marker._prev, marker._next);\r\n\r\n\t\t// remove ghost markers near the removed marker\r\n\t\tif (marker._middleLeft) {\r\n\t\t\tthis._markerGroup.removeLayer(marker._middleLeft);\r\n\t\t}\r\n\t\tif (marker._middleRight) {\r\n\t\t\tthis._markerGroup.removeLayer(marker._middleRight);\r\n\t\t}\r\n\r\n\t\t// create a ghost marker in place of the removed one\r\n\t\tif (marker._prev && marker._next) {\r\n\t\t\tthis._createMiddleMarker(marker._prev, marker._next);\r\n\r\n\t\t} else if (!marker._prev) {\r\n\t\t\tmarker._next._middleLeft = null;\r\n\r\n\t\t} else if (!marker._next) {\r\n\t\t\tmarker._prev._middleRight = null;\r\n\t\t}\r\n\r\n\t\tthis._fireEdit();\r\n\t},\r\n\r\n\t_onContextMenu: function (e) {\r\n\t\tvar marker = e.target;\r\n\t\tvar poly = this._poly;\r\n\t\tthis._poly._map.fire(L.Draw.Event.MARKERCONTEXT, {marker: marker, layers: this._markerGroup, poly: this._poly});\r\n\t\tL.DomEvent.stopPropagation;\r\n\t},\r\n\r\n\t_onTouchMove: function (e) {\r\n\r\n\t\tvar layerPoint = this._map.mouseEventToLayerPoint(e.originalEvent.touches[0]),\r\n\t\t\tlatlng = this._map.layerPointToLatLng(layerPoint),\r\n\t\t\tmarker = e.target;\r\n\r\n\t\tL.extend(marker._origLatLng, latlng);\r\n\r\n\t\tif (marker._middleLeft) {\r\n\t\t\tmarker._middleLeft.setLatLng(this._getMiddleLatLng(marker._prev, marker));\r\n\t\t}\r\n\t\tif (marker._middleRight) {\r\n\t\t\tmarker._middleRight.setLatLng(this._getMiddleLatLng(marker, marker._next));\r\n\t\t}\r\n\r\n\t\tthis._poly.redraw();\r\n\t\tthis.updateMarkers();\r\n\t},\r\n\r\n\t_updateIndexes: function (index, delta) {\r\n\t\tthis._markerGroup.eachLayer(function (marker) {\r\n\t\t\tif (marker._index > index) {\r\n\t\t\t\tmarker._index += delta;\r\n\t\t\t}\r\n\t\t});\r\n\t},\r\n\r\n\t_createMiddleMarker: function (marker1, marker2) {\r\n\t\tvar latlng = this._getMiddleLatLng(marker1, marker2),\r\n\t\t\tmarker = this._createMarker(latlng),\r\n\t\t\tonClick,\r\n\t\t\tonDragStart,\r\n\t\t\tonDragEnd;\r\n\r\n\t\tmarker.setOpacity(0.6);\r\n\r\n\t\tmarker1._middleRight = marker2._middleLeft = marker;\r\n\r\n\t\tonDragStart = function () {\r\n\t\t\tmarker.off('touchmove', onDragStart, this);\r\n\t\t\tvar i = marker2._index;\r\n\r\n\t\t\tmarker._index = i;\r\n\r\n\t\t\tmarker\r\n\t\t\t\t.off('click', onClick, this)\r\n\t\t\t\t.on('click', this._onMarkerClick, this);\r\n\r\n\t\t\tlatlng.lat = marker.getLatLng().lat;\r\n\t\t\tlatlng.lng = marker.getLatLng().lng;\r\n\t\t\tthis._spliceLatLngs(i, 0, latlng);\r\n\t\t\tthis._markers.splice(i, 0, marker);\r\n\r\n\t\t\tmarker.setOpacity(1);\r\n\r\n\t\t\tthis._updateIndexes(i, 1);\r\n\t\t\tmarker2._index++;\r\n\t\t\tthis._updatePrevNext(marker1, marker);\r\n\t\t\tthis._updatePrevNext(marker, marker2);\r\n\r\n\t\t\tthis._poly.fire('editstart');\r\n\t\t};\r\n\r\n\t\tonDragEnd = function () {\r\n\t\t\tmarker.off('dragstart', onDragStart, this);\r\n\t\t\tmarker.off('dragend', onDragEnd, this);\r\n\t\t\tmarker.off('touchmove', onDragStart, this);\r\n\r\n\t\t\tthis._createMiddleMarker(marker1, marker);\r\n\t\t\tthis._createMiddleMarker(marker, marker2);\r\n\t\t};\r\n\r\n\t\tonClick = function () {\r\n\t\t\tonDragStart.call(this);\r\n\t\t\tonDragEnd.call(this);\r\n\t\t\tthis._fireEdit();\r\n\t\t};\r\n\r\n\t\tmarker\r\n\t\t\t.on('click', onClick, this)\r\n\t\t\t.on('dragstart', onDragStart, this)\r\n\t\t\t.on('dragend', onDragEnd, this)\r\n\t\t\t.on('touchmove', onDragStart, this);\r\n\r\n\t\tthis._markerGroup.addLayer(marker);\r\n\t},\r\n\r\n\t_updatePrevNext: function (marker1, marker2) {\r\n\t\tif (marker1) {\r\n\t\t\tmarker1._next = marker2;\r\n\t\t}\r\n\t\tif (marker2) {\r\n\t\t\tmarker2._prev = marker1;\r\n\t\t}\r\n\t},\r\n\r\n\t_getMiddleLatLng: function (marker1, marker2) {\r\n\t\tvar map = this._poly._map,\r\n\t\t\tp1 = map.project(marker1.getLatLng()),\r\n\t\t\tp2 = map.project(marker2.getLatLng());\r\n\r\n\t\treturn map.unproject(p1._add(p2)._divideBy(2));\r\n\t}\r\n});\r\n\r\nL.Polyline.addInitHook(function () {\r\n\r\n\t// Check to see if handler has already been initialized. This is to support versions of Leaflet that still have L.Handler.PolyEdit\r\n\tif (this.editing) {\r\n\t\treturn;\r\n\t}\r\n\r\n\tif (L.Edit.Poly) {\r\n\r\n\t\tthis.editing = new L.Edit.Poly(this);\r\n\r\n\t\tif (this.options.editable) {\r\n\t\t\tthis.editing.enable();\r\n\t\t}\r\n\t}\r\n\r\n\tthis.on('add', function () {\r\n\t\tif (this.editing && this.editing.enabled()) {\r\n\t\t\tthis.editing.addHooks();\r\n\t\t}\r\n\t});\r\n\r\n\tthis.on('remove', function () {\r\n\t\tif (this.editing && this.editing.enabled()) {\r\n\t\t\tthis.editing.removeHooks();\r\n\t\t}\r\n\t});\r\n});\r\n","L.Edit = L.Edit || {};\r\n/**\r\n * @class L.Edit.SimpleShape\r\n * @aka Edit.SimpleShape\r\n */\r\nL.Edit.SimpleShape = L.Handler.extend({\r\n\toptions: {\r\n\t\tmoveIcon: new L.DivIcon({\r\n\t\t\ticonSize: new L.Point(8, 8),\r\n\t\t\tclassName: 'leaflet-div-icon leaflet-editing-icon leaflet-edit-move'\r\n\t\t}),\r\n\t\tresizeIcon: new L.DivIcon({\r\n\t\t\ticonSize: new L.Point(8, 8),\r\n\t\t\tclassName: 'leaflet-div-icon leaflet-editing-icon leaflet-edit-resize'\r\n\t\t}),\r\n\t\ttouchMoveIcon: new L.DivIcon({\r\n\t\t\ticonSize: new L.Point(20, 20),\r\n\t\t\tclassName: 'leaflet-div-icon leaflet-editing-icon leaflet-edit-move leaflet-touch-icon'\r\n\t\t}),\r\n\t\ttouchResizeIcon: new L.DivIcon({\r\n\t\t\ticonSize: new L.Point(20, 20),\r\n\t\t\tclassName: 'leaflet-div-icon leaflet-editing-icon leaflet-edit-resize leaflet-touch-icon'\r\n\t\t}),\r\n\t},\r\n\r\n\t// @method intialize(): void\r\n\tinitialize: function (shape, options) {\r\n\t\t// if touch, switch to touch icon\r\n\t\tif (L.Browser.touch) {\r\n\t\t\tthis.options.moveIcon = this.options.touchMoveIcon;\r\n\t\t\tthis.options.resizeIcon = this.options.touchResizeIcon;\r\n\t\t}\r\n\r\n\t\tthis._shape = shape;\r\n\t\tL.Util.setOptions(this, options);\r\n\t},\r\n\r\n\t// @method addHooks(): void\r\n\t// Add listener hooks to this handler\r\n\taddHooks: function () {\r\n\t\tvar shape = this._shape;\r\n\t\tif (this._shape._map) {\r\n\t\t\tthis._map = this._shape._map;\r\n\t\t\tshape.setStyle(shape.options.editing);\r\n\r\n\t\t\tif (shape._map) {\r\n\t\t\t\tthis._map = shape._map;\r\n\t\t\t\tif (!this._markerGroup) {\r\n\t\t\t\t\tthis._initMarkers();\r\n\t\t\t\t}\r\n\t\t\t\tthis._map.addLayer(this._markerGroup);\r\n\t\t\t}\r\n\t\t}\r\n\t},\r\n\r\n\t// @method removeHooks(): void\r\n\t// Remove listener hooks from this handler\r\n\tremoveHooks: function () {\r\n\t\tvar shape = this._shape;\r\n\r\n\t\tshape.setStyle(shape.options.original);\r\n\r\n\t\tif (shape._map) {\r\n\t\t\tthis._unbindMarker(this._moveMarker);\r\n\r\n\t\t\tfor (var i = 0, l = this._resizeMarkers.length; i < l; i++) {\r\n\t\t\t\tthis._unbindMarker(this._resizeMarkers[i]);\r\n\t\t\t}\r\n\t\t\tthis._resizeMarkers = null;\r\n\r\n\t\t\tthis._map.removeLayer(this._markerGroup);\r\n\t\t\tdelete this._markerGroup;\r\n\t\t}\r\n\r\n\t\tthis._map = null;\r\n\t},\r\n\r\n\t// @method updateMarkers(): void\r\n\t// Remove the edit markers from this layer\r\n\tupdateMarkers: function () {\r\n\t\tthis._markerGroup.clearLayers();\r\n\t\tthis._initMarkers();\r\n\t},\r\n\r\n\t_initMarkers: function () {\r\n\t\tif (!this._markerGroup) {\r\n\t\t\tthis._markerGroup = new L.LayerGroup();\r\n\t\t}\r\n\r\n\t\t// Create center marker\r\n\t\tthis._createMoveMarker();\r\n\r\n\t\t// Create edge marker\r\n\t\tthis._createResizeMarker();\r\n\t},\r\n\r\n\t_createMoveMarker: function () {\r\n\t\t// Children override\r\n\t},\r\n\r\n\t_createResizeMarker: function () {\r\n\t\t// Children override\r\n\t},\r\n\r\n\t_createMarker: function (latlng, icon) {\r\n\t\t// Extending L.Marker in TouchEvents.js to include touch.\r\n\t\tvar marker = new L.Marker.Touch(latlng, {\r\n\t\t\tdraggable: true,\r\n\t\t\ticon: icon,\r\n\t\t\tzIndexOffset: 10\r\n\t\t});\r\n\r\n\t\tthis._bindMarker(marker);\r\n\r\n\t\tthis._markerGroup.addLayer(marker);\r\n\r\n\t\treturn marker;\r\n\t},\r\n\r\n\t_bindMarker: function (marker) {\r\n\t\tmarker\r\n\t\t\t.on('dragstart', this._onMarkerDragStart, this)\r\n\t\t\t.on('drag', this._onMarkerDrag, this)\r\n\t\t\t.on('dragend', this._onMarkerDragEnd, this)\r\n\t\t\t.on('touchstart', this._onTouchStart, this)\r\n\t\t\t.on('touchmove', this._onTouchMove, this)\r\n\t\t\t.on('MSPointerMove', this._onTouchMove, this)\r\n\t\t\t.on('touchend', this._onTouchEnd, this)\r\n\t\t\t.on('MSPointerUp', this._onTouchEnd, this);\r\n\t},\r\n\r\n\t_unbindMarker: function (marker) {\r\n\t\tmarker\r\n\t\t\t.off('dragstart', this._onMarkerDragStart, this)\r\n\t\t\t.off('drag', this._onMarkerDrag, this)\r\n\t\t\t.off('dragend', this._onMarkerDragEnd, this)\r\n\t\t\t.off('touchstart', this._onTouchStart, this)\r\n\t\t\t.off('touchmove', this._onTouchMove, this)\r\n\t\t\t.off('MSPointerMove', this._onTouchMove, this)\r\n\t\t\t.off('touchend', this._onTouchEnd, this)\r\n\t\t\t.off('MSPointerUp', this._onTouchEnd, this);\r\n\t},\r\n\r\n\t_onMarkerDragStart: function (e) {\r\n\t\tvar marker = e.target;\r\n\t\tmarker.setOpacity(0);\r\n\r\n\t\tthis._shape.fire('editstart');\r\n\t},\r\n\r\n\t_fireEdit: function () {\r\n\t\tthis._shape.edited = true;\r\n\t\tthis._shape.fire('edit');\r\n\t},\r\n\r\n\t_onMarkerDrag: function (e) {\r\n\t\tvar marker = e.target,\r\n\t\t\tlatlng = marker.getLatLng();\r\n\r\n\t\tif (marker === this._moveMarker) {\r\n\t\t\tthis._move(latlng);\r\n\t\t} else {\r\n\t\t\tthis._resize(latlng);\r\n\t\t}\r\n\r\n\t\tthis._shape.redraw();\r\n\t\tthis._shape.fire('editdrag');\r\n\t},\r\n\r\n\t_onMarkerDragEnd: function (e) {\r\n\t\tvar marker = e.target;\r\n\t\tmarker.setOpacity(1);\r\n\r\n\t\tthis._fireEdit();\r\n\t},\r\n\r\n\t_onTouchStart: function (e) {\r\n\t\tL.Edit.SimpleShape.prototype._onMarkerDragStart.call(this, e);\r\n\r\n\t\tif (typeof(this._getCorners) === 'function') {\r\n\t\t\t// Save a reference to the opposite point\r\n\t\t\tvar corners = this._getCorners(),\r\n\t\t\t\tmarker = e.target,\r\n\t\t\t\tcurrentCornerIndex = marker._cornerIndex;\r\n\r\n\t\t\tmarker.setOpacity(0);\r\n\r\n\t\t\t// Copyed from Edit.Rectangle.js line 23 _onMarkerDragStart()\r\n\t\t\t// Latlng is null otherwise.\r\n\t\t\tthis._oppositeCorner = corners[(currentCornerIndex + 2) % 4];\r\n\t\t\tthis._toggleCornerMarkers(0, currentCornerIndex);\r\n\t\t}\r\n\r\n\t\tthis._shape.fire('editstart');\r\n\t},\r\n\r\n\t_onTouchMove: function (e) {\r\n\t\tvar layerPoint = this._map.mouseEventToLayerPoint(e.originalEvent.touches[0]),\r\n\t\t\tlatlng = this._map.layerPointToLatLng(layerPoint),\r\n\t\t\tmarker = e.target;\r\n\r\n\t\tif (marker === this._moveMarker) {\r\n\t\t\tthis._move(latlng);\r\n\t\t} else {\r\n\t\t\tthis._resize(latlng);\r\n\t\t}\r\n\r\n\t\tthis._shape.redraw();\r\n\r\n\t\t// prevent touchcancel in IOS\r\n\t\t// e.preventDefault();\r\n\t\treturn false;\r\n\t},\r\n\r\n\t_onTouchEnd: function (e) {\r\n\t\tvar marker = e.target;\r\n\t\tmarker.setOpacity(1);\r\n\t\tthis.updateMarkers();\r\n\t\tthis._fireEdit();\r\n\t},\r\n\r\n\t_move: function () {\r\n\t\t// Children override\r\n\t},\r\n\r\n\t_resize: function () {\r\n\t\t// Children override\r\n\t}\r\n});\r\n","L.Edit = L.Edit || {};\r\n/**\r\n * @class L.Edit.Rectangle\r\n * @aka Edit.Rectangle\r\n * @inherits L.Edit.SimpleShape\r\n */\r\nL.Edit.Rectangle = L.Edit.SimpleShape.extend({\r\n\t_createMoveMarker: function () {\r\n\t\tvar bounds = this._shape.getBounds(),\r\n\t\t\tcenter = bounds.getCenter();\r\n\r\n\t\tthis._moveMarker = this._createMarker(center, this.options.moveIcon);\r\n\t},\r\n\r\n\t_createResizeMarker: function () {\r\n\t\tvar corners = this._getCorners();\r\n\r\n\t\tthis._resizeMarkers = [];\r\n\r\n\t\tfor (var i = 0, l = corners.length; i < l; i++) {\r\n\t\t\tthis._resizeMarkers.push(this._createMarker(corners[i], this.options.resizeIcon));\r\n\t\t\t// Monkey in the corner index as we will need to know this for dragging\r\n\t\t\tthis._resizeMarkers[i]._cornerIndex = i;\r\n\t\t}\r\n\t},\r\n\r\n\t_onMarkerDragStart: function (e) {\r\n\t\tL.Edit.SimpleShape.prototype._onMarkerDragStart.call(this, e);\r\n\r\n\t\t// Save a reference to the opposite point\r\n\t\tvar corners = this._getCorners(),\r\n\t\t\tmarker = e.target,\r\n\t\t\tcurrentCornerIndex = marker._cornerIndex;\r\n\r\n\t\tthis._oppositeCorner = corners[(currentCornerIndex + 2) % 4];\r\n\r\n\t\tthis._toggleCornerMarkers(0, currentCornerIndex);\r\n\t},\r\n\r\n\t_onMarkerDragEnd: function (e) {\r\n\t\tvar marker = e.target,\r\n\t\t\tbounds, center;\r\n\r\n\t\t// Reset move marker position to the center\r\n\t\tif (marker === this._moveMarker) {\r\n\t\t\tbounds = this._shape.getBounds();\r\n\t\t\tcenter = bounds.getCenter();\r\n\r\n\t\t\tmarker.setLatLng(center);\r\n\t\t}\r\n\r\n\t\tthis._toggleCornerMarkers(1);\r\n\r\n\t\tthis._repositionCornerMarkers();\r\n\r\n\t\tL.Edit.SimpleShape.prototype._onMarkerDragEnd.call(this, e);\r\n\t},\r\n\r\n\t_move: function (newCenter) {\r\n\t\tvar latlngs = this._shape._defaultShape ? this._shape._defaultShape() : this._shape.getLatLngs(),\r\n\t\t\tbounds = this._shape.getBounds(),\r\n\t\t\tcenter = bounds.getCenter(),\r\n\t\t\toffset, newLatLngs = [];\r\n\r\n\t\t// Offset the latlngs to the new center\r\n\t\tfor (var i = 0, l = latlngs.length; i < l; i++) {\r\n\t\t\toffset = [latlngs[i].lat - center.lat, latlngs[i].lng - center.lng];\r\n\t\t\tnewLatLngs.push([newCenter.lat + offset[0], newCenter.lng + offset[1]]);\r\n\t\t}\r\n\r\n\t\tthis._shape.setLatLngs(newLatLngs);\r\n\r\n\t\t// Reposition the resize markers\r\n\t\tthis._repositionCornerMarkers();\r\n\r\n\t\tthis._map.fire(L.Draw.Event.EDITMOVE, {layer: this._shape});\r\n\t},\r\n\r\n\t_resize: function (latlng) {\r\n\t\tvar bounds;\r\n\r\n\t\t// Update the shape based on the current position of this corner and the opposite point\r\n\t\tthis._shape.setBounds(L.latLngBounds(latlng, this._oppositeCorner));\r\n\r\n\t\t// Reposition the move marker\r\n\t\tbounds = this._shape.getBounds();\r\n\t\tthis._moveMarker.setLatLng(bounds.getCenter());\r\n\r\n\t\tthis._map.fire(L.Draw.Event.EDITRESIZE, {layer: this._shape});\r\n\t},\r\n\r\n\t_getCorners: function () {\r\n\t\tvar bounds = this._shape.getBounds(),\r\n\t\t\tnw = bounds.getNorthWest(),\r\n\t\t\tne = bounds.getNorthEast(),\r\n\t\t\tse = bounds.getSouthEast(),\r\n\t\t\tsw = bounds.getSouthWest();\r\n\r\n\t\treturn [nw, ne, se, sw];\r\n\t},\r\n\r\n\t_toggleCornerMarkers: function (opacity) {\r\n\t\tfor (var i = 0, l = this._resizeMarkers.length; i < l; i++) {\r\n\t\t\tthis._resizeMarkers[i].setOpacity(opacity);\r\n\t\t}\r\n\t},\r\n\r\n\t_repositionCornerMarkers: function () {\r\n\t\tvar corners = this._getCorners();\r\n\r\n\t\tfor (var i = 0, l = this._resizeMarkers.length; i < l; i++) {\r\n\t\t\tthis._resizeMarkers[i].setLatLng(corners[i]);\r\n\t\t}\r\n\t}\r\n});\r\n\r\nL.Rectangle.addInitHook(function () {\r\n\tif (L.Edit.Rectangle) {\r\n\t\tthis.editing = new L.Edit.Rectangle(this);\r\n\r\n\t\tif (this.options.editable) {\r\n\t\t\tthis.editing.enable();\r\n\t\t}\r\n\t}\r\n});\r\n","L.Edit = L.Edit || {};\r\n/**\r\n * @class L.Edit.CircleMarker\r\n * @aka Edit.Circle\r\n * @inherits L.Edit.SimpleShape\r\n */\r\nL.Edit.CircleMarker = L.Edit.SimpleShape.extend({\r\n\t_createMoveMarker: function () {\r\n\t\tvar center = this._shape.getLatLng();\r\n\t\tthis._map._editTooltip = new L.Draw.Tooltip(this._map);\r\n\t\tthis._moveMarker = this._createMarker(center, this.options.moveIcon);\r\n\t},\r\n\r\n\t_createResizeMarker: function () {\r\n\t\t// To avoid an undefined check in L.Edit.SimpleShape.removeHooks\r\n\t\tthis._resizeMarkers = [];\r\n\t},\r\n\r\n\t_move: function (latlng) {\r\n\t\tif (this._resizeMarkers.length) {\r\n\t\t\tvar resizemarkerPoint = this._getResizeMarkerPoint(latlng);\r\n\t\t\t// Move the resize marker\r\n\t\t\tthis._resizeMarkers[0].setLatLng(resizemarkerPoint);\r\n\t\t}\r\n\r\n\t\t// Move the circle\r\n\t\tthis._shape.setLatLng(latlng);\r\n\r\n\t\tthis._map.fire(L.Draw.Event.EDITMOVE, {layer: this._shape});\r\n\t},\r\n});\r\n\r\nL.CircleMarker.addInitHook(function () {\r\n\tif (L.Edit.CircleMarker) {\r\n\t\tthis.editing = new L.Edit.CircleMarker(this);\r\n\r\n\t\tif (this.options.editable) {\r\n\t\t\tthis.editing.enable();\r\n\t\t}\r\n\t}\r\n\r\n\tthis.on('add', function () {\r\n\t\tif (this.editing && this.editing.enabled()) {\r\n\t\t\tthis.editing.addHooks();\r\n\t\t}\r\n\t});\r\n\r\n\tthis.on('remove', function () {\r\n\t\tif (this.editing && this.editing.enabled()) {\r\n\t\t\tthis.editing.removeHooks();\r\n\t\t}\r\n\t});\r\n});\r\n","L.Edit = L.Edit || {};\r\n/**\r\n * @class L.Edit.Circle\r\n * @aka Edit.Circle\r\n * @inherits L.Edit.CircleMarker\r\n */\r\nL.Edit.Circle = L.Edit.CircleMarker.extend({\r\n\r\n\t_createResizeMarker: function () {\r\n\t\tvar center = this._shape.getLatLng(),\r\n\t\t\tresizemarkerPoint = this._getResizeMarkerPoint(center);\r\n\r\n\t\tthis._resizeMarkers = [];\r\n\t\tthis._resizeMarkers.push(this._createMarker(resizemarkerPoint, this.options.resizeIcon));\r\n\t},\r\n\r\n\t_getResizeMarkerPoint: function (latlng) {\r\n\t\t// From L.shape.getBounds()\r\n\t\tvar delta = this._shape._radius * Math.cos(Math.PI / 4),\r\n\t\t\tpoint = this._map.project(latlng);\r\n\t\treturn this._map.unproject([point.x + delta, point.y - delta]);\r\n\t},\r\n\r\n\t_resize: function (latlng) {\r\n\t\tvar moveLatLng = this._moveMarker.getLatLng();\r\n\r\n\t\t// Calculate the radius based on the version\r\n\t\tif (L.GeometryUtil.isVersion07x()) {\r\n\t\t\tradius = moveLatLng.distanceTo(latlng);\r\n\t\t} else {\r\n\t\t\tradius = this._map.distance(moveLatLng, latlng);\r\n\t\t}\r\n\t\tthis._shape.setRadius(radius);\r\n\r\n\t\tif (this._map._editTooltip) {\r\n\t\t\tthis._map._editTooltip.updatePosition(latlng);\r\n\t\t\tthis._map._editTooltip.updateContent({\r\n\t\t\t\ttext: L.drawLocal.edit.handlers.edit.tooltip.subtext + '
' + L.drawLocal.edit.handlers.edit.tooltip.text,\r\n\t\t\t\tsubtext: L.drawLocal.draw.handlers.circle.radius + ': ' +\r\n\t\t\t\tL.GeometryUtil.readableDistance(radius, true, this.options.feet, this.options.nautic)\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\tthis._shape.setRadius(radius);\r\n\r\n\t\tthis._map.fire(L.Draw.Event.EDITRESIZE, {layer: this._shape});\r\n\t}\r\n});\r\n\r\nL.Circle.addInitHook(function () {\r\n\tif (L.Edit.Circle) {\r\n\t\tthis.editing = new L.Edit.Circle(this);\r\n\r\n\t\tif (this.options.editable) {\r\n\t\t\tthis.editing.enable();\r\n\t\t}\r\n\t}\r\n});\r\n","L.Map.mergeOptions({\r\n\ttouchExtend: true\r\n});\r\n\r\n/**\r\n * @class L.Map.TouchExtend\r\n * @aka TouchExtend\r\n */\r\nL.Map.TouchExtend = L.Handler.extend({\r\n\r\n\t// @method initialize(): void\r\n\t// Sets TouchExtend private accessor variables\r\n\tinitialize: function (map) {\r\n\t\tthis._map = map;\r\n\t\tthis._container = map._container;\r\n\t\tthis._pane = map._panes.overlayPane;\r\n\t},\r\n\r\n\t// @method addHooks(): void\r\n\t// Adds dom listener events to the map container\r\n\taddHooks: function () {\r\n\t\tL.DomEvent.on(this._container, 'touchstart', this._onTouchStart, this);\r\n\t\tL.DomEvent.on(this._container, 'touchend', this._onTouchEnd, this);\r\n\t\tL.DomEvent.on(this._container, 'touchmove', this._onTouchMove, this);\r\n\t\tif (this._detectIE()) {\r\n\t\t\tL.DomEvent.on(this._container, 'MSPointerDown', this._onTouchStart, this);\r\n\t\t\tL.DomEvent.on(this._container, 'MSPointerUp', this._onTouchEnd, this);\r\n\t\t\tL.DomEvent.on(this._container, 'MSPointerMove', this._onTouchMove, this);\r\n\t\t\tL.DomEvent.on(this._container, 'MSPointerCancel', this._onTouchCancel, this);\r\n\r\n\t\t} else {\r\n\t\t\tL.DomEvent.on(this._container, 'touchcancel', this._onTouchCancel, this);\r\n\t\t\tL.DomEvent.on(this._container, 'touchleave', this._onTouchLeave, this);\r\n\t\t}\r\n\t},\r\n\r\n\t// @method removeHooks(): void\r\n\t// Removes dom listener events from the map container\r\n\tremoveHooks: function () {\r\n\t\tL.DomEvent.off(this._container, 'touchstart', this._onTouchStart, this);\r\n\t\tL.DomEvent.off(this._container, 'touchend', this._onTouchEnd, this);\r\n\t\tL.DomEvent.off(this._container, 'touchmove', this._onTouchMove, this);\r\n\t\tif (this._detectIE()) {\r\n\t\t\tL.DomEvent.off(this._container, 'MSPointerDown', this._onTouchStart, this);\r\n\t\t\tL.DomEvent.off(this._container, 'MSPointerUp', this._onTouchEnd, this);\r\n\t\t\tL.DomEvent.off(this._container, 'MSPointerMove', this._onTouchMove, this);\r\n\t\t\tL.DomEvent.off(this._container, 'MSPointerCancel', this._onTouchCancel, this);\r\n\t\t} else {\r\n\t\t\tL.DomEvent.off(this._container, 'touchcancel', this._onTouchCancel, this);\r\n\t\t\tL.DomEvent.off(this._container, 'touchleave', this._onTouchLeave, this);\r\n\t\t}\r\n\t},\r\n\r\n\t_touchEvent: function (e, type) {\r\n\t\t// #TODO: fix the pageX error that is do a bug in Android where a single touch triggers two click events\r\n\t\t// _filterClick is what leaflet uses as a workaround.\r\n\t\t// This is a problem with more things than just android. Another problem is touchEnd has no touches in\r\n\t\t// its touch list.\r\n\t\tvar touchEvent = {};\r\n\t\tif (typeof e.touches !== 'undefined') {\r\n\t\t\tif (!e.touches.length) {\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\t\t\ttouchEvent = e.touches[0];\r\n\t\t} else if (e.pointerType === 'touch') {\r\n\t\t\ttouchEvent = e;\r\n\t\t\tif (!this._filterClick(e)) {\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\t\t} else {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tvar containerPoint = this._map.mouseEventToContainerPoint(touchEvent),\r\n\t\t\tlayerPoint = this._map.mouseEventToLayerPoint(touchEvent),\r\n\t\t\tlatlng = this._map.layerPointToLatLng(layerPoint);\r\n\r\n\t\tthis._map.fire(type, {\r\n\t\t\tlatlng: latlng,\r\n\t\t\tlayerPoint: layerPoint,\r\n\t\t\tcontainerPoint: containerPoint,\r\n\t\t\tpageX: touchEvent.pageX,\r\n\t\t\tpageY: touchEvent.pageY,\r\n\t\t\toriginalEvent: e\r\n\t\t});\r\n\t},\r\n\r\n\t/** Borrowed from Leaflet and modified for bool ops **/\r\n\t_filterClick: function (e) {\r\n\t\tvar timeStamp = (e.timeStamp || e.originalEvent.timeStamp),\r\n\t\t\telapsed = L.DomEvent._lastClick && (timeStamp - L.DomEvent._lastClick);\r\n\r\n\t\t// are they closer together than 500ms yet more than 100ms?\r\n\t\t// Android typically triggers them ~300ms apart while multiple listeners\r\n\t\t// on the same event should be triggered far faster;\r\n\t\t// or check if click is simulated on the element, and if it is, reject any non-simulated events\r\n\t\tif ((elapsed && elapsed > 100 && elapsed < 500) || (e.target._simulatedClick && !e._simulated)) {\r\n\t\t\tL.DomEvent.stop(e);\r\n\t\t\treturn false;\r\n\t\t}\r\n\t\tL.DomEvent._lastClick = timeStamp;\r\n\t\treturn true;\r\n\t},\r\n\r\n\t_onTouchStart: function (e) {\r\n\t\tif (!this._map._loaded) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tvar type = 'touchstart';\r\n\t\tthis._touchEvent(e, type);\r\n\r\n\t},\r\n\r\n\t_onTouchEnd: function (e) {\r\n\t\tif (!this._map._loaded) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tvar type = 'touchend';\r\n\t\tthis._touchEvent(e, type);\r\n\t},\r\n\r\n\t_onTouchCancel: function (e) {\r\n\t\tif (!this._map._loaded) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tvar type = 'touchcancel';\r\n\t\tif (this._detectIE()) {\r\n\t\t\ttype = 'pointercancel';\r\n\t\t}\r\n\t\tthis._touchEvent(e, type);\r\n\t},\r\n\r\n\t_onTouchLeave: function (e) {\r\n\t\tif (!this._map._loaded) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tvar type = 'touchleave';\r\n\t\tthis._touchEvent(e, type);\r\n\t},\r\n\r\n\t_onTouchMove: function (e) {\r\n\t\tif (!this._map._loaded) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tvar type = 'touchmove';\r\n\t\tthis._touchEvent(e, type);\r\n\t},\r\n\r\n\t_detectIE: function () {\r\n\t\tvar ua = window.navigator.userAgent;\r\n\r\n\t\tvar msie = ua.indexOf('MSIE ');\r\n\t\tif (msie > 0) {\r\n\t\t\t// IE 10 or older => return version number\r\n\t\t\treturn parseInt(ua.substring(msie + 5, ua.indexOf('.', msie)), 10);\r\n\t\t}\r\n\r\n\t\tvar trident = ua.indexOf('Trident/');\r\n\t\tif (trident > 0) {\r\n\t\t\t// IE 11 => return version number\r\n\t\t\tvar rv = ua.indexOf('rv:');\r\n\t\t\treturn parseInt(ua.substring(rv + 3, ua.indexOf('.', rv)), 10);\r\n\t\t}\r\n\r\n\t\tvar edge = ua.indexOf('Edge/');\r\n\t\tif (edge > 0) {\r\n\t\t\t// IE 12 => return version number\r\n\t\t\treturn parseInt(ua.substring(edge + 5, ua.indexOf('.', edge)), 10);\r\n\t\t}\r\n\r\n\t\t// other browser\r\n\t\treturn false;\r\n\t}\r\n});\r\n\r\nL.Map.addInitHook('addHandler', 'touchExtend', L.Map.TouchExtend);\r\n\r\n\r\n/**\r\n * @class L.Marker.Touch\r\n * @aka Marker.Touch\r\n *\r\n * This isn't full Touch support. This is just to get markers to also support dom touch events after creation\r\n * #TODO: find a better way of getting markers to support touch.\r\n */\r\nL.Marker.Touch = L.Marker.extend({\r\n\r\n\t_initInteraction: function () {\r\n\t\tif (!this.addInteractiveTarget) {\r\n\t\t\t// 0.7.x support\r\n\t\t\treturn this._initInteractionLegacy();\r\n\t\t}\r\n\t\t// TODO this may need be updated to re-add touch events for 1.0+\r\n\t\treturn L.Marker.prototype._initInteraction.apply(this);\r\n\t},\r\n\r\n\t// This is an exact copy of https://github.com/Leaflet/Leaflet/blob/v0.7/src/layer/marker/Marker.js\r\n\t// with the addition of the touch events\r\n\t_initInteractionLegacy: function () {\r\n\r\n\t\tif (!this.options.clickable) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\t// TODO refactor into something shared with Map/Path/etc. to DRY it up\r\n\r\n\t\tvar icon = this._icon,\r\n\t\t\tevents = ['dblclick',\r\n\t\t\t\t'mousedown',\r\n\t\t\t\t'mouseover',\r\n\t\t\t\t'mouseout',\r\n\t\t\t\t'contextmenu',\r\n\t\t\t\t'touchstart',\r\n\t\t\t\t'touchend',\r\n\t\t\t\t'touchmove'];\r\n\t\tif (this._detectIE) {\r\n\t\t\tevents.concat(['MSPointerDown',\r\n\t\t\t\t'MSPointerUp',\r\n\t\t\t\t'MSPointerMove',\r\n\t\t\t\t'MSPointerCancel']);\r\n\t\t} else {\r\n\t\t\tevents.concat(['touchcancel']);\r\n\t\t}\r\n\r\n\t\tL.DomUtil.addClass(icon, 'leaflet-clickable');\r\n\t\tL.DomEvent.on(icon, 'click', this._onMouseClick, this);\r\n\t\tL.DomEvent.on(icon, 'keypress', this._onKeyPress, this);\r\n\r\n\t\tfor (var i = 0; i < events.length; i++) {\r\n\t\t\tL.DomEvent.on(icon, events[i], this._fireMouseEvent, this);\r\n\t\t}\r\n\r\n\t\tif (L.Handler.MarkerDrag) {\r\n\t\t\tthis.dragging = new L.Handler.MarkerDrag(this);\r\n\r\n\t\t\tif (this.options.draggable) {\r\n\t\t\t\tthis.dragging.enable();\r\n\t\t\t}\r\n\t\t}\r\n\t},\r\n\r\n\t_detectIE: function () {\r\n\t\tvar ua = window.navigator.userAgent;\r\n\r\n\t\tvar msie = ua.indexOf('MSIE ');\r\n\t\tif (msie > 0) {\r\n\t\t\t// IE 10 or older => return version number\r\n\t\t\treturn parseInt(ua.substring(msie + 5, ua.indexOf('.', msie)), 10);\r\n\t\t}\r\n\r\n\t\tvar trident = ua.indexOf('Trident/');\r\n\t\tif (trident > 0) {\r\n\t\t\t// IE 11 => return version number\r\n\t\t\tvar rv = ua.indexOf('rv:');\r\n\t\t\treturn parseInt(ua.substring(rv + 3, ua.indexOf('.', rv)), 10);\r\n\t\t}\r\n\r\n\t\tvar edge = ua.indexOf('Edge/');\r\n\t\tif (edge > 0) {\r\n\t\t\t// IE 12 => return version number\r\n\t\t\treturn parseInt(ua.substring(edge + 5, ua.indexOf('.', edge)), 10);\r\n\t\t}\r\n\r\n\t\t// other browser\r\n\t\treturn false;\r\n\t}\r\n});\r\n","/**\r\n * @class L.LatLngUtil\r\n * @aka LatLngUtil\r\n */\r\nL.LatLngUtil = {\r\n\t// Clones a LatLngs[], returns [][]\r\n\r\n\t// @method cloneLatLngs(LatLngs[]): L.LatLngs[]\r\n\t// Clone the latLng point or points or nested points and return an array with those points\r\n\tcloneLatLngs: function (latlngs) {\r\n\t\tvar clone = [];\r\n\t\tfor (var i = 0, l = latlngs.length; i < l; i++) {\r\n\t\t\t// Check for nested array (Polyline/Polygon)\r\n\t\t\tif (Array.isArray(latlngs[i])) {\r\n\t\t\t\tclone.push(L.LatLngUtil.cloneLatLngs(latlngs[i]));\r\n\t\t\t} else {\r\n\t\t\t\tclone.push(this.cloneLatLng(latlngs[i]));\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn clone;\r\n\t},\r\n\r\n\t// @method cloneLatLng(LatLng): L.LatLng\r\n\t// Clone the latLng and return a new LatLng object.\r\n\tcloneLatLng: function (latlng) {\r\n\t\treturn L.latLng(latlng.lat, latlng.lng);\r\n\t}\r\n};\r\n","(function () {\r\n\r\n\tvar defaultPrecision = {\r\n\t\tkm: 2,\r\n\t\tha: 2,\r\n\t\tm: 0,\r\n\t\tmi: 2,\r\n\t\tac: 2,\r\n\t\tyd: 0,\r\n\t\tft: 0,\r\n\t\tnm: 2\r\n\t};\r\n\r\n\r\n\t/**\r\n\t * @class L.GeometryUtil\r\n\t * @aka GeometryUtil\r\n\t */\r\n\tL.GeometryUtil = L.extend(L.GeometryUtil || {}, {\r\n\t\t// Ported from the OpenLayers implementation. See https://github.com/openlayers/openlayers/blob/master/lib/OpenLayers/Geometry/LinearRing.js#L270\r\n\r\n\t\t// @method geodesicArea(): number\r\n\t\tgeodesicArea: function (latLngs) {\r\n\t\t\tvar pointsCount = latLngs.length,\r\n\t\t\t\tarea = 0.0,\r\n\t\t\t\td2r = Math.PI / 180,\r\n\t\t\t\tp1, p2;\r\n\r\n\t\t\tif (pointsCount > 2) {\r\n\t\t\t\tfor (var i = 0; i < pointsCount; i++) {\r\n\t\t\t\t\tp1 = latLngs[i];\r\n\t\t\t\t\tp2 = latLngs[(i + 1) % pointsCount];\r\n\t\t\t\t\tarea += ((p2.lng - p1.lng) * d2r) *\r\n\t\t\t\t\t\t(2 + Math.sin(p1.lat * d2r) + Math.sin(p2.lat * d2r));\r\n\t\t\t\t}\r\n\t\t\t\tarea = area * 6378137.0 * 6378137.0 / 2.0;\r\n\t\t\t}\r\n\r\n\t\t\treturn Math.abs(area);\r\n\t\t},\r\n\r\n\t\t// @method formattedNumber(n, precision): string\r\n\t\t// Returns n in specified number format (if defined) and precision\r\n\t\tformattedNumber: function (n, precision) {\r\n\t\t\tvar formatted = parseFloat(n).toFixed(precision),\r\n\t\t\t\tformat = L.drawLocal.format && L.drawLocal.format.numeric,\r\n\t\t\t\tdelimiters = format && format.delimiters,\r\n\t\t\t\tthousands = delimiters && delimiters.thousands,\r\n\t\t\t\tdecimal = delimiters && delimiters.decimal;\r\n\r\n\t\t\tif (thousands || decimal) {\r\n\t\t\t\tvar splitValue = formatted.split('.');\r\n\t\t\t\tformatted = thousands ? splitValue[0].replace(/(\\d)(?=(\\d{3})+(?!\\d))/g, '$1' + thousands) : splitValue[0];\r\n\t\t\t\tdecimal = decimal || '.';\r\n\t\t\t\tif (splitValue.length > 1) {\r\n\t\t\t\t\tformatted = formatted + decimal + splitValue[1];\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\treturn formatted;\r\n\t\t},\r\n\r\n\t\t// @method readableArea(area, isMetric, precision): string\r\n\t\t// Returns a readable area string in yards or metric.\r\n\t\t// The value will be rounded as defined by the precision option object.\r\n\t\treadableArea: function (area, isMetric, precision) {\r\n\t\t\tvar areaStr,\r\n\t\t\t\tunits,\r\n\t\t\t\tprecision = L.Util.extend({}, defaultPrecision, precision);\r\n\r\n\t\t\tif (isMetric) {\r\n\t\t\t\tunits = ['ha', 'm'];\r\n\t\t\t\ttype = typeof isMetric;\r\n\t\t\t\tif (type === 'string') {\r\n\t\t\t\t\tunits = [isMetric];\r\n\t\t\t\t} else if (type !== 'boolean') {\r\n\t\t\t\t\tunits = isMetric;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif (area >= 1000000 && units.indexOf('km') !== -1) {\r\n\t\t\t\t\tareaStr = L.GeometryUtil.formattedNumber(area * 0.000001, precision['km']) + ' km²';\r\n\t\t\t\t} else if (area >= 10000 && units.indexOf('ha') !== -1) {\r\n\t\t\t\t\tareaStr = L.GeometryUtil.formattedNumber(area * 0.0001, precision['ha']) + ' ha';\r\n\t\t\t\t} else {\r\n\t\t\t\t\tareaStr = L.GeometryUtil.formattedNumber(area, precision['m']) + ' m²';\r\n\t\t\t\t}\r\n\t\t\t} else {\r\n\t\t\t\tarea /= 0.836127; // Square yards in 1 meter\r\n\r\n\t\t\t\tif (area >= 3097600) { //3097600 square yards in 1 square mile\r\n\t\t\t\t\tareaStr = L.GeometryUtil.formattedNumber(area / 3097600, precision['mi']) + ' mi²';\r\n\t\t\t\t} else if (area >= 4840) { //4840 square yards in 1 acre\r\n\t\t\t\t\tareaStr = L.GeometryUtil.formattedNumber(area / 4840, precision['ac']) + ' acres';\r\n\t\t\t\t} else {\r\n\t\t\t\t\tareaStr = L.GeometryUtil.formattedNumber(area, precision['yd']) + ' yd²';\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\treturn areaStr;\r\n\t\t},\r\n\r\n\t\t// @method readableDistance(distance, units): string\r\n\t\t// Converts a metric distance to one of [ feet, nauticalMile, metric or yards ] string\r\n\t\t//\r\n\t\t// @alternative\r\n\t\t// @method readableDistance(distance, isMetric, useFeet, isNauticalMile, precision): string\r\n\t\t// Converts metric distance to distance string.\r\n\t\t// The value will be rounded as defined by the precision option object.\r\n\t\treadableDistance: function (distance, isMetric, isFeet, isNauticalMile, precision) {\r\n\t\t\tvar distanceStr,\r\n\t\t\t\tunits,\r\n\t\t\t\tprecision = L.Util.extend({}, defaultPrecision, precision);\r\n\r\n\t\t\tif (isMetric) {\r\n\t\t\t\tunits = typeof isMetric == 'string' ? isMetric : 'metric';\r\n\t\t\t} else if (isFeet) {\r\n\t\t\t\tunits = 'feet';\r\n\t\t\t} else if (isNauticalMile) {\r\n\t\t\t\tunits = 'nauticalMile';\r\n\t\t\t} else {\r\n\t\t\t\tunits = 'yards';\r\n\t\t\t}\r\n\r\n\t\t\tswitch (units) {\r\n\t\t\t\tcase 'metric':\r\n\t\t\t\t\t// show metres when distance is < 1km, then show km\r\n\t\t\t\t\tif (distance > 1000) {\r\n\t\t\t\t\t\tdistanceStr = L.GeometryUtil.formattedNumber(distance / 1000, precision['km']) + ' km';\r\n\t\t\t\t\t} else {\r\n\t\t\t\t\t\tdistanceStr = L.GeometryUtil.formattedNumber(distance, precision['m']) + ' m';\r\n\t\t\t\t\t}\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase 'feet':\r\n\t\t\t\t\tdistance *= 1.09361 * 3;\r\n\t\t\t\t\tdistanceStr = L.GeometryUtil.formattedNumber(distance, precision['ft']) + ' ft';\r\n\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase 'nauticalMile':\r\n\t\t\t\t\tdistance *= 0.53996;\r\n\t\t\t\t\tdistanceStr = L.GeometryUtil.formattedNumber(distance / 1000, precision['nm']) + ' nm';\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase 'yards':\r\n\t\t\t\tdefault:\r\n\t\t\t\t\tdistance *= 1.09361;\r\n\r\n\t\t\t\t\tif (distance > 1760) {\r\n\t\t\t\t\t\tdistanceStr = L.GeometryUtil.formattedNumber(distance / 1760, precision['mi']) + ' miles';\r\n\t\t\t\t\t} else {\r\n\t\t\t\t\t\tdistanceStr = L.GeometryUtil.formattedNumber(distance, precision['yd']) + ' yd';\r\n\t\t\t\t\t}\r\n\t\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t\treturn distanceStr;\r\n\t\t},\r\n\r\n\t\t// @method isVersion07x(): boolean\r\n\t\t// Returns true if the Leaflet version is 0.7.x, false otherwise.\r\n\t\tisVersion07x: function () {\r\n\t\t\tvar version = L.version.split('.');\r\n\t\t\t//If Version is == 0.7.*\r\n\t\t\treturn parseInt(version[0], 10) === 0 && parseInt(version[1], 10) === 7;\r\n\t\t},\r\n\t});\r\n\r\n})();\r\n","/**\r\n * @class L.LineUtil\r\n * @aka Util\r\n * @aka L.Utils\r\n */\r\nL.Util.extend(L.LineUtil, {\r\n\r\n\t// @method segmentsIntersect(): boolean\r\n\t// Checks to see if two line segments intersect. Does not handle degenerate cases.\r\n\t// http://compgeom.cs.uiuc.edu/~jeffe/teaching/373/notes/x06-sweepline.pdf\r\n\tsegmentsIntersect: function (/*Point*/ p, /*Point*/ p1, /*Point*/ p2, /*Point*/ p3) {\r\n\t\treturn this._checkCounterclockwise(p, p2, p3) !==\r\n\t\t\tthis._checkCounterclockwise(p1, p2, p3) &&\r\n\t\t\tthis._checkCounterclockwise(p, p1, p2) !==\r\n\t\t\tthis._checkCounterclockwise(p, p1, p3);\r\n\t},\r\n\r\n\t// check to see if points are in counterclockwise order\r\n\t_checkCounterclockwise: function (/*Point*/ p, /*Point*/ p1, /*Point*/ p2) {\r\n\t\treturn (p2.y - p.y) * (p1.x - p.x) > (p1.y - p.y) * (p2.x - p.x);\r\n\t}\r\n});\r\n","/**\r\n * @class L.Polyline\r\n * @aka Polyline\r\n */\r\nL.Polyline.include({\r\n\r\n\t// @method intersects(): boolean\r\n\t// Check to see if this polyline has any linesegments that intersect.\r\n\t// NOTE: does not support detecting intersection for degenerate cases.\r\n\tintersects: function () {\r\n\t\tvar points = this._getProjectedPoints(),\r\n\t\t\tlen = points ? points.length : 0,\r\n\t\t\ti, p, p1;\r\n\r\n\t\tif (this._tooFewPointsForIntersection()) {\r\n\t\t\treturn false;\r\n\t\t}\r\n\r\n\t\tfor (i = len - 1; i >= 3; i--) {\r\n\t\t\tp = points[i - 1];\r\n\t\t\tp1 = points[i];\r\n\r\n\r\n\t\t\tif (this._lineSegmentsIntersectsRange(p, p1, i - 2)) {\r\n\t\t\t\treturn true;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn false;\r\n\t},\r\n\r\n\t// @method newLatLngIntersects(): boolean\r\n\t// Check for intersection if new latlng was added to this polyline.\r\n\t// NOTE: does not support detecting intersection for degenerate cases.\r\n\tnewLatLngIntersects: function (latlng, skipFirst) {\r\n\t\t// Cannot check a polyline for intersecting lats/lngs when not added to the map\r\n\t\tif (!this._map) {\r\n\t\t\treturn false;\r\n\t\t}\r\n\r\n\t\treturn this.newPointIntersects(this._map.latLngToLayerPoint(latlng), skipFirst);\r\n\t},\r\n\r\n\t// @method newPointIntersects(): boolean\r\n\t// Check for intersection if new point was added to this polyline.\r\n\t// newPoint must be a layer point.\r\n\t// NOTE: does not support detecting intersection for degenerate cases.\r\n\tnewPointIntersects: function (newPoint, skipFirst) {\r\n\t\tvar points = this._getProjectedPoints(),\r\n\t\t\tlen = points ? points.length : 0,\r\n\t\t\tlastPoint = points ? points[len - 1] : null,\r\n\t\t\t// The previous previous line segment. Previous line segment doesn't need testing.\r\n\t\t\tmaxIndex = len - 2;\r\n\r\n\t\tif (this._tooFewPointsForIntersection(1)) {\r\n\t\t\treturn false;\r\n\t\t}\r\n\r\n\t\treturn this._lineSegmentsIntersectsRange(lastPoint, newPoint, maxIndex, skipFirst ? 1 : 0);\r\n\t},\r\n\r\n\t// Polylines with 2 sides can only intersect in cases where points are collinear (we don't support detecting these).\r\n\t// Cannot have intersection when < 3 line segments (< 4 points)\r\n\t_tooFewPointsForIntersection: function (extraPoints) {\r\n\t\tvar points = this._getProjectedPoints(),\r\n\t\t\tlen = points ? points.length : 0;\r\n\t\t// Increment length by extraPoints if present\r\n\t\tlen += extraPoints || 0;\r\n\r\n\t\treturn !points || len <= 3;\r\n\t},\r\n\r\n\t// Checks a line segment intersections with any line segments before its predecessor.\r\n\t// Don't need to check the predecessor as will never intersect.\r\n\t_lineSegmentsIntersectsRange: function (p, p1, maxIndex, minIndex) {\r\n\t\tvar points = this._getProjectedPoints(),\r\n\t\t\tp2, p3;\r\n\r\n\t\tminIndex = minIndex || 0;\r\n\r\n\t\t// Check all previous line segments (beside the immediately previous) for intersections\r\n\t\tfor (var j = maxIndex; j > minIndex; j--) {\r\n\t\t\tp2 = points[j - 1];\r\n\t\t\tp3 = points[j];\r\n\r\n\t\t\tif (L.LineUtil.segmentsIntersect(p, p1, p2, p3)) {\r\n\t\t\t\treturn true;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn false;\r\n\t},\r\n\r\n\t_getProjectedPoints: function () {\r\n\t\tif (!this._defaultShape) {\r\n\t\t\treturn this._originalPoints;\r\n\t\t}\r\n\t\tvar points = [],\r\n\t\t\t_shape = this._defaultShape();\r\n\r\n\t\tfor (var i = 0; i < _shape.length; i++) {\r\n\t\t\tpoints.push(this._map.latLngToLayerPoint(_shape[i]));\r\n\t\t}\r\n\t\treturn points;\r\n\t}\r\n});\r\n","/**\r\n * @class L.Polygon\r\n * @aka Polygon\r\n */\r\nL.Polygon.include({\r\n\r\n\t// @method intersects(): boolean\r\n\t// Checks a polygon for any intersecting line segments. Ignores holes.\r\n\tintersects: function () {\r\n\t\tvar polylineIntersects,\r\n\t\t\tpoints = this._getProjectedPoints(),\r\n\t\t\tlen, firstPoint, lastPoint, maxIndex;\r\n\r\n\t\tif (this._tooFewPointsForIntersection()) {\r\n\t\t\treturn false;\r\n\t\t}\r\n\r\n\t\tpolylineIntersects = L.Polyline.prototype.intersects.call(this);\r\n\r\n\t\t// If already found an intersection don't need to check for any more.\r\n\t\tif (polylineIntersects) {\r\n\t\t\treturn true;\r\n\t\t}\r\n\r\n\t\tlen = points.length;\r\n\t\tfirstPoint = points[0];\r\n\t\tlastPoint = points[len - 1];\r\n\t\tmaxIndex = len - 2;\r\n\r\n\t\t// Check the line segment between last and first point. Don't need to check the first line segment (minIndex = 1)\r\n\t\treturn this._lineSegmentsIntersectsRange(lastPoint, firstPoint, maxIndex, 1);\r\n\t}\r\n});\r\n","/**\r\n * @class L.Control.Draw\r\n * @aka L.Draw\r\n */\r\nL.Control.Draw = L.Control.extend({\r\n\r\n\t// Options\r\n\toptions: {\r\n\t\tposition: 'topleft',\r\n\t\tdraw: {},\r\n\t\tedit: false\r\n\t},\r\n\r\n\t// @method initialize(): void\r\n\t// Initializes draw control, toolbars from the options\r\n\tinitialize: function (options) {\r\n\t\tif (L.version < '0.7') {\r\n\t\t\tthrow new Error('Leaflet.draw 0.2.3+ requires Leaflet 0.7.0+. Download latest from https://github.com/Leaflet/Leaflet/');\r\n\t\t}\r\n\r\n\t\tL.Control.prototype.initialize.call(this, options);\r\n\r\n\t\tvar toolbar;\r\n\r\n\t\tthis._toolbars = {};\r\n\r\n\t\t// Initialize toolbars\r\n\t\tif (L.DrawToolbar && this.options.draw) {\r\n\t\t\ttoolbar = new L.DrawToolbar(this.options.draw);\r\n\r\n\t\t\tthis._toolbars[L.DrawToolbar.TYPE] = toolbar;\r\n\r\n\t\t\t// Listen for when toolbar is enabled\r\n\t\t\tthis._toolbars[L.DrawToolbar.TYPE].on('enable', this._toolbarEnabled, this);\r\n\t\t}\r\n\r\n\t\tif (L.EditToolbar && this.options.edit) {\r\n\t\t\ttoolbar = new L.EditToolbar(this.options.edit);\r\n\r\n\t\t\tthis._toolbars[L.EditToolbar.TYPE] = toolbar;\r\n\r\n\t\t\t// Listen for when toolbar is enabled\r\n\t\t\tthis._toolbars[L.EditToolbar.TYPE].on('enable', this._toolbarEnabled, this);\r\n\t\t}\r\n\t\tL.toolbar = this; //set global var for editing the toolbar\r\n\t},\r\n\r\n\t// @method onAdd(): container\r\n\t// Adds the toolbar container to the map\r\n\tonAdd: function (map) {\r\n\t\tvar container = L.DomUtil.create('div', 'leaflet-draw'),\r\n\t\t\taddedTopClass = false,\r\n\t\t\ttopClassName = 'leaflet-draw-toolbar-top',\r\n\t\t\ttoolbarContainer;\r\n\r\n\t\tfor (var toolbarId in this._toolbars) {\r\n\t\t\tif (this._toolbars.hasOwnProperty(toolbarId)) {\r\n\t\t\t\ttoolbarContainer = this._toolbars[toolbarId].addToolbar(map);\r\n\r\n\t\t\t\tif (toolbarContainer) {\r\n\t\t\t\t\t// Add class to the first toolbar to remove the margin\r\n\t\t\t\t\tif (!addedTopClass) {\r\n\t\t\t\t\t\tif (!L.DomUtil.hasClass(toolbarContainer, topClassName)) {\r\n\t\t\t\t\t\t\tL.DomUtil.addClass(toolbarContainer.childNodes[0], topClassName);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\taddedTopClass = true;\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tcontainer.appendChild(toolbarContainer);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn container;\r\n\t},\r\n\r\n\t// @method onRemove(): void\r\n\t// Removes the toolbars from the map toolbar container\r\n\tonRemove: function () {\r\n\t\tfor (var toolbarId in this._toolbars) {\r\n\t\t\tif (this._toolbars.hasOwnProperty(toolbarId)) {\r\n\t\t\t\tthis._toolbars[toolbarId].removeToolbar();\r\n\t\t\t}\r\n\t\t}\r\n\t},\r\n\r\n\t// @method setDrawingOptions(options): void\r\n\t// Sets options to all toolbar instances\r\n\tsetDrawingOptions: function (options) {\r\n\t\tfor (var toolbarId in this._toolbars) {\r\n\t\t\tif (this._toolbars[toolbarId] instanceof L.DrawToolbar) {\r\n\t\t\t\tthis._toolbars[toolbarId].setOptions(options);\r\n\t\t\t}\r\n\t\t}\r\n\t},\r\n\r\n\t_toolbarEnabled: function (e) {\r\n\t\tvar enabledToolbar = e.target;\r\n\r\n\t\tfor (var toolbarId in this._toolbars) {\r\n\t\t\tif (this._toolbars[toolbarId] !== enabledToolbar) {\r\n\t\t\t\tthis._toolbars[toolbarId].disable();\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n});\r\n\r\nL.Map.mergeOptions({\r\n\tdrawControlTooltips: true,\r\n\tdrawControl: false\r\n});\r\n\r\nL.Map.addInitHook(function () {\r\n\tif (this.options.drawControl) {\r\n\t\tthis.drawControl = new L.Control.Draw();\r\n\t\tthis.addControl(this.drawControl);\r\n\t}\r\n});\r\n","/**\r\n * @class L.Draw.Toolbar\r\n * @aka Toolbar\r\n *\r\n * The toolbar class of the API — it is used to create the ui\r\n * This will be depreciated\r\n *\r\n * @example\r\n *\r\n * ```js\r\n * var toolbar = L.Toolbar();\r\n * toolbar.addToolbar(map);\r\n * ```\r\n *\r\n * ### Disabling a toolbar\r\n *\r\n * If you do not want a particular toolbar in your app you can turn it off by setting the toolbar to false.\r\n *\r\n * ```js\r\n * var drawControl = new L.Control.Draw({\r\n * draw: false,\r\n * edit: {\r\n * featureGroup: editableLayers\r\n * }\r\n * });\r\n * ```\r\n *\r\n * ### Disabling a toolbar item\r\n *\r\n * If you want to turn off a particular toolbar item, set it to false. The following disables drawing polygons and\r\n * markers. It also turns off the ability to edit layers.\r\n *\r\n * ```js\r\n * var drawControl = new L.Control.Draw({\r\n * draw: {\r\n * polygon: false,\r\n * marker: false\r\n * },\r\n * edit: {\r\n * featureGroup: editableLayers,\r\n * edit: false\r\n * }\r\n * });\r\n * ```\r\n */\r\nL.Toolbar = L.Class.extend({\r\n\t// @section Methods for modifying the toolbar\r\n\r\n\t// @method initialize(options): void\r\n\t// Toolbar constructor\r\n\tinitialize: function (options) {\r\n\t\tL.setOptions(this, options);\r\n\r\n\t\tthis._modes = {};\r\n\t\tthis._actionButtons = [];\r\n\t\tthis._activeMode = null;\r\n\r\n\t\tvar version = L.version.split('.');\r\n\t\t//If Version is >= 1.2.0\r\n\t\tif (parseInt(version[0], 10) === 1 && parseInt(version[1], 10) >= 2) {\r\n\t\t\tL.Toolbar.include(L.Evented.prototype);\r\n\t\t} else {\r\n\t\t\tL.Toolbar.include(L.Mixin.Events);\r\n\t\t}\r\n\t},\r\n\r\n\t// @method enabled(): boolean\r\n\t// Gets a true/false of whether the toolbar is enabled\r\n\tenabled: function () {\r\n\t\treturn this._activeMode !== null;\r\n\t},\r\n\r\n\t// @method disable(): void\r\n\t// Disables the toolbar\r\n\tdisable: function () {\r\n\t\tif (!this.enabled()) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tthis._activeMode.handler.disable();\r\n\t},\r\n\r\n\t// @method addToolbar(map): L.DomUtil\r\n\t// Adds the toolbar to the map and returns the toolbar dom element\r\n\taddToolbar: function (map) {\r\n\t\tvar container = L.DomUtil.create('div', 'leaflet-draw-section'),\r\n\t\t\tbuttonIndex = 0,\r\n\t\t\tbuttonClassPrefix = this._toolbarClass || '',\r\n\t\t\tmodeHandlers = this.getModeHandlers(map),\r\n\t\t\ti;\r\n\r\n\t\tthis._toolbarContainer = L.DomUtil.create('div', 'leaflet-draw-toolbar leaflet-bar');\r\n\t\tthis._map = map;\r\n\r\n\t\tfor (i = 0; i < modeHandlers.length; i++) {\r\n\t\t\tif (modeHandlers[i].enabled) {\r\n\t\t\t\tthis._initModeHandler(\r\n\t\t\t\t\tmodeHandlers[i].handler,\r\n\t\t\t\t\tthis._toolbarContainer,\r\n\t\t\t\t\tbuttonIndex++,\r\n\t\t\t\t\tbuttonClassPrefix,\r\n\t\t\t\t\tmodeHandlers[i].title\r\n\t\t\t\t);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// if no buttons were added, do not add the toolbar\r\n\t\tif (!buttonIndex) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\t// Save button index of the last button, -1 as we would have ++ after the last button\r\n\t\tthis._lastButtonIndex = --buttonIndex;\r\n\r\n\t\t// Create empty actions part of the toolbar\r\n\t\tthis._actionsContainer = L.DomUtil.create('ul', 'leaflet-draw-actions');\r\n\r\n\t\t// Add draw and cancel containers to the control container\r\n\t\tcontainer.appendChild(this._toolbarContainer);\r\n\t\tcontainer.appendChild(this._actionsContainer);\r\n\r\n\t\treturn container;\r\n\t},\r\n\r\n\t// @method removeToolbar(): void\r\n\t// Removes the toolbar and drops the handler event listeners\r\n\tremoveToolbar: function () {\r\n\t\t// Dispose each handler\r\n\t\tfor (var handlerId in this._modes) {\r\n\t\t\tif (this._modes.hasOwnProperty(handlerId)) {\r\n\t\t\t\t// Unbind handler button\r\n\t\t\t\tthis._disposeButton(\r\n\t\t\t\t\tthis._modes[handlerId].button,\r\n\t\t\t\t\tthis._modes[handlerId].handler.enable,\r\n\t\t\t\t\tthis._modes[handlerId].handler\r\n\t\t\t\t);\r\n\r\n\t\t\t\t// Make sure is disabled\r\n\t\t\t\tthis._modes[handlerId].handler.disable();\r\n\r\n\t\t\t\t// Unbind handler\r\n\t\t\t\tthis._modes[handlerId].handler\r\n\t\t\t\t\t.off('enabled', this._handlerActivated, this)\r\n\t\t\t\t\t.off('disabled', this._handlerDeactivated, this);\r\n\t\t\t}\r\n\t\t}\r\n\t\tthis._modes = {};\r\n\r\n\t\t// Dispose the actions toolbar\r\n\t\tfor (var i = 0, l = this._actionButtons.length; i < l; i++) {\r\n\t\t\tthis._disposeButton(\r\n\t\t\t\tthis._actionButtons[i].button,\r\n\t\t\t\tthis._actionButtons[i].callback,\r\n\t\t\t\tthis\r\n\t\t\t);\r\n\t\t}\r\n\t\tthis._actionButtons = [];\r\n\t\tthis._actionsContainer = null;\r\n\t},\r\n\r\n\t_initModeHandler: function (handler, container, buttonIndex, classNamePredix, buttonTitle) {\r\n\t\tvar type = handler.type;\r\n\r\n\t\tthis._modes[type] = {};\r\n\r\n\t\tthis._modes[type].handler = handler;\r\n\r\n\t\tthis._modes[type].button = this._createButton({\r\n\t\t\ttype: type,\r\n\t\t\ttitle: buttonTitle,\r\n\t\t\tclassName: classNamePredix + '-' + type,\r\n\t\t\tcontainer: container,\r\n\t\t\tcallback: this._modes[type].handler.enable,\r\n\t\t\tcontext: this._modes[type].handler\r\n\t\t});\r\n\r\n\t\tthis._modes[type].buttonIndex = buttonIndex;\r\n\r\n\t\tthis._modes[type].handler\r\n\t\t\t.on('enabled', this._handlerActivated, this)\r\n\t\t\t.on('disabled', this._handlerDeactivated, this);\r\n\t},\r\n\r\n\t/* Detect iOS based on browser User Agent, based on:\r\n\t * http://stackoverflow.com/a/9039885 */\r\n\t_detectIOS: function () {\r\n\t\tvar iOS = (/iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream);\r\n\t\treturn iOS;\r\n\t},\r\n\r\n\t_createButton: function (options) {\r\n\r\n\t\tvar link = L.DomUtil.create('a', options.className || '', options.container);\r\n\t\t// Screen reader tag\r\n\t\tvar sr = L.DomUtil.create('span', 'sr-only', options.container);\r\n\r\n\t\tlink.href = '#';\r\n\t\tlink.appendChild(sr);\r\n\r\n\t\tif (options.title) {\r\n\t\t\tlink.title = options.title;\r\n\t\t\tsr.innerHTML = options.title;\r\n\t\t}\r\n\r\n\t\tif (options.text) {\r\n\t\t\tlink.innerHTML = options.text;\r\n\t\t\tsr.innerHTML = options.text;\r\n\t\t}\r\n\r\n\t\t/* iOS does not use click events */\r\n\t\tvar buttonEvent = this._detectIOS() ? 'touchstart' : 'click';\r\n\r\n\t\tL.DomEvent\r\n\t\t\t.on(link, 'click', L.DomEvent.stopPropagation)\r\n\t\t\t.on(link, 'mousedown', L.DomEvent.stopPropagation)\r\n\t\t\t.on(link, 'dblclick', L.DomEvent.stopPropagation)\r\n\t\t\t.on(link, 'touchstart', L.DomEvent.stopPropagation)\r\n\t\t\t.on(link, 'click', L.DomEvent.preventDefault)\r\n\t\t\t.on(link, buttonEvent, options.callback, options.context);\r\n\r\n\t\treturn link;\r\n\t},\r\n\r\n\t_disposeButton: function (button, callback) {\r\n\t\t/* iOS does not use click events */\r\n\t\tvar buttonEvent = this._detectIOS() ? 'touchstart' : 'click';\r\n\r\n\t\tL.DomEvent\r\n\t\t\t.off(button, 'click', L.DomEvent.stopPropagation)\r\n\t\t\t.off(button, 'mousedown', L.DomEvent.stopPropagation)\r\n\t\t\t.off(button, 'dblclick', L.DomEvent.stopPropagation)\r\n\t\t\t.off(button, 'touchstart', L.DomEvent.stopPropagation)\r\n\t\t\t.off(button, 'click', L.DomEvent.preventDefault)\r\n\t\t\t.off(button, buttonEvent, callback);\r\n\t},\r\n\r\n\t_handlerActivated: function (e) {\r\n\t\t// Disable active mode (if present)\r\n\t\tthis.disable();\r\n\r\n\t\t// Cache new active feature\r\n\t\tthis._activeMode = this._modes[e.handler];\r\n\r\n\t\tL.DomUtil.addClass(this._activeMode.button, 'leaflet-draw-toolbar-button-enabled');\r\n\r\n\t\tthis._showActionsToolbar();\r\n\r\n\t\tthis.fire('enable');\r\n\t},\r\n\r\n\t_handlerDeactivated: function () {\r\n\t\tthis._hideActionsToolbar();\r\n\r\n\t\tL.DomUtil.removeClass(this._activeMode.button, 'leaflet-draw-toolbar-button-enabled');\r\n\r\n\t\tthis._activeMode = null;\r\n\r\n\t\tthis.fire('disable');\r\n\t},\r\n\r\n\t_createActions: function (handler) {\r\n\t\tvar container = this._actionsContainer,\r\n\t\t\tbuttons = this.getActions(handler),\r\n\t\t\tl = buttons.length,\r\n\t\t\tli, di, dl, button;\r\n\r\n\t\t// Dispose the actions toolbar (todo: dispose only not used buttons)\r\n\t\tfor (di = 0, dl = this._actionButtons.length; di < dl; di++) {\r\n\t\t\tthis._disposeButton(this._actionButtons[di].button, this._actionButtons[di].callback);\r\n\t\t}\r\n\t\tthis._actionButtons = [];\r\n\r\n\t\t// Remove all old buttons\r\n\t\twhile (container.firstChild) {\r\n\t\t\tcontainer.removeChild(container.firstChild);\r\n\t\t}\r\n\r\n\t\tfor (var i = 0; i < l; i++) {\r\n\t\t\tif ('enabled' in buttons[i] && !buttons[i].enabled) {\r\n\t\t\t\tcontinue;\r\n\t\t\t}\r\n\r\n\t\t\tli = L.DomUtil.create('li', '', container);\r\n\r\n\t\t\tbutton = this._createButton({\r\n\t\t\t\ttitle: buttons[i].title,\r\n\t\t\t\ttext: buttons[i].text,\r\n\t\t\t\tcontainer: li,\r\n\t\t\t\tcallback: buttons[i].callback,\r\n\t\t\t\tcontext: buttons[i].context\r\n\t\t\t});\r\n\r\n\t\t\tthis._actionButtons.push({\r\n\t\t\t\tbutton: button,\r\n\t\t\t\tcallback: buttons[i].callback\r\n\t\t\t});\r\n\t\t}\r\n\t},\r\n\r\n\t_showActionsToolbar: function () {\r\n\t\tvar buttonIndex = this._activeMode.buttonIndex,\r\n\t\t\tlastButtonIndex = this._lastButtonIndex,\r\n\t\t\ttoolbarPosition = this._activeMode.button.offsetTop - 1;\r\n\r\n\t\t// Recreate action buttons on every click\r\n\t\tthis._createActions(this._activeMode.handler);\r\n\r\n\t\t// Correctly position the cancel button\r\n\t\tthis._actionsContainer.style.top = toolbarPosition + 'px';\r\n\r\n\t\tif (buttonIndex === 0) {\r\n\t\t\tL.DomUtil.addClass(this._toolbarContainer, 'leaflet-draw-toolbar-notop');\r\n\t\t\tL.DomUtil.addClass(this._actionsContainer, 'leaflet-draw-actions-top');\r\n\t\t}\r\n\r\n\t\tif (buttonIndex === lastButtonIndex) {\r\n\t\t\tL.DomUtil.addClass(this._toolbarContainer, 'leaflet-draw-toolbar-nobottom');\r\n\t\t\tL.DomUtil.addClass(this._actionsContainer, 'leaflet-draw-actions-bottom');\r\n\t\t}\r\n\r\n\t\tthis._actionsContainer.style.display = 'block';\r\n\t\tthis._map.fire(L.Draw.Event.TOOLBAROPENED);\r\n\t},\r\n\r\n\t_hideActionsToolbar: function () {\r\n\t\tthis._actionsContainer.style.display = 'none';\r\n\r\n\t\tL.DomUtil.removeClass(this._toolbarContainer, 'leaflet-draw-toolbar-notop');\r\n\t\tL.DomUtil.removeClass(this._toolbarContainer, 'leaflet-draw-toolbar-nobottom');\r\n\t\tL.DomUtil.removeClass(this._actionsContainer, 'leaflet-draw-actions-top');\r\n\t\tL.DomUtil.removeClass(this._actionsContainer, 'leaflet-draw-actions-bottom');\r\n\t\tthis._map.fire(L.Draw.Event.TOOLBARCLOSED);\r\n\t}\r\n});\r\n","L.Draw = L.Draw || {};\r\n/**\r\n * @class L.Draw.Tooltip\r\n * @aka Tooltip\r\n *\r\n * The tooltip class — it is used to display the tooltip while drawing\r\n * This will be depreciated\r\n *\r\n * @example\r\n *\r\n * ```js\r\n * var tooltip = L.Draw.Tooltip();\r\n * ```\r\n *\r\n */\r\nL.Draw.Tooltip = L.Class.extend({\r\n\r\n\t// @section Methods for modifying draw state\r\n\r\n\t// @method initialize(map): void\r\n\t// Tooltip constructor\r\n\tinitialize: function (map) {\r\n\t\tthis._map = map;\r\n\t\tthis._popupPane = map._panes.popupPane;\r\n\t\tthis._visible = false;\r\n\r\n\t\tthis._container = map.options.drawControlTooltips ?\r\n\t\t\tL.DomUtil.create('div', 'leaflet-draw-tooltip', this._popupPane) : null;\r\n\t\tthis._singleLineLabel = false;\r\n\r\n\t\tthis._map.on('mouseout', this._onMouseOut, this);\r\n\t},\r\n\r\n\t// @method dispose(): void\r\n\t// Remove Tooltip DOM and unbind events\r\n\tdispose: function () {\r\n\t\tthis._map.off('mouseout', this._onMouseOut, this);\r\n\r\n\t\tif (this._container) {\r\n\t\t\tthis._popupPane.removeChild(this._container);\r\n\t\t\tthis._container = null;\r\n\t\t}\r\n\t},\r\n\r\n\t// @method updateContent(labelText): this\r\n\t// Changes the tooltip text to string in function call\r\n\tupdateContent: function (labelText) {\r\n\t\tif (!this._container) {\r\n\t\t\treturn this;\r\n\t\t}\r\n\t\tlabelText.subtext = labelText.subtext || '';\r\n\r\n\t\t// update the vertical position (only if changed)\r\n\t\tif (labelText.subtext.length === 0 && !this._singleLineLabel) {\r\n\t\t\tL.DomUtil.addClass(this._container, 'leaflet-draw-tooltip-single');\r\n\t\t\tthis._singleLineLabel = true;\r\n\t\t}\r\n\t\telse if (labelText.subtext.length > 0 && this._singleLineLabel) {\r\n\t\t\tL.DomUtil.removeClass(this._container, 'leaflet-draw-tooltip-single');\r\n\t\t\tthis._singleLineLabel = false;\r\n\t\t}\r\n\r\n\t\tthis._container.innerHTML =\r\n\t\t\t(labelText.subtext.length > 0 ?\r\n\t\t\t\t'' + labelText.subtext + '' + '
' : '') +\r\n\t\t\t'' + labelText.text + '';\r\n\r\n\t\tif (!labelText.text && !labelText.subtext) {\r\n\t\t\tthis._visible = false;\r\n\t\t\tthis._container.style.visibility = 'hidden';\r\n\t\t} else {\r\n\t\t\tthis._visible = true;\r\n\t\t\tthis._container.style.visibility = 'inherit';\r\n\t\t}\r\n\r\n\t\treturn this;\r\n\t},\r\n\r\n\t// @method updatePosition(latlng): this\r\n\t// Changes the location of the tooltip\r\n\tupdatePosition: function (latlng) {\r\n\t\tvar pos = this._map.latLngToLayerPoint(latlng),\r\n\t\t\ttooltipContainer = this._container;\r\n\r\n\t\tif (this._container) {\r\n\t\t\tif (this._visible) {\r\n\t\t\t\ttooltipContainer.style.visibility = 'inherit';\r\n\t\t\t}\r\n\t\t\tL.DomUtil.setPosition(tooltipContainer, pos);\r\n\t\t}\r\n\r\n\t\treturn this;\r\n\t},\r\n\r\n\t// @method showAsError(): this\r\n\t// Applies error class to tooltip\r\n\tshowAsError: function () {\r\n\t\tif (this._container) {\r\n\t\t\tL.DomUtil.addClass(this._container, 'leaflet-error-draw-tooltip');\r\n\t\t}\r\n\t\treturn this;\r\n\t},\r\n\r\n\t// @method removeError(): this\r\n\t// Removes the error class from the tooltip\r\n\tremoveError: function () {\r\n\t\tif (this._container) {\r\n\t\t\tL.DomUtil.removeClass(this._container, 'leaflet-error-draw-tooltip');\r\n\t\t}\r\n\t\treturn this;\r\n\t},\r\n\r\n\t_onMouseOut: function () {\r\n\t\tif (this._container) {\r\n\t\t\tthis._container.style.visibility = 'hidden';\r\n\t\t}\r\n\t}\r\n});\r\n","/**\r\n * @class L.DrawToolbar\r\n * @aka Toolbar\r\n */\r\nL.DrawToolbar = L.Toolbar.extend({\r\n\r\n\tstatics: {\r\n\t\tTYPE: 'draw'\r\n\t},\r\n\r\n\toptions: {\r\n\t\tpolyline: {},\r\n\t\tpolygon: {},\r\n\t\trectangle: {},\r\n\t\tcircle: {},\r\n\t\tmarker: {},\r\n\t\tcirclemarker: {}\r\n\t},\r\n\r\n\t// @method initialize(): void\r\n\tinitialize: function (options) {\r\n\t\t// Ensure that the options are merged correctly since L.extend is only shallow\r\n\t\tfor (var type in this.options) {\r\n\t\t\tif (this.options.hasOwnProperty(type)) {\r\n\t\t\t\tif (options[type]) {\r\n\t\t\t\t\toptions[type] = L.extend({}, this.options[type], options[type]);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tthis._toolbarClass = 'leaflet-draw-draw';\r\n\t\tL.Toolbar.prototype.initialize.call(this, options);\r\n\t},\r\n\r\n\t// @method getModeHandlers(): object\r\n\t// Get mode handlers information\r\n\tgetModeHandlers: function (map) {\r\n\t\treturn [\r\n\t\t\t{\r\n\t\t\t\tenabled: this.options.polyline,\r\n\t\t\t\thandler: new L.Draw.Polyline(map, this.options.polyline),\r\n\t\t\t\ttitle: L.drawLocal.draw.toolbar.buttons.polyline\r\n\t\t\t},\r\n\t\t\t{\r\n\t\t\t\tenabled: this.options.polygon,\r\n\t\t\t\thandler: new L.Draw.Polygon(map, this.options.polygon),\r\n\t\t\t\ttitle: L.drawLocal.draw.toolbar.buttons.polygon\r\n\t\t\t},\r\n\t\t\t{\r\n\t\t\t\tenabled: this.options.rectangle,\r\n\t\t\t\thandler: new L.Draw.Rectangle(map, this.options.rectangle),\r\n\t\t\t\ttitle: L.drawLocal.draw.toolbar.buttons.rectangle\r\n\t\t\t},\r\n\t\t\t{\r\n\t\t\t\tenabled: this.options.circle,\r\n\t\t\t\thandler: new L.Draw.Circle(map, this.options.circle),\r\n\t\t\t\ttitle: L.drawLocal.draw.toolbar.buttons.circle\r\n\t\t\t},\r\n\t\t\t{\r\n\t\t\t\tenabled: this.options.marker,\r\n\t\t\t\thandler: new L.Draw.Marker(map, this.options.marker),\r\n\t\t\t\ttitle: L.drawLocal.draw.toolbar.buttons.marker\r\n\t\t\t},\r\n\t\t\t{\r\n\t\t\t\tenabled: this.options.circlemarker,\r\n\t\t\t\thandler: new L.Draw.CircleMarker(map, this.options.circlemarker),\r\n\t\t\t\ttitle: L.drawLocal.draw.toolbar.buttons.circlemarker\r\n\t\t\t}\r\n\t\t];\r\n\t},\r\n\r\n\t// @method getActions(): object\r\n\t// Get action information\r\n\tgetActions: function (handler) {\r\n\t\treturn [\r\n\t\t\t{\r\n\t\t\t\tenabled: handler.completeShape,\r\n\t\t\t\ttitle: L.drawLocal.draw.toolbar.finish.title,\r\n\t\t\t\ttext: L.drawLocal.draw.toolbar.finish.text,\r\n\t\t\t\tcallback: handler.completeShape,\r\n\t\t\t\tcontext: handler\r\n\t\t\t},\r\n\t\t\t{\r\n\t\t\t\tenabled: handler.deleteLastVertex,\r\n\t\t\t\ttitle: L.drawLocal.draw.toolbar.undo.title,\r\n\t\t\t\ttext: L.drawLocal.draw.toolbar.undo.text,\r\n\t\t\t\tcallback: handler.deleteLastVertex,\r\n\t\t\t\tcontext: handler\r\n\t\t\t},\r\n\t\t\t{\r\n\t\t\t\ttitle: L.drawLocal.draw.toolbar.actions.title,\r\n\t\t\t\ttext: L.drawLocal.draw.toolbar.actions.text,\r\n\t\t\t\tcallback: this.disable,\r\n\t\t\t\tcontext: this\r\n\t\t\t}\r\n\t\t];\r\n\t},\r\n\r\n\t// @method setOptions(): void\r\n\t// Sets the options to the toolbar\r\n\tsetOptions: function (options) {\r\n\t\tL.setOptions(this, options);\r\n\r\n\t\tfor (var type in this._modes) {\r\n\t\t\tif (this._modes.hasOwnProperty(type) && options.hasOwnProperty(type)) {\r\n\t\t\t\tthis._modes[type].handler.setOptions(options[type]);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n});\r\n","/*L.Map.mergeOptions({\r\n editControl: true\r\n });*/\r\n/**\r\n * @class L.EditToolbar\r\n * @aka EditToolbar\r\n */\r\nL.EditToolbar = L.Toolbar.extend({\r\n\tstatics: {\r\n\t\tTYPE: 'edit'\r\n\t},\r\n\r\n\toptions: {\r\n\t\tedit: {\r\n\t\t\tselectedPathOptions: {\r\n\t\t\t\tdashArray: '10, 10',\r\n\r\n\t\t\t\tfill: true,\r\n\t\t\t\tfillColor: '#fe57a1',\r\n\t\t\t\tfillOpacity: 0.1,\r\n\r\n\t\t\t\t// Whether to user the existing layers color\r\n\t\t\t\tmaintainColor: false\r\n\t\t\t}\r\n\t\t},\r\n\t\tremove: {},\r\n\t\tpoly: null,\r\n\t\tfeatureGroup: null /* REQUIRED! TODO: perhaps if not set then all layers on the map are selectable? */\r\n\t},\r\n\r\n\t// @method intialize(): void\r\n\tinitialize: function (options) {\r\n\t\t// Need to set this manually since null is an acceptable value here\r\n\t\tif (options.edit) {\r\n\t\t\tif (typeof options.edit.selectedPathOptions === 'undefined') {\r\n\t\t\t\toptions.edit.selectedPathOptions = this.options.edit.selectedPathOptions;\r\n\t\t\t}\r\n\t\t\toptions.edit.selectedPathOptions = L.extend({}, this.options.edit.selectedPathOptions, options.edit.selectedPathOptions);\r\n\t\t}\r\n\r\n\t\tif (options.remove) {\r\n\t\t\toptions.remove = L.extend({}, this.options.remove, options.remove);\r\n\t\t}\r\n\r\n\t\tif (options.poly) {\r\n\t\t\toptions.poly = L.extend({}, this.options.poly, options.poly);\r\n\t\t}\r\n\r\n\t\tthis._toolbarClass = 'leaflet-draw-edit';\r\n\t\tL.Toolbar.prototype.initialize.call(this, options);\r\n\r\n\t\tthis._selectedFeatureCount = 0;\r\n\t},\r\n\r\n\t// @method getModeHandlers(): object\r\n\t// Get mode handlers information\r\n\tgetModeHandlers: function (map) {\r\n\t\tvar featureGroup = this.options.featureGroup;\r\n\t\treturn [\r\n\t\t\t{\r\n\t\t\t\tenabled: this.options.edit,\r\n\t\t\t\thandler: new L.EditToolbar.Edit(map, {\r\n\t\t\t\t\tfeatureGroup: featureGroup,\r\n\t\t\t\t\tselectedPathOptions: this.options.edit.selectedPathOptions,\r\n\t\t\t\t\tpoly: this.options.poly\r\n\t\t\t\t}),\r\n\t\t\t\ttitle: L.drawLocal.edit.toolbar.buttons.edit\r\n\t\t\t},\r\n\t\t\t{\r\n\t\t\t\tenabled: this.options.remove,\r\n\t\t\t\thandler: new L.EditToolbar.Delete(map, {\r\n\t\t\t\t\tfeatureGroup: featureGroup\r\n\t\t\t\t}),\r\n\t\t\t\ttitle: L.drawLocal.edit.toolbar.buttons.remove\r\n\t\t\t}\r\n\t\t];\r\n\t},\r\n\r\n\t// @method getActions(): object\r\n\t// Get actions information\r\n\tgetActions: function (handler) {\r\n\t\tvar actions = [\r\n\t\t\t{\r\n\t\t\t\ttitle: L.drawLocal.edit.toolbar.actions.save.title,\r\n\t\t\t\ttext: L.drawLocal.edit.toolbar.actions.save.text,\r\n\t\t\t\tcallback: this._save,\r\n\t\t\t\tcontext: this\r\n\t\t\t},\r\n\t\t\t{\r\n\t\t\t\ttitle: L.drawLocal.edit.toolbar.actions.cancel.title,\r\n\t\t\t\ttext: L.drawLocal.edit.toolbar.actions.cancel.text,\r\n\t\t\t\tcallback: this.disable,\r\n\t\t\t\tcontext: this\r\n\t\t\t}\r\n\t\t];\r\n\r\n\t\tif (handler.removeAllLayers) {\r\n\t\t\tactions.push({\r\n\t\t\t\ttitle: L.drawLocal.edit.toolbar.actions.clearAll.title,\r\n\t\t\t\ttext: L.drawLocal.edit.toolbar.actions.clearAll.text,\r\n\t\t\t\tcallback: this._clearAllLayers,\r\n\t\t\t\tcontext: this\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\treturn actions;\r\n\t},\r\n\r\n\t// @method addToolbar(map): L.DomUtil\r\n\t// Adds the toolbar to the map\r\n\taddToolbar: function (map) {\r\n\t\tvar container = L.Toolbar.prototype.addToolbar.call(this, map);\r\n\r\n\t\tthis._checkDisabled();\r\n\r\n\t\tthis.options.featureGroup.on('layeradd layerremove', this._checkDisabled, this);\r\n\r\n\t\treturn container;\r\n\t},\r\n\r\n\t// @method removeToolbar(): void\r\n\t// Removes the toolbar from the map\r\n\tremoveToolbar: function () {\r\n\t\tthis.options.featureGroup.off('layeradd layerremove', this._checkDisabled, this);\r\n\r\n\t\tL.Toolbar.prototype.removeToolbar.call(this);\r\n\t},\r\n\r\n\t// @method disable(): void\r\n\t// Disables the toolbar\r\n\tdisable: function () {\r\n\t\tif (!this.enabled()) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tthis._activeMode.handler.revertLayers();\r\n\r\n\t\tL.Toolbar.prototype.disable.call(this);\r\n\t},\r\n\r\n\t_save: function () {\r\n\t\tthis._activeMode.handler.save();\r\n\t\tif (this._activeMode) {\r\n\t\t\tthis._activeMode.handler.disable();\r\n\t\t}\r\n\t},\r\n\r\n\t_clearAllLayers: function () {\r\n\t\tthis._activeMode.handler.removeAllLayers();\r\n\t\tif (this._activeMode) {\r\n\t\t\tthis._activeMode.handler.disable();\r\n\t\t}\r\n\t},\r\n\r\n\t_checkDisabled: function () {\r\n\t\tvar featureGroup = this.options.featureGroup,\r\n\t\t\thasLayers = featureGroup.getLayers().length !== 0,\r\n\t\t\tbutton;\r\n\r\n\t\tif (this.options.edit) {\r\n\t\t\tbutton = this._modes[L.EditToolbar.Edit.TYPE].button;\r\n\r\n\t\t\tif (hasLayers) {\r\n\t\t\t\tL.DomUtil.removeClass(button, 'leaflet-disabled');\r\n\t\t\t} else {\r\n\t\t\t\tL.DomUtil.addClass(button, 'leaflet-disabled');\r\n\t\t\t}\r\n\r\n\t\t\tbutton.setAttribute(\r\n\t\t\t\t'title',\r\n\t\t\t\thasLayers ?\r\n\t\t\t\t\tL.drawLocal.edit.toolbar.buttons.edit\r\n\t\t\t\t\t: L.drawLocal.edit.toolbar.buttons.editDisabled\r\n\t\t\t);\r\n\t\t}\r\n\r\n\t\tif (this.options.remove) {\r\n\t\t\tbutton = this._modes[L.EditToolbar.Delete.TYPE].button;\r\n\r\n\t\t\tif (hasLayers) {\r\n\t\t\t\tL.DomUtil.removeClass(button, 'leaflet-disabled');\r\n\t\t\t} else {\r\n\t\t\t\tL.DomUtil.addClass(button, 'leaflet-disabled');\r\n\t\t\t}\r\n\r\n\t\t\tbutton.setAttribute(\r\n\t\t\t\t'title',\r\n\t\t\t\thasLayers ?\r\n\t\t\t\t\tL.drawLocal.edit.toolbar.buttons.remove\r\n\t\t\t\t\t: L.drawLocal.edit.toolbar.buttons.removeDisabled\r\n\t\t\t);\r\n\t\t}\r\n\t}\r\n});\r\n","/**\r\n * @class L.EditToolbar.Edit\r\n * @aka EditToolbar.Edit\r\n */\r\nL.EditToolbar.Edit = L.Handler.extend({\r\n\tstatics: {\r\n\t\tTYPE: 'edit'\r\n\t},\r\n\r\n\t// @method intialize(): void\r\n\tinitialize: function (map, options) {\r\n\t\tL.Handler.prototype.initialize.call(this, map);\r\n\r\n\t\tL.setOptions(this, options);\r\n\r\n\t\t// Store the selectable layer group for ease of access\r\n\t\tthis._featureGroup = options.featureGroup;\r\n\r\n\t\tif (!(this._featureGroup instanceof L.FeatureGroup)) {\r\n\t\t\tthrow new Error('options.featureGroup must be a L.FeatureGroup');\r\n\t\t}\r\n\r\n\t\tthis._uneditedLayerProps = {};\r\n\r\n\t\t// Save the type so super can fire, need to do this as cannot do this.TYPE :(\r\n\t\tthis.type = L.EditToolbar.Edit.TYPE;\r\n\r\n\t\tvar version = L.version.split('.');\r\n\t\t//If Version is >= 1.2.0\r\n\t\tif (parseInt(version[0], 10) === 1 && parseInt(version[1], 10) >= 2) {\r\n\t\t\tL.EditToolbar.Edit.include(L.Evented.prototype);\r\n\t\t} else {\r\n\t\t\tL.EditToolbar.Edit.include(L.Mixin.Events);\r\n\t\t}\r\n\t},\r\n\r\n\t// @method enable(): void\r\n\t// Enable the edit toolbar\r\n\tenable: function () {\r\n\t\tif (this._enabled || !this._hasAvailableLayers()) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tthis.fire('enabled', {handler: this.type});\r\n\t\t//this disable other handlers\r\n\r\n\t\tthis._map.fire(L.Draw.Event.EDITSTART, {handler: this.type});\r\n\t\t//allow drawLayer to be updated before beginning edition.\r\n\r\n\t\tL.Handler.prototype.enable.call(this);\r\n\t\tthis._featureGroup\r\n\t\t\t.on('layeradd', this._enableLayerEdit, this)\r\n\t\t\t.on('layerremove', this._disableLayerEdit, this);\r\n\t},\r\n\r\n\t// @method disable(): void\r\n\t// Disable the edit toolbar\r\n\tdisable: function () {\r\n\t\tif (!this._enabled) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tthis._featureGroup\r\n\t\t\t.off('layeradd', this._enableLayerEdit, this)\r\n\t\t\t.off('layerremove', this._disableLayerEdit, this);\r\n\t\tL.Handler.prototype.disable.call(this);\r\n\t\tthis._map.fire(L.Draw.Event.EDITSTOP, {handler: this.type});\r\n\t\tthis.fire('disabled', {handler: this.type});\r\n\t},\r\n\r\n\t// @method addHooks(): void\r\n\t// Add listener hooks for this handler\r\n\taddHooks: function () {\r\n\t\tvar map = this._map;\r\n\r\n\t\tif (map) {\r\n\t\t\tmap.getContainer().focus();\r\n\r\n\t\t\tthis._featureGroup.eachLayer(this._enableLayerEdit, this);\r\n\r\n\t\t\tthis._tooltip = new L.Draw.Tooltip(this._map);\r\n\t\t\tthis._tooltip.updateContent({\r\n\t\t\t\ttext: L.drawLocal.edit.handlers.edit.tooltip.text,\r\n\t\t\t\tsubtext: L.drawLocal.edit.handlers.edit.tooltip.subtext\r\n\t\t\t});\r\n\r\n\t\t\t// Quickly access the tooltip to update for intersection checking\r\n\t\t\tmap._editTooltip = this._tooltip;\r\n\r\n\t\t\tthis._updateTooltip();\r\n\r\n\t\t\tthis._map\r\n\t\t\t\t.on('mousemove', this._onMouseMove, this)\r\n\t\t\t\t.on('touchmove', this._onMouseMove, this)\r\n\t\t\t\t.on('MSPointerMove', this._onMouseMove, this)\r\n\t\t\t\t.on(L.Draw.Event.EDITVERTEX, this._updateTooltip, this);\r\n\t\t}\r\n\t},\r\n\r\n\t// @method removeHooks(): void\r\n\t// Remove listener hooks for this handler\r\n\tremoveHooks: function () {\r\n\t\tif (this._map) {\r\n\t\t\t// Clean up selected layers.\r\n\t\t\tthis._featureGroup.eachLayer(this._disableLayerEdit, this);\r\n\t\t\tthis._map._editTooltip.dispose();\r\n\t\t\tthis._map._editTooltip = null;\r\n\t\t\t// Clear the backups of the original layers\r\n\t\t\tthis._uneditedLayerProps = {};\r\n\r\n\t\t\tthis._tooltip.dispose();\r\n\t\t\tthis._tooltip = null;\r\n\r\n\t\t\tthis._map\r\n\t\t\t\t.off('mousemove', this._onMouseMove, this)\r\n\t\t\t\t.off('touchmove', this._onMouseMove, this)\r\n\t\t\t\t.off('MSPointerMove', this._onMouseMove, this)\r\n\t\t\t\t.off(L.Draw.Event.EDITVERTEX, this._updateTooltip, this);\r\n\t\t}\r\n\t},\r\n\r\n\t// @method revertLayers(): void\r\n\t// Revert each layer's geometry changes\r\n\trevertLayers: function () {\r\n\t\tthis._featureGroup.eachLayer(function (layer) {\r\n\t\t\tthis._revertLayer(layer);\r\n\t\t}, this);\r\n\t},\r\n\r\n\t// @method save(): void\r\n\t// Save the layer geometries\r\n\tsave: function () {\r\n\t\tvar editedLayers = new L.LayerGroup();\r\n\t\tthis._featureGroup.eachLayer(function (layer) {\r\n\t\t\tif (layer.edited) {\r\n\t\t\t\teditedLayers.addLayer(layer);\r\n\t\t\t\tlayer.edited = false;\r\n\t\t\t}\r\n\t\t});\r\n\t\tthis._map.fire(L.Draw.Event.EDITED, {layers: editedLayers});\r\n\t},\r\n\r\n\t_backupLayer: function (layer) {\r\n\t\tvar id = L.Util.stamp(layer);\r\n\r\n\t\tif (!this._uneditedLayerProps[id]) {\r\n\t\t\t// Polyline, Polygon or Rectangle\r\n\t\t\tif (layer instanceof L.Polyline || layer instanceof L.Polygon || layer instanceof L.Rectangle) {\r\n\t\t\t\tthis._uneditedLayerProps[id] = {\r\n\t\t\t\t\tlatlngs: L.LatLngUtil.cloneLatLngs(layer.getLatLngs())\r\n\t\t\t\t};\r\n\t\t\t} else if (layer instanceof L.Circle) {\r\n\t\t\t\tthis._uneditedLayerProps[id] = {\r\n\t\t\t\t\tlatlng: L.LatLngUtil.cloneLatLng(layer.getLatLng()),\r\n\t\t\t\t\tradius: layer.getRadius()\r\n\t\t\t\t};\r\n\t\t\t} else if (layer instanceof L.Marker || layer instanceof L.CircleMarker) { // Marker\r\n\t\t\t\tthis._uneditedLayerProps[id] = {\r\n\t\t\t\t\tlatlng: L.LatLngUtil.cloneLatLng(layer.getLatLng())\r\n\t\t\t\t};\r\n\t\t\t}\r\n\t\t}\r\n\t},\r\n\r\n\t_getTooltipText: function () {\r\n\t\treturn ({\r\n\t\t\ttext: L.drawLocal.edit.handlers.edit.tooltip.text,\r\n\t\t\tsubtext: L.drawLocal.edit.handlers.edit.tooltip.subtext\r\n\t\t});\r\n\t},\r\n\r\n\t_updateTooltip: function () {\r\n\t\tthis._tooltip.updateContent(this._getTooltipText());\r\n\t},\r\n\r\n\t_revertLayer: function (layer) {\r\n\t\tvar id = L.Util.stamp(layer);\r\n\t\tlayer.edited = false;\r\n\t\tif (this._uneditedLayerProps.hasOwnProperty(id)) {\r\n\t\t\t// Polyline, Polygon or Rectangle\r\n\t\t\tif (layer instanceof L.Polyline || layer instanceof L.Polygon || layer instanceof L.Rectangle) {\r\n\t\t\t\tlayer.setLatLngs(this._uneditedLayerProps[id].latlngs);\r\n\t\t\t} else if (layer instanceof L.Circle) {\r\n\t\t\t\tlayer.setLatLng(this._uneditedLayerProps[id].latlng);\r\n\t\t\t\tlayer.setRadius(this._uneditedLayerProps[id].radius);\r\n\t\t\t} else if (layer instanceof L.Marker || layer instanceof L.CircleMarker) { // Marker or CircleMarker\r\n\t\t\t\tlayer.setLatLng(this._uneditedLayerProps[id].latlng);\r\n\t\t\t}\r\n\r\n\t\t\tlayer.fire('revert-edited', {layer: layer});\r\n\t\t}\r\n\t},\r\n\r\n\t_enableLayerEdit: function (e) {\r\n\t\tvar layer = e.layer || e.target || e,\r\n\t\t\tpathOptions, poly;\r\n\r\n\t\t// Back up this layer (if haven't before)\r\n\t\tthis._backupLayer(layer);\r\n\r\n\t\tif (this.options.poly) {\r\n\t\t\tpoly = L.Util.extend({}, this.options.poly);\r\n\t\t\tlayer.options.poly = poly;\r\n\t\t}\r\n\r\n\t\t// Set different style for editing mode\r\n\t\tif (this.options.selectedPathOptions) {\r\n\t\t\tpathOptions = L.Util.extend({}, this.options.selectedPathOptions);\r\n\r\n\t\t\t// Use the existing color of the layer\r\n\t\t\tif (pathOptions.maintainColor) {\r\n\t\t\t\tpathOptions.color = layer.options.color;\r\n\t\t\t\tpathOptions.fillColor = layer.options.fillColor;\r\n\t\t\t}\r\n\r\n\t\t\tlayer.options.original = L.extend({}, layer.options);\r\n\t\t\tlayer.options.editing = pathOptions;\r\n\r\n\t\t}\r\n\r\n\t\tif (layer instanceof L.Marker) {\r\n\t\t\tif (layer.editing) {\r\n\t\t\t\tlayer.editing.enable();\r\n\t\t\t}\r\n\t\t\tlayer.dragging.enable();\r\n\t\t\tlayer\r\n\t\t\t\t.on('dragend', this._onMarkerDragEnd)\r\n\t\t\t\t// #TODO: remove when leaflet finally fixes their draggable so it's touch friendly again.\r\n\t\t\t\t.on('touchmove', this._onTouchMove, this)\r\n\t\t\t\t.on('MSPointerMove', this._onTouchMove, this)\r\n\t\t\t\t.on('touchend', this._onMarkerDragEnd, this)\r\n\t\t\t\t.on('MSPointerUp', this._onMarkerDragEnd, this);\r\n\t\t} else {\r\n\t\t\tlayer.editing.enable();\r\n\t\t}\r\n\t},\r\n\r\n\t_disableLayerEdit: function (e) {\r\n\t\tvar layer = e.layer || e.target || e;\r\n\r\n\t\tlayer.edited = false;\r\n\t\tif (layer.editing) {\r\n\t\t\tlayer.editing.disable();\r\n\t\t}\r\n\r\n\t\tdelete layer.options.editing;\r\n\t\tdelete layer.options.original;\r\n\t\t// Reset layer styles to that of before select\r\n\t\tif (this._selectedPathOptions) {\r\n\t\t\tif (layer instanceof L.Marker) {\r\n\t\t\t\tthis._toggleMarkerHighlight(layer);\r\n\t\t\t} else {\r\n\t\t\t\t// reset the layer style to what is was before being selected\r\n\t\t\t\tlayer.setStyle(layer.options.previousOptions);\r\n\t\t\t\t// remove the cached options for the layer object\r\n\t\t\t\tdelete layer.options.previousOptions;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (layer instanceof L.Marker) {\r\n\t\t\tlayer.dragging.disable();\r\n\t\t\tlayer\r\n\t\t\t\t.off('dragend', this._onMarkerDragEnd, this)\r\n\t\t\t\t.off('touchmove', this._onTouchMove, this)\r\n\t\t\t\t.off('MSPointerMove', this._onTouchMove, this)\r\n\t\t\t\t.off('touchend', this._onMarkerDragEnd, this)\r\n\t\t\t\t.off('MSPointerUp', this._onMarkerDragEnd, this);\r\n\t\t} else {\r\n\t\t\tlayer.editing.disable();\r\n\t\t}\r\n\t},\r\n\r\n\t_onMouseMove: function (e) {\r\n\t\tthis._tooltip.updatePosition(e.latlng);\r\n\t},\r\n\r\n\t_onMarkerDragEnd: function (e) {\r\n\t\tvar layer = e.target;\r\n\t\tlayer.edited = true;\r\n\t\tthis._map.fire(L.Draw.Event.EDITMOVE, {layer: layer});\r\n\t},\r\n\r\n\t_onTouchMove: function (e) {\r\n\t\tvar touchEvent = e.originalEvent.changedTouches[0],\r\n\t\t\tlayerPoint = this._map.mouseEventToLayerPoint(touchEvent),\r\n\t\t\tlatlng = this._map.layerPointToLatLng(layerPoint);\r\n\t\te.target.setLatLng(latlng);\r\n\t},\r\n\r\n\t_hasAvailableLayers: function () {\r\n\t\treturn this._featureGroup.getLayers().length !== 0;\r\n\t}\r\n});\r\n","/**\r\n * @class L.EditToolbar.Delete\r\n * @aka EditToolbar.Delete\r\n */\r\nL.EditToolbar.Delete = L.Handler.extend({\r\n\tstatics: {\r\n\t\tTYPE: 'remove' // not delete as delete is reserved in js\r\n\t},\r\n\r\n\t// @method intialize(): void\r\n\tinitialize: function (map, options) {\r\n\t\tL.Handler.prototype.initialize.call(this, map);\r\n\r\n\t\tL.Util.setOptions(this, options);\r\n\r\n\t\t// Store the selectable layer group for ease of access\r\n\t\tthis._deletableLayers = this.options.featureGroup;\r\n\r\n\t\tif (!(this._deletableLayers instanceof L.FeatureGroup)) {\r\n\t\t\tthrow new Error('options.featureGroup must be a L.FeatureGroup');\r\n\t\t}\r\n\r\n\t\t// Save the type so super can fire, need to do this as cannot do this.TYPE :(\r\n\t\tthis.type = L.EditToolbar.Delete.TYPE;\r\n\r\n\t\tvar version = L.version.split('.');\r\n\t\t//If Version is >= 1.2.0\r\n\t\tif (parseInt(version[0], 10) === 1 && parseInt(version[1], 10) >= 2) {\r\n\t\t\tL.EditToolbar.Delete.include(L.Evented.prototype);\r\n\t\t} else {\r\n\t\t\tL.EditToolbar.Delete.include(L.Mixin.Events);\r\n\t\t}\r\n\r\n\t},\r\n\r\n\t// @method enable(): void\r\n\t// Enable the delete toolbar\r\n\tenable: function () {\r\n\t\tif (this._enabled || !this._hasAvailableLayers()) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tthis.fire('enabled', {handler: this.type});\r\n\r\n\t\tthis._map.fire(L.Draw.Event.DELETESTART, {handler: this.type});\r\n\r\n\t\tL.Handler.prototype.enable.call(this);\r\n\r\n\t\tthis._deletableLayers\r\n\t\t\t.on('layeradd', this._enableLayerDelete, this)\r\n\t\t\t.on('layerremove', this._disableLayerDelete, this);\r\n\t},\r\n\r\n\t// @method disable(): void\r\n\t// Disable the delete toolbar\r\n\tdisable: function () {\r\n\t\tif (!this._enabled) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tthis._deletableLayers\r\n\t\t\t.off('layeradd', this._enableLayerDelete, this)\r\n\t\t\t.off('layerremove', this._disableLayerDelete, this);\r\n\r\n\t\tL.Handler.prototype.disable.call(this);\r\n\r\n\t\tthis._map.fire(L.Draw.Event.DELETESTOP, {handler: this.type});\r\n\r\n\t\tthis.fire('disabled', {handler: this.type});\r\n\t},\r\n\r\n\t// @method addHooks(): void\r\n\t// Add listener hooks to this handler\r\n\taddHooks: function () {\r\n\t\tvar map = this._map;\r\n\r\n\t\tif (map) {\r\n\t\t\tmap.getContainer().focus();\r\n\r\n\t\t\tthis._deletableLayers.eachLayer(this._enableLayerDelete, this);\r\n\t\t\tthis._deletedLayers = new L.LayerGroup();\r\n\r\n\t\t\tthis._tooltip = new L.Draw.Tooltip(this._map);\r\n\t\t\tthis._tooltip.updateContent({text: L.drawLocal.edit.handlers.remove.tooltip.text});\r\n\r\n\t\t\tthis._map.on('mousemove', this._onMouseMove, this);\r\n\t\t}\r\n\t},\r\n\r\n\t// @method removeHooks(): void\r\n\t// Remove listener hooks from this handler\r\n\tremoveHooks: function () {\r\n\t\tif (this._map) {\r\n\t\t\tthis._deletableLayers.eachLayer(this._disableLayerDelete, this);\r\n\t\t\tthis._deletedLayers = null;\r\n\r\n\t\t\tthis._tooltip.dispose();\r\n\t\t\tthis._tooltip = null;\r\n\r\n\t\t\tthis._map.off('mousemove', this._onMouseMove, this);\r\n\t\t}\r\n\t},\r\n\r\n\t// @method revertLayers(): void\r\n\t// Revert the deleted layers back to their prior state.\r\n\trevertLayers: function () {\r\n\t\t// Iterate of the deleted layers and add them back into the featureGroup\r\n\t\tthis._deletedLayers.eachLayer(function (layer) {\r\n\t\t\tthis._deletableLayers.addLayer(layer);\r\n\t\t\tlayer.fire('revert-deleted', {layer: layer});\r\n\t\t}, this);\r\n\t},\r\n\r\n\t// @method save(): void\r\n\t// Save deleted layers\r\n\tsave: function () {\r\n\t\tthis._map.fire(L.Draw.Event.DELETED, {layers: this._deletedLayers});\r\n\t},\r\n\r\n\t// @method removeAllLayers(): void\r\n\t// Remove all delateable layers\r\n\tremoveAllLayers: function () {\r\n\t\t// Iterate of the delateable layers and add remove them\r\n\t\tthis._deletableLayers.eachLayer(function (layer) {\r\n\t\t\tthis._removeLayer({layer: layer});\r\n\t\t}, this);\r\n\t\tthis.save();\r\n\t},\r\n\r\n\t_enableLayerDelete: function (e) {\r\n\t\tvar layer = e.layer || e.target || e;\r\n\r\n\t\tlayer.on('click', this._removeLayer, this);\r\n\t},\r\n\r\n\t_disableLayerDelete: function (e) {\r\n\t\tvar layer = e.layer || e.target || e;\r\n\r\n\t\tlayer.off('click', this._removeLayer, this);\r\n\r\n\t\t// Remove from the deleted layers so we can't accidentally revert if the user presses cancel\r\n\t\tthis._deletedLayers.removeLayer(layer);\r\n\t},\r\n\r\n\t_removeLayer: function (e) {\r\n\t\tvar layer = e.layer || e.target || e;\r\n\r\n\t\tthis._deletableLayers.removeLayer(layer);\r\n\r\n\t\tthis._deletedLayers.addLayer(layer);\r\n\r\n\t\tlayer.fire('deleted');\r\n\t},\r\n\r\n\t_onMouseMove: function (e) {\r\n\t\tthis._tooltip.updatePosition(e.latlng);\r\n\t},\r\n\r\n\t_hasAvailableLayers: function () {\r\n\t\treturn this._deletableLayers.getLayers().length !== 0;\r\n\t}\r\n});\r\n"]} \ No newline at end of file diff --git a/dist/leaflet.draw.js b/dist/leaflet.draw.js index d4efa5360..39bc85e73 100644 --- a/dist/leaflet.draw.js +++ b/dist/leaflet.draw.js @@ -1,10 +1,10 @@ /* - Leaflet.draw 1.0.3+e90ec6d, a plugin that adds drawing and editing tools to Leaflet powered maps. + Leaflet.draw 1.0.3+638b962, a plugin that adds drawing and editing tools to Leaflet powered maps. (c) 2012-2017, Jacob Toye, Jon West, Smartrak, Leaflet https://github.com/Leaflet/Leaflet.draw http://leafletjs.com */ -!function(t,e,i){function o(t,e){for(;(t=t.parentElement)&&!t.classList.contains(e););return t}L.drawVersion="1.0.3+e90ec6d",L.Draw={},L.drawLocal={draw:{toolbar:{actions:{title:"Cancel drawing",text:"Cancel"},finish:{title:"Finish drawing",text:"Finish"},undo:{title:"Delete last point drawn",text:"Delete last point"},buttons:{polyline:"Draw a polyline",polygon:"Draw a polygon",rectangle:"Draw a rectangle",circle:"Draw a circle",marker:"Draw a marker",circlemarker:"Draw a circlemarker"}},handlers:{circle:{tooltip:{start:"Click and drag to draw circle."},radius:"Radius"},circlemarker:{tooltip:{start:"Click map to place circle marker."}},marker:{tooltip:{start:"Click map to place marker."}},polygon:{tooltip:{start:"Click to start drawing shape.",cont:"Click to continue drawing shape.",end:"Click first point to close this shape."}},polyline:{error:"Error: shape edges cannot cross!",tooltip:{start:"Click to start drawing line.",cont:"Click to continue drawing line.",end:"Click last point to finish line."}},rectangle:{tooltip:{start:"Click and drag to draw rectangle."}},simpleshape:{tooltip:{end:"Release mouse to finish drawing."}}}},edit:{toolbar:{actions:{save:{title:"Save changes",text:"Save"},cancel:{title:"Cancel editing, discards all changes",text:"Cancel"},clearAll:{title:"Clear all layers",text:"Clear All"}},buttons:{edit:"Edit layers",editDisabled:"No layers to edit",remove:"Delete layers",removeDisabled:"No layers to delete"}},handlers:{edit:{tooltip:{text:"Drag handles or markers to edit features.",subtext:"Click cancel to undo changes."}},remove:{tooltip:{text:"Click on a feature to remove."}}}}},L.Draw.Event={},L.Draw.Event.CREATED="draw:created",L.Draw.Event.EDITED="draw:edited",L.Draw.Event.DELETED="draw:deleted",L.Draw.Event.DRAWSTART="draw:drawstart",L.Draw.Event.DRAWSTOP="draw:drawstop",L.Draw.Event.DRAWVERTEX="draw:drawvertex",L.Draw.Event.EDITSTART="draw:editstart",L.Draw.Event.EDITMOVE="draw:editmove",L.Draw.Event.EDITRESIZE="draw:editresize",L.Draw.Event.EDITVERTEX="draw:editvertex",L.Draw.Event.EDITSTOP="draw:editstop",L.Draw.Event.DELETESTART="draw:deletestart",L.Draw.Event.DELETESTOP="draw:deletestop",L.Draw.Event.TOOLBAROPENED="draw:toolbaropened",L.Draw.Event.TOOLBARCLOSED="draw:toolbarclosed",L.Draw.Event.MARKERCONTEXT="draw:markercontext",L.Draw=L.Draw||{},L.Draw.Feature=L.Handler.extend({initialize:function(t,e){this._map=t,this._container=t._container,this._overlayPane=t._panes.overlayPane,this._popupPane=t._panes.popupPane,e&&e.shapeOptions&&(e.shapeOptions=L.Util.extend({},this.options.shapeOptions,e.shapeOptions)),L.setOptions(this,e);var i=L.version.split(".");1===parseInt(i[0],10)&&parseInt(i[1],10)>=2?L.Draw.Feature.include(L.Evented.prototype):L.Draw.Feature.include(L.Mixin.Events)},enable:function(){this._enabled||(L.Handler.prototype.enable.call(this),this.fire("enabled",{handler:this.type}),this._map.fire(L.Draw.Event.DRAWSTART,{layerType:this.type}))},disable:function(){this._enabled&&(L.Handler.prototype.disable.call(this),this._map.fire(L.Draw.Event.DRAWSTOP,{layerType:this.type}),this.fire("disabled",{handler:this.type}))},addHooks:function(){var t=this._map;t&&(L.DomUtil.disableTextSelection(),t.getContainer().focus(),this._tooltip=new L.Draw.Tooltip(this._map),L.DomEvent.on(this._container,"keyup",this._cancelDrawing,this))},removeHooks:function(){this._map&&(L.DomUtil.enableTextSelection(),this._tooltip.dispose(),this._tooltip=null,L.DomEvent.off(this._container,"keyup",this._cancelDrawing,this))},setOptions:function(t){L.setOptions(this,t)},_fireCreatedEvent:function(t){this._map.fire(L.Draw.Event.CREATED,{layer:t,layerType:this.type})},_cancelDrawing:function(t){27===t.keyCode&&(this._map.fire("draw:canceled",{layerType:this.type}),this.disable())}}),L.Draw.Polyline=L.Draw.Feature.extend({statics:{TYPE:"polyline"},Poly:L.Polyline,options:{allowIntersection:!0,repeatMode:!1,drawError:{color:"#b00b00",timeout:2500},icon:new L.DivIcon({iconSize:new L.Point(8,8),className:"leaflet-div-icon leaflet-editing-icon"}),touchIcon:new L.DivIcon({iconSize:new L.Point(20,20),className:"leaflet-div-icon leaflet-editing-icon leaflet-touch-icon"}),guidelineDistance:20,maxGuideLineLength:4e3,shapeOptions:{stroke:!0,color:"#3388ff",weight:4,opacity:.5,fill:!1,clickable:!0},metric:!0,feet:!0,nautic:!1,showLength:!0,zIndexOffset:2e3,factor:1,maxPoints:0},initialize:function(t,e){L.Browser.touch&&(this.options.icon=this.options.touchIcon),this.options.drawError.message=L.drawLocal.draw.handlers.polyline.error,e&&e.drawError&&(e.drawError=L.Util.extend({},this.options.drawError,e.drawError)),this.type=L.Draw.Polyline.TYPE,L.Draw.Feature.prototype.initialize.call(this,t,e)},addHooks:function(){L.Draw.Feature.prototype.addHooks.call(this),this._map&&(this._markers=[],this._markerGroup=new L.LayerGroup,this._map.addLayer(this._markerGroup),this._poly=new L.Polyline([],this.options.shapeOptions),this._tooltip.updateContent(this._getTooltipText()),this._mouseMarker||(this._mouseMarker=L.marker(this._map.getCenter(),{icon:L.divIcon({className:"leaflet-mouse-marker",iconAnchor:[20,20],iconSize:[40,40]}),opacity:0,zIndexOffset:this.options.zIndexOffset})),this._mouseMarker.on("mouseout",this._onMouseOut,this).on("mousemove",this._onMouseMove,this).on("mousedown",this._onMouseDown,this).on("mouseup",this._onMouseUp,this).addTo(this._map),this._map.on("mouseup",this._onMouseUp,this).on("mousemove",this._onMouseMove,this).on("zoomlevelschange",this._onZoomEnd,this).on("touchstart",this._onTouch,this).on("zoomend",this._onZoomEnd,this))},removeHooks:function(){L.Draw.Feature.prototype.removeHooks.call(this),this._clearHideErrorTimeout(),this._cleanUpShape(),this._map.removeLayer(this._markerGroup),delete this._markerGroup,delete this._markers,this._map.removeLayer(this._poly),delete this._poly,this._mouseMarker.off("mousedown",this._onMouseDown,this).off("mouseout",this._onMouseOut,this).off("mouseup",this._onMouseUp,this).off("mousemove",this._onMouseMove,this),this._map.removeLayer(this._mouseMarker),delete this._mouseMarker,this._clearGuides(),this._map.off("mouseup",this._onMouseUp,this).off("mousemove",this._onMouseMove,this).off("zoomlevelschange",this._onZoomEnd,this).off("zoomend",this._onZoomEnd,this).off("touchstart",this._onTouch,this).off("click",this._onTouch,this)},deleteLastVertex:function(){if(!(this._markers.length<=1)){var t=this._markers.pop(),e=this._poly,i=e.getLatLngs(),o=i.splice(-1,1)[0];this._poly.setLatLngs(i),this._markerGroup.removeLayer(t),e.getLatLngs().length<2&&this._map.removeLayer(e),this._vertexChanged(o,!1)}},addVertex:function(t){if(this._markers.length>=2&&!this.options.allowIntersection&&this._poly.newLatLngIntersects(t))return void this._showErrorTooltip();this._errorShown&&this._hideErrorTooltip(),this._markers.push(this._createMarker(t)),this._poly.addLatLng(t),2===this._poly.getLatLngs().length&&this._map.addLayer(this._poly),this._vertexChanged(t,!0)},completeShape:function(){this._markers.length<=1||!this._shapeIsValid()||(this._fireCreatedEvent(),this.disable(),this.options.repeatMode&&this.enable())},_finishShape:function(){var t=this._poly._defaultShape?this._poly._defaultShape():this._poly.getLatLngs(),e=this._poly.newLatLngIntersects(t[t.length-1]);if(!this.options.allowIntersection&&e||!this._shapeIsValid())return void this._showErrorTooltip();this._fireCreatedEvent(),this.disable(),this.options.repeatMode&&this.enable()},_shapeIsValid:function(){return!0},_onZoomEnd:function(){null!==this._markers&&this._updateGuide()},_onMouseMove:function(t){var e=this._map.mouseEventToLayerPoint(t.originalEvent),i=this._map.layerPointToLatLng(e);this._currentLatLng=i,this._updateTooltip(i),this._updateGuide(e),this._mouseMarker.setLatLng(i),L.DomEvent.preventDefault(t.originalEvent)},_vertexChanged:function(t,e){this._map.fire(L.Draw.Event.DRAWVERTEX,{layers:this._markerGroup}),this._updateFinishHandler(),this._updateRunningMeasure(t,e),this._clearGuides(),this._updateTooltip()},_onMouseDown:function(t){if(!this._clickHandled&&!this._touchHandled&&!this._disableMarkers){this._onMouseMove(t),this._clickHandled=!0,this._disableNewMarkers();var e=t.originalEvent,i=e.clientX,o=e.clientY;this._startPoint.call(this,i,o)}},_startPoint:function(t,e){this._mouseDownOrigin=L.point(t,e)},_onMouseUp:function(t){var e=t.originalEvent,i=e.clientX,o=e.clientY;this._endPoint.call(this,i,o,t),this._clickHandled=null},_endPoint:function(e,i,o){if(this._mouseDownOrigin){var a=L.point(e,i).distanceTo(this._mouseDownOrigin),n=this._calculateFinishDistance(o.latlng);this.options.maxPoints>1&&this.options.maxPoints==this._markers.length+1?(this.addVertex(o.latlng),this._finishShape()):n<10&&L.Browser.touch?this._finishShape():Math.abs(a)<9*(t.devicePixelRatio||1)&&this.addVertex(o.latlng),this._enableNewMarkers()}this._mouseDownOrigin=null},_onTouch:function(t){var e,i,o=t.originalEvent;!o.touches||!o.touches[0]||this._clickHandled||this._touchHandled||this._disableMarkers||(e=o.touches[0].clientX,i=o.touches[0].clientY,this._disableNewMarkers(),this._touchHandled=!0,this._startPoint.call(this,e,i),this._endPoint.call(this,e,i,t),this._touchHandled=null),this._clickHandled=null},_onMouseOut:function(){this._tooltip&&this._tooltip._onMouseOut.call(this._tooltip)},_calculateFinishDistance:function(t){var e;if(this._markers.length>0){var i;if(this.type===L.Draw.Polyline.TYPE)i=this._markers[this._markers.length-1];else{if(this.type!==L.Draw.Polygon.TYPE)return 1/0;i=this._markers[0]}var o=this._map.latLngToContainerPoint(i.getLatLng()),a=new L.Marker(t,{icon:this.options.icon,zIndexOffset:2*this.options.zIndexOffset}),n=this._map.latLngToContainerPoint(a.getLatLng());e=o.distanceTo(n)}else e=1/0;return e},_updateFinishHandler:function(){var t=this._markers.length;t>1&&this._markers[t-1].on("click",this._finishShape,this),t>2&&this._markers[t-2].off("click",this._finishShape,this)},_createMarker:function(t){var e=new L.Marker(t,{icon:this.options.icon,zIndexOffset:2*this.options.zIndexOffset});return this._markerGroup.addLayer(e),e},_updateGuide:function(t){var e=this._markers?this._markers.length:0;e>0&&(t=t||this._map.latLngToLayerPoint(this._currentLatLng),this._clearGuides(),this._drawGuide(this._map.latLngToLayerPoint(this._markers[e-1].getLatLng()),t))},_updateTooltip:function(t){var e=this._getTooltipText();t&&this._tooltip.updatePosition(t),this._errorShown||this._tooltip.updateContent(e)},_drawGuide:function(t,e){var i,o,a,n=Math.floor(Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))),s=this.options.guidelineDistance,r=this.options.maxGuideLineLength,l=n>r?n-r:s;for(this._guidesContainer||(this._guidesContainer=L.DomUtil.create("div","leaflet-draw-guides",this._overlayPane));l1&&this._markers[this._markers.length-1].off("click",this._finishShape,this)},_fireCreatedEvent:function(){var t=new this.Poly(this._poly.getLatLngs(),this.options.shapeOptions);L.Draw.Feature.prototype._fireCreatedEvent.call(this,t)}}),L.Draw.Polygon=L.Draw.Polyline.extend({statics:{TYPE:"polygon"},Poly:L.Polygon,options:{showArea:!1,showLength:!1,shapeOptions:{stroke:!0,color:"#3388ff",weight:4,opacity:.5,fill:!0,fillColor:null,fillOpacity:.2,clickable:!0},metric:!0,feet:!0,nautic:!1,precision:{}},initialize:function(t,e){L.Draw.Polyline.prototype.initialize.call(this,t,e),this.type=L.Draw.Polygon.TYPE},_updateFinishHandler:function(){var t=this._markers.length;1===t&&this._markers[0].on("click",this._finishShape,this),t>2&&(this._markers[t-1].on("dblclick",this._finishShape,this),t>3&&this._markers[t-2].off("dblclick",this._finishShape,this))},_getTooltipText:function(){var t,e;return 0===this._markers.length?t=L.drawLocal.draw.handlers.polygon.tooltip.start:this._markers.length<3?(t=L.drawLocal.draw.handlers.polygon.tooltip.cont,e=this._getMeasurementString()):(t=L.drawLocal.draw.handlers.polygon.tooltip.end,e=this._getMeasurementString()),{text:t,subtext:e}},_getMeasurementString:function(){var t=this._area,e="";return t||this.options.showLength?(this.options.showLength&&(e=L.Draw.Polyline.prototype._getMeasurementString.call(this)),t&&(e+="
"+L.GeometryUtil.readableArea(t,this.options.metric,this.options.precision)),e):null},_shapeIsValid:function(){return this._markers.length>=3},_vertexChanged:function(t,e){var i;!this.options.allowIntersection&&this.options.showArea&&(i=this._poly.getLatLngs(),this._area=L.GeometryUtil.geodesicArea(i)),L.Draw.Polyline.prototype._vertexChanged.call(this,t,e)},_cleanUpShape:function(){var t=this._markers.length;t>0&&(this._markers[0].off("click",this._finishShape,this),t>2&&this._markers[t-1].off("dblclick",this._finishShape,this))}}),L.SimpleShape={},L.Draw.SimpleShape=L.Draw.Feature.extend({options:{repeatMode:!1},initialize:function(t,e){this._endLabelText=L.drawLocal.draw.handlers.simpleshape.tooltip.end,L.Draw.Feature.prototype.initialize.call(this,t,e)},addHooks:function(){L.Draw.Feature.prototype.addHooks.call(this),this._map&&(this._mapDraggable=this._map.dragging.enabled(),this._mapDraggable&&this._map.dragging.disable(),this._container.style.cursor="crosshair",this._tooltip.updateContent({text:this._initialLabelText}),this._map.on("mousedown",this._onMouseDown,this).on("mousemove",this._onMouseMove,this).on("touchstart",this._onMouseDown,this).on("touchmove",this._onMouseMove,this),e.addEventListener("touchstart",L.DomEvent.preventDefault,{passive:!1}))},removeHooks:function(){L.Draw.Feature.prototype.removeHooks.call(this),this._map&&(this._mapDraggable&&this._map.dragging.enable(),this._container.style.cursor="",this._map.off("mousedown",this._onMouseDown,this).off("mousemove",this._onMouseMove,this).off("touchstart",this._onMouseDown,this).off("touchmove",this._onMouseMove,this),L.DomEvent.off(e,"mouseup",this._onMouseUp,this),L.DomEvent.off(e,"touchend",this._onMouseUp,this),e.removeEventListener("touchstart",L.DomEvent.preventDefault),this._shape&&(this._map.removeLayer(this._shape),delete this._shape)),this._isDrawing=!1},_getTooltipText:function(){return{text:this._endLabelText}},_onMouseDown:function(t){this._isDrawing=!0,this._startLatLng=t.latlng,L.DomEvent.on(e,"mouseup",this._onMouseUp,this).on(e,"touchend",this._onMouseUp,this).preventDefault(t.originalEvent)},_onMouseMove:function(t){var e=t.latlng;this._tooltip.updatePosition(e),this._isDrawing&&(this._tooltip.updateContent(this._getTooltipText()),this._drawShape(e))},_onMouseUp:function(){this._shape&&this._fireCreatedEvent(),this.disable(),this.options.repeatMode&&this.enable()}}),L.Draw.Rectangle=L.Draw.SimpleShape.extend({statics:{TYPE:"rectangle"},options:{shapeOptions:{stroke:!0,color:"#3388ff",weight:4,opacity:.5,fill:!0,fillColor:null,fillOpacity:.2,clickable:!0},showArea:!0,metric:!0},initialize:function(t,e){this.type=L.Draw.Rectangle.TYPE,this._initialLabelText=L.drawLocal.draw.handlers.rectangle.tooltip.start,L.Draw.SimpleShape.prototype.initialize.call(this,t,e)},disable:function(){this._enabled&&(this._isCurrentlyTwoClickDrawing=!1,L.Draw.SimpleShape.prototype.disable.call(this))},_onMouseUp:function(t){if(!this._shape&&!this._isCurrentlyTwoClickDrawing)return void(this._isCurrentlyTwoClickDrawing=!0);this._isCurrentlyTwoClickDrawing&&!o(t.target,"leaflet-pane")||L.Draw.SimpleShape.prototype._onMouseUp.call(this)},_drawShape:function(t){this._shape?this._shape.setBounds(new L.LatLngBounds(this._startLatLng,t)):(this._shape=new L.Rectangle(new L.LatLngBounds(this._startLatLng,t),this.options.shapeOptions),this._map.addLayer(this._shape))},_fireCreatedEvent:function(){var t=new L.Rectangle(this._shape.getBounds(),this.options.shapeOptions);L.Draw.SimpleShape.prototype._fireCreatedEvent.call(this,t)},_getTooltipText:function(){var t,e,i,o=L.Draw.SimpleShape.prototype._getTooltipText.call(this),a=this._shape,n=this.options.showArea;return a&&(t=this._shape._defaultShape?this._shape._defaultShape():this._shape.getLatLngs(),e=L.GeometryUtil.geodesicArea(t),i=n?L.GeometryUtil.readableArea(e,this.options.metric):""),{text:o.text,subtext:i}}}),L.Draw.Marker=L.Draw.Feature.extend({statics:{TYPE:"marker"},options:{icon:new L.Icon.Default,repeatMode:!1,zIndexOffset:2e3},initialize:function(t,e){this.type=L.Draw.Marker.TYPE,this._initialLabelText=L.drawLocal.draw.handlers.marker.tooltip.start,L.Draw.Feature.prototype.initialize.call(this,t,e)},addHooks:function(){L.Draw.Feature.prototype.addHooks.call(this),this._map&&(this._tooltip.updateContent({text:this._initialLabelText}),this._mouseMarker||(this._mouseMarker=L.marker(this._map.getCenter(),{icon:L.divIcon({className:"leaflet-mouse-marker",iconAnchor:[20,20],iconSize:[40,40]}),opacity:0,zIndexOffset:this.options.zIndexOffset})),this._mouseMarker.on("click",this._onClick,this).addTo(this._map),this._map.on("mousemove",this._onMouseMove,this),this._map.on("click",this._onTouch,this))},removeHooks:function(){L.Draw.Feature.prototype.removeHooks.call(this),this._map&&(this._map.off("click",this._onClick,this).off("click",this._onTouch,this),this._marker&&(this._marker.off("click",this._onClick,this),this._map.removeLayer(this._marker),delete this._marker),this._mouseMarker.off("click",this._onClick,this),this._map.removeLayer(this._mouseMarker),delete this._mouseMarker,this._map.off("mousemove",this._onMouseMove,this))},_onMouseMove:function(t){var e=t.latlng;this._tooltip.updatePosition(e),this._mouseMarker.setLatLng(e),this._marker?(e=this._mouseMarker.getLatLng(),this._marker.setLatLng(e)):(this._marker=this._createMarker(e),this._marker.on("click",this._onClick,this),this._map.on("click",this._onClick,this).addLayer(this._marker))},_createMarker:function(t){return new L.Marker(t,{icon:this.options.icon,zIndexOffset:this.options.zIndexOffset})},_onClick:function(){this._fireCreatedEvent(),this.disable(),this.options.repeatMode&&this.enable()},_onTouch:function(t){this._onMouseMove(t),this._onClick()},_fireCreatedEvent:function(){var t=new L.Marker.Touch(this._marker.getLatLng(),{icon:this.options.icon});L.Draw.Feature.prototype._fireCreatedEvent.call(this,t)}}),L.Draw.CircleMarker=L.Draw.Marker.extend({statics:{TYPE:"circlemarker"},options:{stroke:!0,color:"#3388ff",weight:4,opacity:.5,fill:!0,fillColor:null,fillOpacity:.2,clickable:!0,zIndexOffset:2e3},initialize:function(t,e){this.type=L.Draw.CircleMarker.TYPE,this._initialLabelText=L.drawLocal.draw.handlers.circlemarker.tooltip.start,L.Draw.Feature.prototype.initialize.call(this,t,e)},_fireCreatedEvent:function(){var t=new L.CircleMarker(this._marker.getLatLng(),this.options);L.Draw.Feature.prototype._fireCreatedEvent.call(this,t)},_createMarker:function(t){return new L.CircleMarker(t,this.options)}}),L.Draw.Circle=L.Draw.SimpleShape.extend({statics:{TYPE:"circle"},options:{shapeOptions:{stroke:!0,color:"#3388ff",weight:4,opacity:.5,fill:!0,fillColor:null,fillOpacity:.2,clickable:!0},showRadius:!0,metric:!0,feet:!0,nautic:!1},initialize:function(t,e){this.type=L.Draw.Circle.TYPE,this._initialLabelText=L.drawLocal.draw.handlers.circle.tooltip.start,L.Draw.SimpleShape.prototype.initialize.call(this,t,e)},_drawShape:function(t){if(L.GeometryUtil.isVersion07x())var e=this._startLatLng.distanceTo(t);else var e=this._map.distance(this._startLatLng,t);this._shape?this._shape.setRadius(e):(this._shape=new L.Circle(this._startLatLng,e,this.options.shapeOptions),this._map.addLayer(this._shape))},_fireCreatedEvent:function(){var t=new L.Circle(this._startLatLng,this._shape.getRadius(),this.options.shapeOptions);L.Draw.SimpleShape.prototype._fireCreatedEvent.call(this,t)},_onMouseMove:function(t){var e,i=t.latlng,o=this.options.showRadius,a=this.options.metric;if(this._tooltip.updatePosition(i),this._isDrawing){this._drawShape(i),e=this._shape.getRadius().toFixed(1);var n="";o&&(n=L.drawLocal.draw.handlers.circle.radius+": "+L.GeometryUtil.readableDistance(e,a,this.options.feet,this.options.nautic)),this._tooltip.updateContent({text:this._endLabelText,subtext:n})}}}),L.Edit=L.Edit||{},L.Edit.Marker=L.Handler.extend({initialize:function(t,e){this._marker=t,L.setOptions(this,e)},addHooks:function(){var t=this._marker;t.dragging.enable(),t.on("dragend",this._onDragEnd,t),this._toggleMarkerHighlight()},removeHooks:function(){var t=this._marker;t.dragging.disable(),t.off("dragend",this._onDragEnd,t),this._toggleMarkerHighlight()},_onDragEnd:function(t){var e=t.target;e.edited=!0,this._map.fire(L.Draw.Event.EDITMOVE,{layer:e})},_toggleMarkerHighlight:function(){var t=this._marker._icon;t&&(t.style.display="none",L.DomUtil.hasClass(t,"leaflet-edit-marker-selected")?(L.DomUtil.removeClass(t,"leaflet-edit-marker-selected"),this._offsetMarker(t,-4)):(L.DomUtil.addClass(t,"leaflet-edit-marker-selected"),this._offsetMarker(t,4)),t.style.display="")},_offsetMarker:function(t,e){var i=parseInt(t.style.marginTop,10)-e,o=parseInt(t.style.marginLeft,10)-e;t.style.marginTop=i+"px",t.style.marginLeft=o+"px"}}),L.Marker.addInitHook(function(){L.Edit.Marker&&(this.editing=new L.Edit.Marker(this),this.options.editable&&this.editing.enable())}),L.Edit=L.Edit||{},L.Edit.Poly=L.Handler.extend({initialize:function(t){this.latlngs=[t._latlngs],t._holes&&(this.latlngs=this.latlngs.concat(t._holes)),this._poly=t,this._poly.on("revert-edited",this._updateLatLngs,this)},_defaultShape:function(){return L.Polyline._flat?L.Polyline._flat(this._poly._latlngs)?this._poly._latlngs:this._poly._latlngs[0]:this._poly._latlngs},_eachVertexHandler:function(t){for(var e=0;et&&(i._index+=e)})},_createMiddleMarker:function(t,e){var i,o,a,n=this._getMiddleLatLng(t,e),s=this._createMarker(n);s.setOpacity(.6),t._middleRight=e._middleLeft=s,o=function(){s.off("touchmove",o,this);var a=e._index;s._index=a,s.off("click",i,this).on("click",this._onMarkerClick,this),n.lat=s.getLatLng().lat,n.lng=s.getLatLng().lng,this._spliceLatLngs(a,0,n),this._markers.splice(a,0,s),s.setOpacity(1),this._updateIndexes(a,1),e._index++,this._updatePrevNext(t,s),this._updatePrevNext(s,e),this._poly.fire("editstart")},a=function(){s.off("dragstart",o,this),s.off("dragend",a,this),s.off("touchmove",o,this),this._createMiddleMarker(t,s),this._createMiddleMarker(s,e)},i=function(){o.call(this),a.call(this),this._fireEdit()},s.on("click",i,this).on("dragstart",o,this).on("dragend",a,this).on("touchmove",o,this),this._markerGroup.addLayer(s)},_updatePrevNext:function(t,e){t&&(t._next=e),e&&(e._prev=t)},_getMiddleLatLng:function(t,e){var i=this._poly._map,o=i.project(t.getLatLng()),a=i.project(e.getLatLng());return i.unproject(o._add(a)._divideBy(2))}}),L.Polyline.addInitHook(function(){this.editing||(L.Edit.Poly&&(this.editing=new L.Edit.Poly(this),this.options.editable&&this.editing.enable()),this.on("add",function(){this.editing&&this.editing.enabled()&&this.editing.addHooks()}),this.on("remove",function(){this.editing&&this.editing.enabled()&&this.editing.removeHooks()}))}),L.Edit=L.Edit||{},L.Edit.SimpleShape=L.Handler.extend({options:{moveIcon:new L.DivIcon({iconSize:new L.Point(8,8),className:"leaflet-div-icon leaflet-editing-icon leaflet-edit-move"}),resizeIcon:new L.DivIcon({iconSize:new L.Point(8,8), -className:"leaflet-div-icon leaflet-editing-icon leaflet-edit-resize"}),touchMoveIcon:new L.DivIcon({iconSize:new L.Point(20,20),className:"leaflet-div-icon leaflet-editing-icon leaflet-edit-move leaflet-touch-icon"}),touchResizeIcon:new L.DivIcon({iconSize:new L.Point(20,20),className:"leaflet-div-icon leaflet-editing-icon leaflet-edit-resize leaflet-touch-icon"})},initialize:function(t,e){L.Browser.touch&&(this.options.moveIcon=this.options.touchMoveIcon,this.options.resizeIcon=this.options.touchResizeIcon),this._shape=t,L.Util.setOptions(this,e)},addHooks:function(){var t=this._shape;this._shape._map&&(this._map=this._shape._map,t.setStyle(t.options.editing),t._map&&(this._map=t._map,this._markerGroup||this._initMarkers(),this._map.addLayer(this._markerGroup)))},removeHooks:function(){var t=this._shape;if(t.setStyle(t.options.original),t._map){this._unbindMarker(this._moveMarker);for(var e=0,i=this._resizeMarkers.length;e"+L.drawLocal.edit.handlers.edit.tooltip.text,subtext:L.drawLocal.draw.handlers.circle.radius+": "+L.GeometryUtil.readableDistance(radius,!0,this.options.feet,this.options.nautic)})),this._shape.setRadius(radius),this._map.fire(L.Draw.Event.EDITRESIZE,{layer:this._shape})}}),L.Circle.addInitHook(function(){L.Edit.Circle&&(this.editing=new L.Edit.Circle(this),this.options.editable&&this.editing.enable())}),L.Map.mergeOptions({touchExtend:!0}),L.Map.TouchExtend=L.Handler.extend({initialize:function(t){this._map=t,this._container=t._container,this._pane=t._panes.overlayPane},addHooks:function(){L.DomEvent.on(this._container,"touchstart",this._onTouchStart,this),L.DomEvent.on(this._container,"touchend",this._onTouchEnd,this),L.DomEvent.on(this._container,"touchmove",this._onTouchMove,this),this._detectIE()?(L.DomEvent.on(this._container,"MSPointerDown",this._onTouchStart,this),L.DomEvent.on(this._container,"MSPointerUp",this._onTouchEnd,this),L.DomEvent.on(this._container,"MSPointerMove",this._onTouchMove,this),L.DomEvent.on(this._container,"MSPointerCancel",this._onTouchCancel,this)):(L.DomEvent.on(this._container,"touchcancel",this._onTouchCancel,this),L.DomEvent.on(this._container,"touchleave",this._onTouchLeave,this))},removeHooks:function(){L.DomEvent.off(this._container,"touchstart",this._onTouchStart,this),L.DomEvent.off(this._container,"touchend",this._onTouchEnd,this),L.DomEvent.off(this._container,"touchmove",this._onTouchMove,this),this._detectIE()?(L.DomEvent.off(this._container,"MSPointerDown",this._onTouchStart,this),L.DomEvent.off(this._container,"MSPointerUp",this._onTouchEnd,this),L.DomEvent.off(this._container,"MSPointerMove",this._onTouchMove,this),L.DomEvent.off(this._container,"MSPointerCancel",this._onTouchCancel,this)):(L.DomEvent.off(this._container,"touchcancel",this._onTouchCancel,this),L.DomEvent.off(this._container,"touchleave",this._onTouchLeave,this))},_touchEvent:function(t,e){var i={};if(void 0!==t.touches){if(!t.touches.length)return;i=t.touches[0]}else{if("touch"!==t.pointerType)return;if(i=t,!this._filterClick(t))return}var o=this._map.mouseEventToContainerPoint(i),a=this._map.mouseEventToLayerPoint(i),n=this._map.layerPointToLatLng(a);this._map.fire(e,{latlng:n,layerPoint:a,containerPoint:o,pageX:i.pageX,pageY:i.pageY,originalEvent:t})},_filterClick:function(t){var e=t.timeStamp||t.originalEvent.timeStamp,i=L.DomEvent._lastClick&&e-L.DomEvent._lastClick;return i&&i>100&&i<500||t.target._simulatedClick&&!t._simulated?(L.DomEvent.stop(t),!1):(L.DomEvent._lastClick=e,!0)},_onTouchStart:function(t){if(this._map._loaded){this._touchEvent(t,"touchstart")}},_onTouchEnd:function(t){if(this._map._loaded){this._touchEvent(t,"touchend")}},_onTouchCancel:function(t){if(this._map._loaded){var e="touchcancel";this._detectIE()&&(e="pointercancel"),this._touchEvent(t,e)}},_onTouchLeave:function(t){if(this._map._loaded){this._touchEvent(t,"touchleave")}},_onTouchMove:function(t){if(this._map._loaded){this._touchEvent(t,"touchmove")}},_detectIE:function(){var e=t.navigator.userAgent,i=e.indexOf("MSIE ");if(i>0)return parseInt(e.substring(i+5,e.indexOf(".",i)),10);if(e.indexOf("Trident/")>0){var o=e.indexOf("rv:");return parseInt(e.substring(o+3,e.indexOf(".",o)),10)}var a=e.indexOf("Edge/");return a>0&&parseInt(e.substring(a+5,e.indexOf(".",a)),10)}}),L.Map.addInitHook("addHandler","touchExtend",L.Map.TouchExtend),L.Marker.Touch=L.Marker.extend({_initInteraction:function(){return this.addInteractiveTarget?L.Marker.prototype._initInteraction.apply(this):this._initInteractionLegacy()},_initInteractionLegacy:function(){if(this.options.clickable){var t=this._icon,e=["dblclick","mousedown","mouseover","mouseout","contextmenu","touchstart","touchend","touchmove"];this._detectIE?e.concat(["MSPointerDown","MSPointerUp","MSPointerMove","MSPointerCancel"]):e.concat(["touchcancel"]),L.DomUtil.addClass(t,"leaflet-clickable"),L.DomEvent.on(t,"click",this._onMouseClick,this),L.DomEvent.on(t,"keypress",this._onKeyPress,this);for(var i=0;i0)return parseInt(e.substring(i+5,e.indexOf(".",i)),10);if(e.indexOf("Trident/")>0){var o=e.indexOf("rv:");return parseInt(e.substring(o+3,e.indexOf(".",o)),10)}var a=e.indexOf("Edge/");return a>0&&parseInt(e.substring(a+5,e.indexOf(".",a)),10)}}),L.LatLngUtil={cloneLatLngs:function(t){for(var e=[],i=0,o=t.length;i2){for(var s=0;s1&&(i=i+s+r[1])}return i},readableArea:function(e,i,o){var a,n,o=L.Util.extend({},t,o);return i?(n=["ha","m"],type=typeof i,"string"===type?n=[i]:"boolean"!==type&&(n=i),a=e>=1e6&&-1!==n.indexOf("km")?L.GeometryUtil.formattedNumber(1e-6*e,o.km)+" km²":e>=1e4&&-1!==n.indexOf("ha")?L.GeometryUtil.formattedNumber(1e-4*e,o.ha)+" ha":L.GeometryUtil.formattedNumber(e,o.m)+" m²"):(e/=.836127,a=e>=3097600?L.GeometryUtil.formattedNumber(e/3097600,o.mi)+" mi²":e>=4840?L.GeometryUtil.formattedNumber(e/4840,o.ac)+" acres":L.GeometryUtil.formattedNumber(e,o.yd)+" yd²"),a},readableDistance:function(e,i,o,a,n){var s,n=L.Util.extend({},t,n);switch(i?"string"==typeof i?i:"metric":o?"feet":a?"nauticalMile":"yards"){case"metric":s=e>1e3?L.GeometryUtil.formattedNumber(e/1e3,n.km)+" km":L.GeometryUtil.formattedNumber(e,n.m)+" m";break;case"feet":e*=3.28083,s=L.GeometryUtil.formattedNumber(e,n.ft)+" ft";break;case"nauticalMile":e*=.53996,s=L.GeometryUtil.formattedNumber(e/1e3,n.nm)+" nm";break;case"yards":default:e*=1.09361,s=e>1760?L.GeometryUtil.formattedNumber(e/1760,n.mi)+" miles":L.GeometryUtil.formattedNumber(e,n.yd)+" yd"}return s},isVersion07x:function(){var t=L.version.split(".");return 0===parseInt(t[0],10)&&7===parseInt(t[1],10)}})}(),L.Util.extend(L.LineUtil,{segmentsIntersect:function(t,e,i,o){return this._checkCounterclockwise(t,i,o)!==this._checkCounterclockwise(e,i,o)&&this._checkCounterclockwise(t,e,i)!==this._checkCounterclockwise(t,e,o)},_checkCounterclockwise:function(t,e,i){return(i.y-t.y)*(e.x-t.x)>(e.y-t.y)*(i.x-t.x)}}),L.Polyline.include({intersects:function(){var t,e,i,o=this._getProjectedPoints(),a=o?o.length:0;if(this._tooFewPointsForIntersection())return!1;for(t=a-1;t>=3;t--)if(e=o[t-1],i=o[t],this._lineSegmentsIntersectsRange(e,i,t-2))return!0;return!1},newLatLngIntersects:function(t,e){return!!this._map&&this.newPointIntersects(this._map.latLngToLayerPoint(t),e)},newPointIntersects:function(t,e){var i=this._getProjectedPoints(),o=i?i.length:0,a=i?i[o-1]:null,n=o-2;return!this._tooFewPointsForIntersection(1)&&this._lineSegmentsIntersectsRange(a,t,n,e?1:0)},_tooFewPointsForIntersection:function(t){var e=this._getProjectedPoints(),i=e?e.length:0;return i+=t||0,!e||i<=3},_lineSegmentsIntersectsRange:function(t,e,i,o){var a,n,s=this._getProjectedPoints();o=o||0;for(var r=i;r>o;r--)if(a=s[r-1],n=s[r],L.LineUtil.segmentsIntersect(t,e,a,n))return!0;return!1},_getProjectedPoints:function(){if(!this._defaultShape)return this._originalPoints;for(var t=[],e=this._defaultShape(),i=0;i=2?L.Toolbar.include(L.Evented.prototype):L.Toolbar.include(L.Mixin.Events)},enabled:function(){return null!==this._activeMode},disable:function(){this.enabled()&&this._activeMode.handler.disable()},addToolbar:function(t){var e,i=L.DomUtil.create("div","leaflet-draw-section"),o=0,a=this._toolbarClass||"",n=this.getModeHandlers(t);for(this._toolbarContainer=L.DomUtil.create("div","leaflet-draw-toolbar leaflet-bar"),this._map=t,e=0;e0&&this._singleLineLabel&&(L.DomUtil.removeClass(this._container,"leaflet-draw-tooltip-single"),this._singleLineLabel=!1):(L.DomUtil.addClass(this._container,"leaflet-draw-tooltip-single"),this._singleLineLabel=!0),this._container.innerHTML=(t.subtext.length>0?''+t.subtext+"
":"")+""+t.text+"",t.text||t.subtext?(this._visible=!0,this._container.style.visibility="inherit"):(this._visible=!1,this._container.style.visibility="hidden"),this):this},updatePosition:function(t){var e=this._map.latLngToLayerPoint(t),i=this._container;return this._container&&(this._visible&&(i.style.visibility="inherit"),L.DomUtil.setPosition(i,e)),this},showAsError:function(){return this._container&&L.DomUtil.addClass(this._container,"leaflet-error-draw-tooltip"),this},removeError:function(){return this._container&&L.DomUtil.removeClass(this._container,"leaflet-error-draw-tooltip"),this},_onMouseOut:function(){this._container&&(this._container.style.visibility="hidden")}}),L.DrawToolbar=L.Toolbar.extend({statics:{TYPE:"draw"},options:{polyline:{},polygon:{},rectangle:{},circle:{},marker:{},circlemarker:{}},initialize:function(t){for(var e in this.options)this.options.hasOwnProperty(e)&&t[e]&&(t[e]=L.extend({},this.options[e],t[e]));this._toolbarClass="leaflet-draw-draw",L.Toolbar.prototype.initialize.call(this,t)},getModeHandlers:function(t){return[{enabled:this.options.polyline,handler:new L.Draw.Polyline(t,this.options.polyline),title:L.drawLocal.draw.toolbar.buttons.polyline},{enabled:this.options.polygon,handler:new L.Draw.Polygon(t,this.options.polygon),title:L.drawLocal.draw.toolbar.buttons.polygon},{enabled:this.options.rectangle,handler:new L.Draw.Rectangle(t,this.options.rectangle),title:L.drawLocal.draw.toolbar.buttons.rectangle},{enabled:this.options.circle,handler:new L.Draw.Circle(t,this.options.circle),title:L.drawLocal.draw.toolbar.buttons.circle},{enabled:this.options.marker,handler:new L.Draw.Marker(t,this.options.marker),title:L.drawLocal.draw.toolbar.buttons.marker},{enabled:this.options.circlemarker,handler:new L.Draw.CircleMarker(t,this.options.circlemarker),title:L.drawLocal.draw.toolbar.buttons.circlemarker}]},getActions:function(t){return[{enabled:t.completeShape,title:L.drawLocal.draw.toolbar.finish.title,text:L.drawLocal.draw.toolbar.finish.text,callback:t.completeShape,context:t},{enabled:t.deleteLastVertex,title:L.drawLocal.draw.toolbar.undo.title,text:L.drawLocal.draw.toolbar.undo.text,callback:t.deleteLastVertex,context:t},{title:L.drawLocal.draw.toolbar.actions.title,text:L.drawLocal.draw.toolbar.actions.text,callback:this.disable,context:this}]},setOptions:function(t){L.setOptions(this,t);for(var e in this._modes)this._modes.hasOwnProperty(e)&&t.hasOwnProperty(e)&&this._modes[e].handler.setOptions(t[e])}}),L.EditToolbar=L.Toolbar.extend({statics:{TYPE:"edit"},options:{edit:{selectedPathOptions:{dashArray:"10, 10",fill:!0,fillColor:"#fe57a1",fillOpacity:.1,maintainColor:!1}},remove:{},poly:null,featureGroup:null},initialize:function(t){t.edit&&(void 0===t.edit.selectedPathOptions&&(t.edit.selectedPathOptions=this.options.edit.selectedPathOptions),t.edit.selectedPathOptions=L.extend({},this.options.edit.selectedPathOptions,t.edit.selectedPathOptions)),t.remove&&(t.remove=L.extend({},this.options.remove,t.remove)),t.poly&&(t.poly=L.extend({},this.options.poly,t.poly)),this._toolbarClass="leaflet-draw-edit",L.Toolbar.prototype.initialize.call(this,t),this._selectedFeatureCount=0},getModeHandlers:function(t){var e=this.options.featureGroup;return[{enabled:this.options.edit,handler:new L.EditToolbar.Edit(t,{featureGroup:e,selectedPathOptions:this.options.edit.selectedPathOptions,poly:this.options.poly}),title:L.drawLocal.edit.toolbar.buttons.edit},{enabled:this.options.remove,handler:new L.EditToolbar.Delete(t,{featureGroup:e}),title:L.drawLocal.edit.toolbar.buttons.remove}]},getActions:function(t){var e=[{title:L.drawLocal.edit.toolbar.actions.save.title,text:L.drawLocal.edit.toolbar.actions.save.text,callback:this._save,context:this},{title:L.drawLocal.edit.toolbar.actions.cancel.title,text:L.drawLocal.edit.toolbar.actions.cancel.text,callback:this.disable,context:this}];return t.removeAllLayers&&e.push({title:L.drawLocal.edit.toolbar.actions.clearAll.title,text:L.drawLocal.edit.toolbar.actions.clearAll.text,callback:this._clearAllLayers,context:this}),e},addToolbar:function(t){var e=L.Toolbar.prototype.addToolbar.call(this,t);return this._checkDisabled(),this.options.featureGroup.on("layeradd layerremove",this._checkDisabled,this),e},removeToolbar:function(){this.options.featureGroup.off("layeradd layerremove",this._checkDisabled,this),L.Toolbar.prototype.removeToolbar.call(this)},disable:function(){this.enabled()&&(this._activeMode.handler.revertLayers(),L.Toolbar.prototype.disable.call(this))},_save:function(){this._activeMode.handler.save(),this._activeMode&&this._activeMode.handler.disable()},_clearAllLayers:function(){this._activeMode.handler.removeAllLayers(),this._activeMode&&this._activeMode.handler.disable()},_checkDisabled:function(){var t,e=this.options.featureGroup,i=0!==e.getLayers().length;this.options.edit&&(t=this._modes[L.EditToolbar.Edit.TYPE].button,i?L.DomUtil.removeClass(t,"leaflet-disabled"):L.DomUtil.addClass(t,"leaflet-disabled"),t.setAttribute("title",i?L.drawLocal.edit.toolbar.buttons.edit:L.drawLocal.edit.toolbar.buttons.editDisabled)),this.options.remove&&(t=this._modes[L.EditToolbar.Delete.TYPE].button,i?L.DomUtil.removeClass(t,"leaflet-disabled"):L.DomUtil.addClass(t,"leaflet-disabled"),t.setAttribute("title",i?L.drawLocal.edit.toolbar.buttons.remove:L.drawLocal.edit.toolbar.buttons.removeDisabled))}}),L.EditToolbar.Edit=L.Handler.extend({statics:{TYPE:"edit"},initialize:function(t,e){if(L.Handler.prototype.initialize.call(this,t),L.setOptions(this,e),this._featureGroup=e.featureGroup,!(this._featureGroup instanceof L.FeatureGroup))throw new Error("options.featureGroup must be a L.FeatureGroup");this._uneditedLayerProps={},this.type=L.EditToolbar.Edit.TYPE;var i=L.version.split(".");1===parseInt(i[0],10)&&parseInt(i[1],10)>=2?L.EditToolbar.Edit.include(L.Evented.prototype):L.EditToolbar.Edit.include(L.Mixin.Events)},enable:function(){!this._enabled&&this._hasAvailableLayers()&&(this.fire("enabled",{handler:this.type}),this._map.fire(L.Draw.Event.EDITSTART,{handler:this.type}),L.Handler.prototype.enable.call(this),this._featureGroup.on("layeradd",this._enableLayerEdit,this).on("layerremove",this._disableLayerEdit,this))},disable:function(){this._enabled&&(this._featureGroup.off("layeradd",this._enableLayerEdit,this).off("layerremove",this._disableLayerEdit,this),L.Handler.prototype.disable.call(this),this._map.fire(L.Draw.Event.EDITSTOP,{handler:this.type}),this.fire("disabled",{handler:this.type}))},addHooks:function(){var t=this._map;t&&(t.getContainer().focus(),this._featureGroup.eachLayer(this._enableLayerEdit,this),this._tooltip=new L.Draw.Tooltip(this._map),this._tooltip.updateContent({text:L.drawLocal.edit.handlers.edit.tooltip.text,subtext:L.drawLocal.edit.handlers.edit.tooltip.subtext}),t._editTooltip=this._tooltip,this._updateTooltip(),this._map.on("mousemove",this._onMouseMove,this).on("touchmove",this._onMouseMove,this).on("MSPointerMove",this._onMouseMove,this).on(L.Draw.Event.EDITVERTEX,this._updateTooltip,this))},removeHooks:function(){this._map&&(this._featureGroup.eachLayer(this._disableLayerEdit,this),this._map._editTooltip.dispose(),this._map._editTooltip=null,this._uneditedLayerProps={},this._tooltip.dispose(),this._tooltip=null,this._map.off("mousemove",this._onMouseMove,this).off("touchmove",this._onMouseMove,this).off("MSPointerMove",this._onMouseMove,this).off(L.Draw.Event.EDITVERTEX,this._updateTooltip,this))},revertLayers:function(){this._featureGroup.eachLayer(function(t){this._revertLayer(t)},this)},save:function(){var t=new L.LayerGroup;this._featureGroup.eachLayer(function(e){e.edited&&(t.addLayer(e),e.edited=!1)}),this._map.fire(L.Draw.Event.EDITED,{layers:t})},_backupLayer:function(t){var e=L.Util.stamp(t);this._uneditedLayerProps[e]||(t instanceof L.Polyline||t instanceof L.Polygon||t instanceof L.Rectangle?this._uneditedLayerProps[e]={latlngs:L.LatLngUtil.cloneLatLngs(t.getLatLngs())}:t instanceof L.Circle?this._uneditedLayerProps[e]={latlng:L.LatLngUtil.cloneLatLng(t.getLatLng()),radius:t.getRadius()}:(t instanceof L.Marker||t instanceof L.CircleMarker)&&(this._uneditedLayerProps[e]={latlng:L.LatLngUtil.cloneLatLng(t.getLatLng())}))},_getTooltipText:function(){return{text:L.drawLocal.edit.handlers.edit.tooltip.text,subtext:L.drawLocal.edit.handlers.edit.tooltip.subtext}},_updateTooltip:function(){this._tooltip.updateContent(this._getTooltipText())},_revertLayer:function(t){var e=L.Util.stamp(t);t.edited=!1,this._uneditedLayerProps.hasOwnProperty(e)&&(t instanceof L.Polyline||t instanceof L.Polygon||t instanceof L.Rectangle?t.setLatLngs(this._uneditedLayerProps[e].latlngs):t instanceof L.Circle?(t.setLatLng(this._uneditedLayerProps[e].latlng),t.setRadius(this._uneditedLayerProps[e].radius)):(t instanceof L.Marker||t instanceof L.CircleMarker)&&t.setLatLng(this._uneditedLayerProps[e].latlng),t.fire("revert-edited",{layer:t}))},_enableLayerEdit:function(t){var e,i,o=t.layer||t.target||t;this._backupLayer(o),this.options.poly&&(i=L.Util.extend({},this.options.poly),o.options.poly=i),this.options.selectedPathOptions&&(e=L.Util.extend({},this.options.selectedPathOptions),e.maintainColor&&(e.color=o.options.color,e.fillColor=o.options.fillColor),o.options.original=L.extend({},o.options),o.options.editing=e),o instanceof L.Marker?(o.editing&&o.editing.enable(),o.dragging.enable(),o.on("dragend",this._onMarkerDragEnd).on("touchmove",this._onTouchMove,this).on("MSPointerMove",this._onTouchMove,this).on("touchend",this._onMarkerDragEnd,this).on("MSPointerUp",this._onMarkerDragEnd,this)):o.editing.enable()},_disableLayerEdit:function(t){var e=t.layer||t.target||t;e.edited=!1,e.editing&&e.editing.disable(), +!function(t,e,i){function o(t,e){for(;(t=t.parentElement)&&!t.classList.contains(e););return t}L.drawVersion="1.0.3+638b962",L.Draw={},L.drawLocal={draw:{toolbar:{actions:{title:"Cancel drawing",text:"Cancel"},finish:{title:"Finish drawing",text:"Finish"},undo:{title:"Delete last point drawn",text:"Delete last point"},buttons:{polyline:"Draw a polyline",polygon:"Draw a polygon",rectangle:"Draw a rectangle",circle:"Draw a circle",marker:"Draw a marker",circlemarker:"Draw a circlemarker"}},handlers:{circle:{tooltip:{start:"Click and drag to draw circle."},radius:"Radius"},circlemarker:{tooltip:{start:"Click map to place circle marker."}},marker:{tooltip:{start:"Click map to place marker."}},polygon:{tooltip:{start:"Click to start drawing shape.",cont:"Click to continue drawing shape.",end:"Click first point to close this shape."}},polyline:{error:"Error: shape edges cannot cross!",tooltip:{start:"Click to start drawing line.",cont:"Click to continue drawing line.",end:"Click last point to finish line."}},rectangle:{tooltip:{start:"Click and drag to draw rectangle."}},simpleshape:{tooltip:{end:"Release mouse to finish drawing."}}}},edit:{toolbar:{actions:{save:{title:"Save changes",text:"Save"},cancel:{title:"Cancel editing, discards all changes",text:"Cancel"},clearAll:{title:"Clear all layers",text:"Clear All"}},buttons:{edit:"Edit layers",editDisabled:"No layers to edit",remove:"Delete layers",removeDisabled:"No layers to delete"}},handlers:{edit:{tooltip:{text:"Drag handles or markers to edit features.",subtext:"Click cancel to undo changes."}},remove:{tooltip:{text:"Click on a feature to remove."}}}}},L.Draw.Event={},L.Draw.Event.CREATED="draw:created",L.Draw.Event.EDITED="draw:edited",L.Draw.Event.DELETED="draw:deleted",L.Draw.Event.DRAWSTART="draw:drawstart",L.Draw.Event.DRAWSTOP="draw:drawstop",L.Draw.Event.DRAWVERTEX="draw:drawvertex",L.Draw.Event.EDITSTART="draw:editstart",L.Draw.Event.EDITMOVE="draw:editmove",L.Draw.Event.EDITRESIZE="draw:editresize",L.Draw.Event.EDITVERTEX="draw:editvertex",L.Draw.Event.EDITSTOP="draw:editstop",L.Draw.Event.DELETESTART="draw:deletestart",L.Draw.Event.DELETESTOP="draw:deletestop",L.Draw.Event.TOOLBAROPENED="draw:toolbaropened",L.Draw.Event.TOOLBARCLOSED="draw:toolbarclosed",L.Draw.Event.MARKERCONTEXT="draw:markercontext",L.Draw=L.Draw||{},L.Draw.Feature=L.Handler.extend({initialize:function(t,e){this._map=t,this._container=t._container,this._overlayPane=t._panes.overlayPane,this._popupPane=t._panes.popupPane,e&&e.shapeOptions&&(e.shapeOptions=L.Util.extend({},this.options.shapeOptions,e.shapeOptions)),L.setOptions(this,e);var i=L.version.split(".");1===parseInt(i[0],10)&&parseInt(i[1],10)>=2?L.Draw.Feature.include(L.Evented.prototype):L.Draw.Feature.include(L.Mixin.Events)},enable:function(){this._enabled||(L.Handler.prototype.enable.call(this),this.fire("enabled",{handler:this.type}),this._map.fire(L.Draw.Event.DRAWSTART,{layerType:this.type}))},disable:function(){this._enabled&&(L.Handler.prototype.disable.call(this),this._map.fire(L.Draw.Event.DRAWSTOP,{layerType:this.type}),this.fire("disabled",{handler:this.type}))},addHooks:function(){var t=this._map;t&&(L.DomUtil.disableTextSelection(),t.getContainer().focus(),this._tooltip=new L.Draw.Tooltip(this._map),L.DomEvent.on(this._container,"keyup",this._cancelDrawing,this))},removeHooks:function(){this._map&&(L.DomUtil.enableTextSelection(),this._tooltip.dispose(),this._tooltip=null,L.DomEvent.off(this._container,"keyup",this._cancelDrawing,this))},setOptions:function(t){L.setOptions(this,t)},_fireCreatedEvent:function(t){this._map.fire(L.Draw.Event.CREATED,{layer:t,layerType:this.type})},_cancelDrawing:function(t){27===t.keyCode&&(this._map.fire("draw:canceled",{layerType:this.type}),this.disable())}}),L.Draw.Polyline=L.Draw.Feature.extend({statics:{TYPE:"polyline"},Poly:L.Polyline,options:{allowIntersection:!0,repeatMode:!1,drawError:{color:"#b00b00",timeout:2500},icon:new L.DivIcon({iconSize:new L.Point(8,8),className:"leaflet-div-icon leaflet-editing-icon"}),touchIcon:new L.DivIcon({iconSize:new L.Point(20,20),className:"leaflet-div-icon leaflet-editing-icon leaflet-touch-icon"}),guidelineDistance:20,maxGuideLineLength:4e3,shapeOptions:{stroke:!0,color:"#3388ff",weight:4,opacity:.5,fill:!1,clickable:!0},metric:!0,feet:!0,nautic:!1,showLength:!0,zIndexOffset:2e3,factor:1,maxPoints:0},initialize:function(t,e){L.Browser.touch&&(this.options.icon=this.options.touchIcon),this.options.drawError.message=L.drawLocal.draw.handlers.polyline.error,e&&e.drawError&&(e.drawError=L.Util.extend({},this.options.drawError,e.drawError)),this.type=L.Draw.Polyline.TYPE,L.Draw.Feature.prototype.initialize.call(this,t,e)},addHooks:function(){L.Draw.Feature.prototype.addHooks.call(this),this._map&&(this._markers=[],this._markerGroup=new L.LayerGroup,this._map.addLayer(this._markerGroup),this._poly=new L.Polyline([],this.options.shapeOptions),this._tooltip.updateContent(this._getTooltipText()),this._mouseMarker||(this._mouseMarker=L.marker(this._map.getCenter(),{icon:L.divIcon({className:"leaflet-mouse-marker",iconAnchor:[20,20],iconSize:[40,40]}),opacity:0,zIndexOffset:this.options.zIndexOffset})),this._mouseMarker.on("mouseout",this._onMouseOut,this).on("mousemove",this._onMouseMove,this).on("mousedown",this._onMouseDown,this).on("mouseup",this._onMouseUp,this).addTo(this._map),this._map.on("mouseup",this._onMouseUp,this).on("mousemove",this._onMouseMove,this).on("zoomlevelschange",this._onZoomEnd,this).on("touchstart",this._onTouch,this).on("zoomend",this._onZoomEnd,this))},removeHooks:function(){L.Draw.Feature.prototype.removeHooks.call(this),this._clearHideErrorTimeout(),this._cleanUpShape(),this._map.removeLayer(this._markerGroup),delete this._markerGroup,delete this._markers,this._map.removeLayer(this._poly),delete this._poly,this._mouseMarker.off("mousedown",this._onMouseDown,this).off("mouseout",this._onMouseOut,this).off("mouseup",this._onMouseUp,this).off("mousemove",this._onMouseMove,this),this._map.removeLayer(this._mouseMarker),delete this._mouseMarker,this._clearGuides(),this._map.off("mouseup",this._onMouseUp,this).off("mousemove",this._onMouseMove,this).off("zoomlevelschange",this._onZoomEnd,this).off("zoomend",this._onZoomEnd,this).off("touchstart",this._onTouch,this).off("click",this._onTouch,this)},deleteLastVertex:function(){if(!(this._markers.length<=1)){var t=this._markers.pop(),e=this._poly,i=e.getLatLngs(),o=i.splice(-1,1)[0];this._poly.setLatLngs(i),this._markerGroup.removeLayer(t),e.getLatLngs().length<2&&this._map.removeLayer(e),this._vertexChanged(o,!1)}},addVertex:function(t){if(this._markers.length>=2&&!this.options.allowIntersection&&this._poly.newLatLngIntersects(t))return void this._showErrorTooltip();this._errorShown&&this._hideErrorTooltip(),this._markers.push(this._createMarker(t)),this._poly.addLatLng(t),2===this._poly.getLatLngs().length&&this._map.addLayer(this._poly),this._vertexChanged(t,!0)},completeShape:function(){this._markers.length<=1||!this._shapeIsValid()||(this._fireCreatedEvent(),this.disable(),this.options.repeatMode&&this.enable())},_finishShape:function(){var t=this._poly._defaultShape?this._poly._defaultShape():this._poly.getLatLngs(),e=this._poly.newLatLngIntersects(t[t.length-1]);if(!this.options.allowIntersection&&e||!this._shapeIsValid())return void this._showErrorTooltip();this._fireCreatedEvent(),this.disable(),this.options.repeatMode&&this.enable()},_shapeIsValid:function(){return!0},_onZoomEnd:function(){null!==this._markers&&this._updateGuide()},_onMouseMove:function(t){var e=this._map.mouseEventToLayerPoint(t.originalEvent),i=this._map.layerPointToLatLng(e);this._currentLatLng=i,this._updateTooltip(i),this._updateGuide(e),this._mouseMarker.setLatLng(i),L.DomEvent.preventDefault(t.originalEvent)},_vertexChanged:function(t,e){this._map.fire(L.Draw.Event.DRAWVERTEX,{layers:this._markerGroup}),this._updateFinishHandler(),this._updateRunningMeasure(t,e),this._clearGuides(),this._updateTooltip()},_onMouseDown:function(t){if(!this._clickHandled&&!this._touchHandled&&!this._disableMarkers){this._onMouseMove(t),this._clickHandled=!0,this._disableNewMarkers();var e=t.originalEvent,i=e.clientX,o=e.clientY;this._startPoint.call(this,i,o)}},_startPoint:function(t,e){this._mouseDownOrigin=L.point(t,e)},_onMouseUp:function(t){var e=t.originalEvent,i=e.clientX,o=e.clientY;this._endPoint.call(this,i,o,t),this._clickHandled=null},_endPoint:function(e,i,o){if(this._mouseDownOrigin){var a=L.point(e,i).distanceTo(this._mouseDownOrigin),n=this._calculateFinishDistance(o.latlng);this.options.maxPoints>1&&this.options.maxPoints==this._markers.length+1?(this.addVertex(o.latlng),this._finishShape()):n<10&&L.Browser.touch?this._finishShape():Math.abs(a)<9*(t.devicePixelRatio||1)&&this.addVertex(o.latlng),this._enableNewMarkers()}this._mouseDownOrigin=null},_onTouch:function(t){var e,i,o=t.originalEvent;!o.touches||!o.touches[0]||this._clickHandled||this._touchHandled||this._disableMarkers||(e=o.touches[0].clientX,i=o.touches[0].clientY,this._disableNewMarkers(),this._touchHandled=!0,this._startPoint.call(this,e,i),this._endPoint.call(this,e,i,t),this._touchHandled=null),this._clickHandled=null},_onMouseOut:function(){this._tooltip&&this._tooltip._onMouseOut.call(this._tooltip)},_calculateFinishDistance:function(t){var e;if(this._markers.length>0){var i;if(this.type===L.Draw.Polyline.TYPE)i=this._markers[this._markers.length-1];else{if(this.type!==L.Draw.Polygon.TYPE)return 1/0;i=this._markers[0]}var o=this._map.latLngToContainerPoint(i.getLatLng()),a=new L.Marker(t,{icon:this.options.icon,zIndexOffset:2*this.options.zIndexOffset}),n=this._map.latLngToContainerPoint(a.getLatLng());e=o.distanceTo(n)}else e=1/0;return e},_updateFinishHandler:function(){var t=this._markers.length;t>1&&this._markers[t-1].on("click",this._finishShape,this),t>2&&this._markers[t-2].off("click",this._finishShape,this)},_createMarker:function(t){var e=new L.Marker(t,{icon:this.options.icon,zIndexOffset:2*this.options.zIndexOffset});return this._markerGroup.addLayer(e),e},_updateGuide:function(t){var e=this._markers?this._markers.length:0;e>0&&(t=t||this._map.latLngToLayerPoint(this._currentLatLng),this._clearGuides(),this._drawGuide(this._map.latLngToLayerPoint(this._markers[e-1].getLatLng()),t))},_updateTooltip:function(t){var e=this._getTooltipText();t&&this._tooltip.updatePosition(t),this._errorShown||this._tooltip.updateContent(e)},_drawGuide:function(t,e){var i,o,a,n=Math.floor(Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))),s=this.options.guidelineDistance,r=this.options.maxGuideLineLength,l=n>r?n-r:s;for(this._guidesContainer||(this._guidesContainer=L.DomUtil.create("div","leaflet-draw-guides",this._overlayPane));l1&&this._markers[this._markers.length-1].off("click",this._finishShape,this)},_fireCreatedEvent:function(){var t=new this.Poly(this._poly.getLatLngs(),this.options.shapeOptions);L.Draw.Feature.prototype._fireCreatedEvent.call(this,t)}}),L.Draw.Polygon=L.Draw.Polyline.extend({statics:{TYPE:"polygon"},Poly:L.Polygon,options:{showArea:!1,showLength:!1,shapeOptions:{stroke:!0,color:"#3388ff",weight:4,opacity:.5,fill:!0,fillColor:null,fillOpacity:.2,clickable:!0},metric:!0,feet:!0,nautic:!1,precision:{}},initialize:function(t,e){L.Draw.Polyline.prototype.initialize.call(this,t,e),this.type=L.Draw.Polygon.TYPE},_updateFinishHandler:function(){var t=this._markers.length;1===t&&this._markers[0].on("click",this._finishShape,this),t>2&&(this._markers[t-1].on("dblclick",this._finishShape,this),t>3&&this._markers[t-2].off("dblclick",this._finishShape,this))},_getTooltipText:function(){var t,e;return 0===this._markers.length?t=L.drawLocal.draw.handlers.polygon.tooltip.start:this._markers.length<3?(t=L.drawLocal.draw.handlers.polygon.tooltip.cont,e=this._getMeasurementString()):(t=L.drawLocal.draw.handlers.polygon.tooltip.end,e=this._getMeasurementString()),{text:t,subtext:e}},_getMeasurementString:function(){var t=this._area,e="";return t||this.options.showLength?(this.options.showLength&&(e=L.Draw.Polyline.prototype._getMeasurementString.call(this)),t&&(e+="
"+L.GeometryUtil.readableArea(t,this.options.metric,this.options.precision)),e):null},_shapeIsValid:function(){return this._markers.length>=3},_vertexChanged:function(t,e){var i;!this.options.allowIntersection&&this.options.showArea&&(i=this._poly.getLatLngs(),this._area=L.GeometryUtil.geodesicArea(i)),L.Draw.Polyline.prototype._vertexChanged.call(this,t,e)},_cleanUpShape:function(){var t=this._markers.length;t>0&&(this._markers[0].off("click",this._finishShape,this),t>2&&this._markers[t-1].off("dblclick",this._finishShape,this))}}),L.SimpleShape={},L.Draw.SimpleShape=L.Draw.Feature.extend({options:{repeatMode:!1},initialize:function(t,e){this._endLabelText=L.drawLocal.draw.handlers.simpleshape.tooltip.end,L.Draw.Feature.prototype.initialize.call(this,t,e)},addHooks:function(){L.Draw.Feature.prototype.addHooks.call(this),this._map&&(this._mapDraggable=this._map.dragging.enabled(),this._mapDraggable&&this._map.dragging.disable(),this._container.style.cursor="crosshair",this._tooltip.updateContent({text:this._initialLabelText}),this._map.on("mousedown",this._onMouseDown,this).on("mousemove",this._onMouseMove,this).on("touchstart",this._onMouseDown,this).on("touchmove",this._onMouseMove,this),e.addEventListener("touchstart",L.DomEvent.preventDefault,{passive:!1}))},removeHooks:function(){L.Draw.Feature.prototype.removeHooks.call(this),this._map&&(this._mapDraggable&&this._map.dragging.enable(),this._container.style.cursor="",this._map.off("mousedown",this._onMouseDown,this).off("mousemove",this._onMouseMove,this).off("touchstart",this._onMouseDown,this).off("touchmove",this._onMouseMove,this),L.DomEvent.off(e,"mouseup",this._onMouseUp,this),L.DomEvent.off(e,"touchend",this._onMouseUp,this),e.removeEventListener("touchstart",L.DomEvent.preventDefault),this._shape&&(this._map.removeLayer(this._shape),delete this._shape)),this._isDrawing=!1},_getTooltipText:function(){return{text:this._endLabelText}},_onMouseDown:function(t){this._isDrawing=!0,this._startLatLng=t.latlng,L.DomEvent.on(e,"mouseup",this._onMouseUp,this).on(e,"touchend",this._onMouseUp,this).preventDefault(t.originalEvent)},_onMouseMove:function(t){var e=t.latlng;this._tooltip.updatePosition(e),this._isDrawing&&(this._tooltip.updateContent(this._getTooltipText()),this._drawShape(e))},_onMouseUp:function(){this._shape&&this._fireCreatedEvent(),this.disable(),this.options.repeatMode&&this.enable()}}),L.Draw.Rectangle=L.Draw.SimpleShape.extend({statics:{TYPE:"rectangle"},options:{shapeOptions:{stroke:!0,color:"#3388ff",weight:4,opacity:.5,fill:!0,fillColor:null,fillOpacity:.2,clickable:!0},showArea:!0,metric:!0},initialize:function(t,e){this.type=L.Draw.Rectangle.TYPE,this._initialLabelText=L.drawLocal.draw.handlers.rectangle.tooltip.start,L.Draw.SimpleShape.prototype.initialize.call(this,t,e)},disable:function(){this._enabled&&(this._isCurrentlyTwoClickDrawing=!1,L.Draw.SimpleShape.prototype.disable.call(this))},_onMouseUp:function(t){if(!this._shape&&!this._isCurrentlyTwoClickDrawing)return void(this._isCurrentlyTwoClickDrawing=!0);this._isCurrentlyTwoClickDrawing&&!o(t.target,"leaflet-pane")||L.Draw.SimpleShape.prototype._onMouseUp.call(this)},_drawShape:function(t){this._shape?this._shape.setBounds(new L.LatLngBounds(this._startLatLng,t)):(this._shape=new L.Rectangle(new L.LatLngBounds(this._startLatLng,t),this.options.shapeOptions),this._map.addLayer(this._shape))},_fireCreatedEvent:function(){var t=new L.Rectangle(this._shape.getBounds(),this.options.shapeOptions);L.Draw.SimpleShape.prototype._fireCreatedEvent.call(this,t)},_getTooltipText:function(){var t,e,i,o=L.Draw.SimpleShape.prototype._getTooltipText.call(this),a=this._shape,n=this.options.showArea;return a&&(t=this._shape._defaultShape?this._shape._defaultShape():this._shape.getLatLngs(),e=L.GeometryUtil.geodesicArea(t),i=n?L.GeometryUtil.readableArea(e,this.options.metric):""),{text:o.text,subtext:i}}}),L.Draw.Marker=L.Draw.Feature.extend({statics:{TYPE:"marker"},options:{icon:new L.Icon.Default,repeatMode:!1,zIndexOffset:2e3},initialize:function(t,e){this.type=L.Draw.Marker.TYPE,this._initialLabelText=L.drawLocal.draw.handlers.marker.tooltip.start,L.Draw.Feature.prototype.initialize.call(this,t,e)},addHooks:function(){L.Draw.Feature.prototype.addHooks.call(this),this._map&&(this._tooltip.updateContent({text:this._initialLabelText}),this._mouseMarker||(this._mouseMarker=L.marker(this._map.getCenter(),{icon:L.divIcon({className:"leaflet-mouse-marker",iconAnchor:[20,20],iconSize:[40,40]}),opacity:0,zIndexOffset:this.options.zIndexOffset})),this._mouseMarker.on("click",this._onClick,this).addTo(this._map),this._map.on("mousemove",this._onMouseMove,this),this._map.on("click",this._onTouch,this))},removeHooks:function(){L.Draw.Feature.prototype.removeHooks.call(this),this._map&&(this._map.off("click",this._onClick,this).off("click",this._onTouch,this),this._marker&&(this._marker.off("click",this._onClick,this),this._map.removeLayer(this._marker),delete this._marker),this._mouseMarker.off("click",this._onClick,this),this._map.removeLayer(this._mouseMarker),delete this._mouseMarker,this._map.off("mousemove",this._onMouseMove,this))},_onMouseMove:function(t){var e=t.latlng;this._tooltip.updatePosition(e),this._mouseMarker.setLatLng(e),this._marker?(e=this._mouseMarker.getLatLng(),this._marker.setLatLng(e)):(this._marker=this._createMarker(e),this._marker.on("click",this._onClick,this),this._map.on("click",this._onClick,this).addLayer(this._marker))},_createMarker:function(t){return new L.Marker(t,{icon:this.options.icon,zIndexOffset:this.options.zIndexOffset})},_onClick:function(){this._fireCreatedEvent(),this.disable(),this.options.repeatMode&&this.enable()},_onTouch:function(t){this._onMouseMove(t),this._onClick()},_fireCreatedEvent:function(){var t=new L.Marker.Touch(this._marker.getLatLng(),{icon:this.options.icon});L.Draw.Feature.prototype._fireCreatedEvent.call(this,t)}}),L.Draw.CircleMarker=L.Draw.Marker.extend({statics:{TYPE:"circlemarker"},options:{stroke:!0,color:"#3388ff",weight:4,opacity:.5,fill:!0,fillColor:null,fillOpacity:.2,clickable:!0,zIndexOffset:2e3},initialize:function(t,e){this.type=L.Draw.CircleMarker.TYPE,this._initialLabelText=L.drawLocal.draw.handlers.circlemarker.tooltip.start,L.Draw.Feature.prototype.initialize.call(this,t,e)},_fireCreatedEvent:function(){var t=new L.CircleMarker(this._marker.getLatLng(),this.options);L.Draw.Feature.prototype._fireCreatedEvent.call(this,t)},_createMarker:function(t){return new L.CircleMarker(t,this.options)}}),L.Draw.Circle=L.Draw.SimpleShape.extend({statics:{TYPE:"circle"},options:{shapeOptions:{stroke:!0,color:"#3388ff",weight:4,opacity:.5,fill:!0,fillColor:null,fillOpacity:.2,clickable:!0},showRadius:!0,metric:!0,feet:!0,nautic:!1},initialize:function(t,e){this.type=L.Draw.Circle.TYPE,this._initialLabelText=L.drawLocal.draw.handlers.circle.tooltip.start,L.Draw.SimpleShape.prototype.initialize.call(this,t,e)},_drawShape:function(t){if(L.GeometryUtil.isVersion07x())var e=this._startLatLng.distanceTo(t);else var e=this._map.distance(this._startLatLng,t);this._shape?this._shape.setRadius(e):(this._shape=new L.Circle(this._startLatLng,e,this.options.shapeOptions),this._map.addLayer(this._shape))},_fireCreatedEvent:function(){var t=new L.Circle(this._startLatLng,this._shape.getRadius(),this.options.shapeOptions);L.Draw.SimpleShape.prototype._fireCreatedEvent.call(this,t)},_onMouseMove:function(t){var e,i=t.latlng,o=this.options.showRadius,a=this.options.metric;if(this._tooltip.updatePosition(i),this._isDrawing){this._drawShape(i),e=this._shape.getRadius().toFixed(1);var n="";o&&(n=L.drawLocal.draw.handlers.circle.radius+": "+L.GeometryUtil.readableDistance(e,a,this.options.feet,this.options.nautic)),this._tooltip.updateContent({text:this._endLabelText,subtext:n})}}}),L.Edit=L.Edit||{},L.Edit.Marker=L.Handler.extend({initialize:function(t,e){this._marker=t,L.setOptions(this,e)},addHooks:function(){var t=this._marker;t.dragging.enable(),t.on("dragend",this._onDragEnd,t),this._toggleMarkerHighlight()},removeHooks:function(){var t=this._marker;t.dragging.disable(),t.off("dragend",this._onDragEnd,t),this._toggleMarkerHighlight()},_onDragEnd:function(t){var e=t.target;e.edited=!0,this._map.fire(L.Draw.Event.EDITMOVE,{layer:e})},_toggleMarkerHighlight:function(){var t=this._marker._icon;t&&(t.style.display="none",L.DomUtil.hasClass(t,"leaflet-edit-marker-selected")?(L.DomUtil.removeClass(t,"leaflet-edit-marker-selected"),this._offsetMarker(t,-4)):(L.DomUtil.addClass(t,"leaflet-edit-marker-selected"),this._offsetMarker(t,4)),t.style.display="")},_offsetMarker:function(t,e){var i=parseInt(t.style.marginTop,10)-e,o=parseInt(t.style.marginLeft,10)-e;t.style.marginTop=i+"px",t.style.marginLeft=o+"px"}}),L.Marker.addInitHook(function(){L.Edit.Marker&&(this.editing=new L.Edit.Marker(this),this.options.editable&&this.editing.enable())}),L.Edit=L.Edit||{},L.Edit.Poly=L.Handler.extend({initialize:function(t){this.latlngs=[t._latlngs],t._holes&&(this.latlngs=this.latlngs.concat(t._holes)),this._poly=t,this._poly.on("revert-edited",this._updateLatLngs,this)},_defaultShape:function(){return L.Polyline._flat?L.Polyline._flat(this._poly._latlngs)?this._poly._latlngs:this._poly._latlngs[0]:this._poly._latlngs},_eachVertexHandler:function(t){for(var e=0;et&&(i._index+=e)})},_createMiddleMarker:function(t,e){var i,o,a,n=this._getMiddleLatLng(t,e),s=this._createMarker(n);s.setOpacity(.6),t._middleRight=e._middleLeft=s,o=function(){s.off("touchmove",o,this);var a=e._index;s._index=a,s.off("click",i,this).on("click",this._onMarkerClick,this),n.lat=s.getLatLng().lat,n.lng=s.getLatLng().lng,this._spliceLatLngs(a,0,n),this._markers.splice(a,0,s),s.setOpacity(1),this._updateIndexes(a,1),e._index++,this._updatePrevNext(t,s),this._updatePrevNext(s,e),this._poly.fire("editstart")},a=function(){s.off("dragstart",o,this),s.off("dragend",a,this),s.off("touchmove",o,this),this._createMiddleMarker(t,s),this._createMiddleMarker(s,e)},i=function(){o.call(this),a.call(this),this._fireEdit()},s.on("click",i,this).on("dragstart",o,this).on("dragend",a,this).on("touchmove",o,this),this._markerGroup.addLayer(s)},_updatePrevNext:function(t,e){t&&(t._next=e),e&&(e._prev=t)},_getMiddleLatLng:function(t,e){var i=this._poly._map,o=i.project(t.getLatLng()),a=i.project(e.getLatLng());return i.unproject(o._add(a)._divideBy(2))}}),L.Polyline.addInitHook(function(){this.editing||(L.Edit.Poly&&(this.editing=new L.Edit.Poly(this),this.options.editable&&this.editing.enable()),this.on("add",function(){this.editing&&this.editing.enabled()&&this.editing.addHooks()}),this.on("remove",function(){this.editing&&this.editing.enabled()&&this.editing.removeHooks()}))}),L.Edit=L.Edit||{},L.Edit.SimpleShape=L.Handler.extend({options:{moveIcon:new L.DivIcon({iconSize:new L.Point(8,8),className:"leaflet-div-icon leaflet-editing-icon leaflet-edit-move"}),resizeIcon:new L.DivIcon({iconSize:new L.Point(8,8), +className:"leaflet-div-icon leaflet-editing-icon leaflet-edit-resize"}),touchMoveIcon:new L.DivIcon({iconSize:new L.Point(20,20),className:"leaflet-div-icon leaflet-editing-icon leaflet-edit-move leaflet-touch-icon"}),touchResizeIcon:new L.DivIcon({iconSize:new L.Point(20,20),className:"leaflet-div-icon leaflet-editing-icon leaflet-edit-resize leaflet-touch-icon"})},initialize:function(t,e){L.Browser.touch&&(this.options.moveIcon=this.options.touchMoveIcon,this.options.resizeIcon=this.options.touchResizeIcon),this._shape=t,L.Util.setOptions(this,e)},addHooks:function(){var t=this._shape;this._shape._map&&(this._map=this._shape._map,t.setStyle(t.options.editing),t._map&&(this._map=t._map,this._markerGroup||this._initMarkers(),this._map.addLayer(this._markerGroup)))},removeHooks:function(){var t=this._shape;if(t.setStyle(t.options.original),t._map){this._unbindMarker(this._moveMarker);for(var e=0,i=this._resizeMarkers.length;e"+L.drawLocal.edit.handlers.edit.tooltip.text,subtext:L.drawLocal.draw.handlers.circle.radius+": "+L.GeometryUtil.readableDistance(radius,!0,this.options.feet,this.options.nautic)})),this._shape.setRadius(radius),this._map.fire(L.Draw.Event.EDITRESIZE,{layer:this._shape})}}),L.Circle.addInitHook(function(){L.Edit.Circle&&(this.editing=new L.Edit.Circle(this),this.options.editable&&this.editing.enable())}),L.Map.mergeOptions({touchExtend:!0}),L.Map.TouchExtend=L.Handler.extend({initialize:function(t){this._map=t,this._container=t._container,this._pane=t._panes.overlayPane},addHooks:function(){L.DomEvent.on(this._container,"touchstart",this._onTouchStart,this),L.DomEvent.on(this._container,"touchend",this._onTouchEnd,this),L.DomEvent.on(this._container,"touchmove",this._onTouchMove,this),this._detectIE()?(L.DomEvent.on(this._container,"MSPointerDown",this._onTouchStart,this),L.DomEvent.on(this._container,"MSPointerUp",this._onTouchEnd,this),L.DomEvent.on(this._container,"MSPointerMove",this._onTouchMove,this),L.DomEvent.on(this._container,"MSPointerCancel",this._onTouchCancel,this)):(L.DomEvent.on(this._container,"touchcancel",this._onTouchCancel,this),L.DomEvent.on(this._container,"touchleave",this._onTouchLeave,this))},removeHooks:function(){L.DomEvent.off(this._container,"touchstart",this._onTouchStart,this),L.DomEvent.off(this._container,"touchend",this._onTouchEnd,this),L.DomEvent.off(this._container,"touchmove",this._onTouchMove,this),this._detectIE()?(L.DomEvent.off(this._container,"MSPointerDown",this._onTouchStart,this),L.DomEvent.off(this._container,"MSPointerUp",this._onTouchEnd,this),L.DomEvent.off(this._container,"MSPointerMove",this._onTouchMove,this),L.DomEvent.off(this._container,"MSPointerCancel",this._onTouchCancel,this)):(L.DomEvent.off(this._container,"touchcancel",this._onTouchCancel,this),L.DomEvent.off(this._container,"touchleave",this._onTouchLeave,this))},_touchEvent:function(t,e){var i={};if(void 0!==t.touches){if(!t.touches.length)return;i=t.touches[0]}else{if("touch"!==t.pointerType)return;if(i=t,!this._filterClick(t))return}var o=this._map.mouseEventToContainerPoint(i),a=this._map.mouseEventToLayerPoint(i),n=this._map.layerPointToLatLng(a);this._map.fire(e,{latlng:n,layerPoint:a,containerPoint:o,pageX:i.pageX,pageY:i.pageY,originalEvent:t})},_filterClick:function(t){var e=t.timeStamp||t.originalEvent.timeStamp,i=L.DomEvent._lastClick&&e-L.DomEvent._lastClick;return i&&i>100&&i<500||t.target._simulatedClick&&!t._simulated?(L.DomEvent.stop(t),!1):(L.DomEvent._lastClick=e,!0)},_onTouchStart:function(t){if(this._map._loaded){this._touchEvent(t,"touchstart")}},_onTouchEnd:function(t){if(this._map._loaded){this._touchEvent(t,"touchend")}},_onTouchCancel:function(t){if(this._map._loaded){var e="touchcancel";this._detectIE()&&(e="pointercancel"),this._touchEvent(t,e)}},_onTouchLeave:function(t){if(this._map._loaded){this._touchEvent(t,"touchleave")}},_onTouchMove:function(t){if(this._map._loaded){this._touchEvent(t,"touchmove")}},_detectIE:function(){var e=t.navigator.userAgent,i=e.indexOf("MSIE ");if(i>0)return parseInt(e.substring(i+5,e.indexOf(".",i)),10);if(e.indexOf("Trident/")>0){var o=e.indexOf("rv:");return parseInt(e.substring(o+3,e.indexOf(".",o)),10)}var a=e.indexOf("Edge/");return a>0&&parseInt(e.substring(a+5,e.indexOf(".",a)),10)}}),L.Map.addInitHook("addHandler","touchExtend",L.Map.TouchExtend),L.Marker.Touch=L.Marker.extend({_initInteraction:function(){return this.addInteractiveTarget?L.Marker.prototype._initInteraction.apply(this):this._initInteractionLegacy()},_initInteractionLegacy:function(){if(this.options.clickable){var t=this._icon,e=["dblclick","mousedown","mouseover","mouseout","contextmenu","touchstart","touchend","touchmove"];this._detectIE?e.concat(["MSPointerDown","MSPointerUp","MSPointerMove","MSPointerCancel"]):e.concat(["touchcancel"]),L.DomUtil.addClass(t,"leaflet-clickable"),L.DomEvent.on(t,"click",this._onMouseClick,this),L.DomEvent.on(t,"keypress",this._onKeyPress,this);for(var i=0;i0)return parseInt(e.substring(i+5,e.indexOf(".",i)),10);if(e.indexOf("Trident/")>0){var o=e.indexOf("rv:");return parseInt(e.substring(o+3,e.indexOf(".",o)),10)}var a=e.indexOf("Edge/");return a>0&&parseInt(e.substring(a+5,e.indexOf(".",a)),10)}}),L.LatLngUtil={cloneLatLngs:function(t){for(var e=[],i=0,o=t.length;i2){for(var s=0;s1&&(i=i+s+r[1])}return i},readableArea:function(e,i,o){var a,n,o=L.Util.extend({},t,o);return i?(n=["ha","m"],type=typeof i,"string"===type?n=[i]:"boolean"!==type&&(n=i),a=e>=1e6&&-1!==n.indexOf("km")?L.GeometryUtil.formattedNumber(1e-6*e,o.km)+" km²":e>=1e4&&-1!==n.indexOf("ha")?L.GeometryUtil.formattedNumber(1e-4*e,o.ha)+" ha":L.GeometryUtil.formattedNumber(e,o.m)+" m²"):(e/=.836127,a=e>=3097600?L.GeometryUtil.formattedNumber(e/3097600,o.mi)+" mi²":e>=4840?L.GeometryUtil.formattedNumber(e/4840,o.ac)+" acres":L.GeometryUtil.formattedNumber(e,o.yd)+" yd²"),a},readableDistance:function(e,i,o,a,n){var s,n=L.Util.extend({},t,n);switch(i?"string"==typeof i?i:"metric":o?"feet":a?"nauticalMile":"yards"){case"metric":s=e>1e3?L.GeometryUtil.formattedNumber(e/1e3,n.km)+" km":L.GeometryUtil.formattedNumber(e,n.m)+" m";break;case"feet":e*=3.28083,s=L.GeometryUtil.formattedNumber(e,n.ft)+" ft";break;case"nauticalMile":e*=.53996,s=L.GeometryUtil.formattedNumber(e/1e3,n.nm)+" nm";break;case"yards":default:e*=1.09361,s=e>1760?L.GeometryUtil.formattedNumber(e/1760,n.mi)+" miles":L.GeometryUtil.formattedNumber(e,n.yd)+" yd"}return s},isVersion07x:function(){var t=L.version.split(".");return 0===parseInt(t[0],10)&&7===parseInt(t[1],10)}})}(),L.Util.extend(L.LineUtil,{segmentsIntersect:function(t,e,i,o){return this._checkCounterclockwise(t,i,o)!==this._checkCounterclockwise(e,i,o)&&this._checkCounterclockwise(t,e,i)!==this._checkCounterclockwise(t,e,o)},_checkCounterclockwise:function(t,e,i){return(i.y-t.y)*(e.x-t.x)>(e.y-t.y)*(i.x-t.x)}}),L.Polyline.include({intersects:function(){var t,e,i,o=this._getProjectedPoints(),a=o?o.length:0;if(this._tooFewPointsForIntersection())return!1;for(t=a-1;t>=3;t--)if(e=o[t-1],i=o[t],this._lineSegmentsIntersectsRange(e,i,t-2))return!0;return!1},newLatLngIntersects:function(t,e){return!!this._map&&this.newPointIntersects(this._map.latLngToLayerPoint(t),e)},newPointIntersects:function(t,e){var i=this._getProjectedPoints(),o=i?i.length:0,a=i?i[o-1]:null,n=o-2;return!this._tooFewPointsForIntersection(1)&&this._lineSegmentsIntersectsRange(a,t,n,e?1:0)},_tooFewPointsForIntersection:function(t){var e=this._getProjectedPoints(),i=e?e.length:0;return i+=t||0,!e||i<=3},_lineSegmentsIntersectsRange:function(t,e,i,o){var a,n,s=this._getProjectedPoints();o=o||0;for(var r=i;r>o;r--)if(a=s[r-1],n=s[r],L.LineUtil.segmentsIntersect(t,e,a,n))return!0;return!1},_getProjectedPoints:function(){if(!this._defaultShape)return this._originalPoints;for(var t=[],e=this._defaultShape(),i=0;i=2?L.Toolbar.include(L.Evented.prototype):L.Toolbar.include(L.Mixin.Events)},enabled:function(){return null!==this._activeMode},disable:function(){this.enabled()&&this._activeMode.handler.disable()},addToolbar:function(t){var e,i=L.DomUtil.create("div","leaflet-draw-section"),o=0,a=this._toolbarClass||"",n=this.getModeHandlers(t);for(this._toolbarContainer=L.DomUtil.create("div","leaflet-draw-toolbar leaflet-bar"),this._map=t,e=0;e0&&this._singleLineLabel&&(L.DomUtil.removeClass(this._container,"leaflet-draw-tooltip-single"),this._singleLineLabel=!1):(L.DomUtil.addClass(this._container,"leaflet-draw-tooltip-single"),this._singleLineLabel=!0),this._container.innerHTML=(t.subtext.length>0?''+t.subtext+"
":"")+""+t.text+"",t.text||t.subtext?(this._visible=!0,this._container.style.visibility="inherit"):(this._visible=!1,this._container.style.visibility="hidden"),this):this},updatePosition:function(t){var e=this._map.latLngToLayerPoint(t),i=this._container;return this._container&&(this._visible&&(i.style.visibility="inherit"),L.DomUtil.setPosition(i,e)),this},showAsError:function(){return this._container&&L.DomUtil.addClass(this._container,"leaflet-error-draw-tooltip"),this},removeError:function(){return this._container&&L.DomUtil.removeClass(this._container,"leaflet-error-draw-tooltip"),this},_onMouseOut:function(){this._container&&(this._container.style.visibility="hidden")}}),L.DrawToolbar=L.Toolbar.extend({statics:{TYPE:"draw"},options:{polyline:{},polygon:{},rectangle:{},circle:{},marker:{},circlemarker:{}},initialize:function(t){for(var e in this.options)this.options.hasOwnProperty(e)&&t[e]&&(t[e]=L.extend({},this.options[e],t[e]));this._toolbarClass="leaflet-draw-draw",L.Toolbar.prototype.initialize.call(this,t)},getModeHandlers:function(t){return[{enabled:this.options.polyline,handler:new L.Draw.Polyline(t,this.options.polyline),title:L.drawLocal.draw.toolbar.buttons.polyline},{enabled:this.options.polygon,handler:new L.Draw.Polygon(t,this.options.polygon),title:L.drawLocal.draw.toolbar.buttons.polygon},{enabled:this.options.rectangle,handler:new L.Draw.Rectangle(t,this.options.rectangle),title:L.drawLocal.draw.toolbar.buttons.rectangle},{enabled:this.options.circle,handler:new L.Draw.Circle(t,this.options.circle),title:L.drawLocal.draw.toolbar.buttons.circle},{enabled:this.options.marker,handler:new L.Draw.Marker(t,this.options.marker),title:L.drawLocal.draw.toolbar.buttons.marker},{enabled:this.options.circlemarker,handler:new L.Draw.CircleMarker(t,this.options.circlemarker),title:L.drawLocal.draw.toolbar.buttons.circlemarker}]},getActions:function(t){return[{enabled:t.completeShape,title:L.drawLocal.draw.toolbar.finish.title,text:L.drawLocal.draw.toolbar.finish.text,callback:t.completeShape,context:t},{enabled:t.deleteLastVertex,title:L.drawLocal.draw.toolbar.undo.title,text:L.drawLocal.draw.toolbar.undo.text,callback:t.deleteLastVertex,context:t},{title:L.drawLocal.draw.toolbar.actions.title,text:L.drawLocal.draw.toolbar.actions.text,callback:this.disable,context:this}]},setOptions:function(t){L.setOptions(this,t);for(var e in this._modes)this._modes.hasOwnProperty(e)&&t.hasOwnProperty(e)&&this._modes[e].handler.setOptions(t[e])}}),L.EditToolbar=L.Toolbar.extend({statics:{TYPE:"edit"},options:{edit:{selectedPathOptions:{dashArray:"10, 10",fill:!0,fillColor:"#fe57a1",fillOpacity:.1,maintainColor:!1}},remove:{},poly:null,featureGroup:null},initialize:function(t){t.edit&&(void 0===t.edit.selectedPathOptions&&(t.edit.selectedPathOptions=this.options.edit.selectedPathOptions),t.edit.selectedPathOptions=L.extend({},this.options.edit.selectedPathOptions,t.edit.selectedPathOptions)),t.remove&&(t.remove=L.extend({},this.options.remove,t.remove)),t.poly&&(t.poly=L.extend({},this.options.poly,t.poly)),this._toolbarClass="leaflet-draw-edit",L.Toolbar.prototype.initialize.call(this,t),this._selectedFeatureCount=0},getModeHandlers:function(t){var e=this.options.featureGroup;return[{enabled:this.options.edit,handler:new L.EditToolbar.Edit(t,{featureGroup:e,selectedPathOptions:this.options.edit.selectedPathOptions,poly:this.options.poly}),title:L.drawLocal.edit.toolbar.buttons.edit},{enabled:this.options.remove,handler:new L.EditToolbar.Delete(t,{featureGroup:e}),title:L.drawLocal.edit.toolbar.buttons.remove}]},getActions:function(t){var e=[{title:L.drawLocal.edit.toolbar.actions.save.title,text:L.drawLocal.edit.toolbar.actions.save.text,callback:this._save,context:this},{title:L.drawLocal.edit.toolbar.actions.cancel.title,text:L.drawLocal.edit.toolbar.actions.cancel.text,callback:this.disable,context:this}];return t.removeAllLayers&&e.push({title:L.drawLocal.edit.toolbar.actions.clearAll.title,text:L.drawLocal.edit.toolbar.actions.clearAll.text,callback:this._clearAllLayers,context:this}),e},addToolbar:function(t){var e=L.Toolbar.prototype.addToolbar.call(this,t);return this._checkDisabled(),this.options.featureGroup.on("layeradd layerremove",this._checkDisabled,this),e},removeToolbar:function(){this.options.featureGroup.off("layeradd layerremove",this._checkDisabled,this),L.Toolbar.prototype.removeToolbar.call(this)},disable:function(){this.enabled()&&(this._activeMode.handler.revertLayers(),L.Toolbar.prototype.disable.call(this))},_save:function(){this._activeMode.handler.save(),this._activeMode&&this._activeMode.handler.disable()},_clearAllLayers:function(){this._activeMode.handler.removeAllLayers(),this._activeMode&&this._activeMode.handler.disable()},_checkDisabled:function(){var t,e=this.options.featureGroup,i=0!==e.getLayers().length;this.options.edit&&(t=this._modes[L.EditToolbar.Edit.TYPE].button,i?L.DomUtil.removeClass(t,"leaflet-disabled"):L.DomUtil.addClass(t,"leaflet-disabled"),t.setAttribute("title",i?L.drawLocal.edit.toolbar.buttons.edit:L.drawLocal.edit.toolbar.buttons.editDisabled)),this.options.remove&&(t=this._modes[L.EditToolbar.Delete.TYPE].button,i?L.DomUtil.removeClass(t,"leaflet-disabled"):L.DomUtil.addClass(t,"leaflet-disabled"),t.setAttribute("title",i?L.drawLocal.edit.toolbar.buttons.remove:L.drawLocal.edit.toolbar.buttons.removeDisabled))}}),L.EditToolbar.Edit=L.Handler.extend({statics:{TYPE:"edit"},initialize:function(t,e){if(L.Handler.prototype.initialize.call(this,t),L.setOptions(this,e),this._featureGroup=e.featureGroup,!(this._featureGroup instanceof L.FeatureGroup))throw new Error("options.featureGroup must be a L.FeatureGroup");this._uneditedLayerProps={},this.type=L.EditToolbar.Edit.TYPE;var i=L.version.split(".");1===parseInt(i[0],10)&&parseInt(i[1],10)>=2?L.EditToolbar.Edit.include(L.Evented.prototype):L.EditToolbar.Edit.include(L.Mixin.Events)},enable:function(){!this._enabled&&this._hasAvailableLayers()&&(this.fire("enabled",{handler:this.type}),this._map.fire(L.Draw.Event.EDITSTART,{handler:this.type}),L.Handler.prototype.enable.call(this),this._featureGroup.on("layeradd",this._enableLayerEdit,this).on("layerremove",this._disableLayerEdit,this))},disable:function(){this._enabled&&(this._featureGroup.off("layeradd",this._enableLayerEdit,this).off("layerremove",this._disableLayerEdit,this),L.Handler.prototype.disable.call(this),this._map.fire(L.Draw.Event.EDITSTOP,{handler:this.type}),this.fire("disabled",{handler:this.type}))},addHooks:function(){var t=this._map;t&&(t.getContainer().focus(),this._featureGroup.eachLayer(this._enableLayerEdit,this),this._tooltip=new L.Draw.Tooltip(this._map),this._tooltip.updateContent({text:L.drawLocal.edit.handlers.edit.tooltip.text,subtext:L.drawLocal.edit.handlers.edit.tooltip.subtext}),t._editTooltip=this._tooltip,this._updateTooltip(),this._map.on("mousemove",this._onMouseMove,this).on("touchmove",this._onMouseMove,this).on("MSPointerMove",this._onMouseMove,this).on(L.Draw.Event.EDITVERTEX,this._updateTooltip,this))},removeHooks:function(){this._map&&(this._featureGroup.eachLayer(this._disableLayerEdit,this),this._map._editTooltip.dispose(),this._map._editTooltip=null,this._uneditedLayerProps={},this._tooltip.dispose(),this._tooltip=null,this._map.off("mousemove",this._onMouseMove,this).off("touchmove",this._onMouseMove,this).off("MSPointerMove",this._onMouseMove,this).off(L.Draw.Event.EDITVERTEX,this._updateTooltip,this))},revertLayers:function(){this._featureGroup.eachLayer(function(t){this._revertLayer(t)},this)},save:function(){var t=new L.LayerGroup;this._featureGroup.eachLayer(function(e){e.edited&&(t.addLayer(e),e.edited=!1)}),this._map.fire(L.Draw.Event.EDITED,{layers:t})},_backupLayer:function(t){var e=L.Util.stamp(t);this._uneditedLayerProps[e]||(t instanceof L.Polyline||t instanceof L.Polygon||t instanceof L.Rectangle?this._uneditedLayerProps[e]={latlngs:L.LatLngUtil.cloneLatLngs(t.getLatLngs())}:t instanceof L.Circle?this._uneditedLayerProps[e]={latlng:L.LatLngUtil.cloneLatLng(t.getLatLng()),radius:t.getRadius()}:(t instanceof L.Marker||t instanceof L.CircleMarker)&&(this._uneditedLayerProps[e]={latlng:L.LatLngUtil.cloneLatLng(t.getLatLng())}))},_getTooltipText:function(){return{text:L.drawLocal.edit.handlers.edit.tooltip.text,subtext:L.drawLocal.edit.handlers.edit.tooltip.subtext}},_updateTooltip:function(){this._tooltip.updateContent(this._getTooltipText())},_revertLayer:function(t){var e=L.Util.stamp(t);t.edited=!1,this._uneditedLayerProps.hasOwnProperty(e)&&(t instanceof L.Polyline||t instanceof L.Polygon||t instanceof L.Rectangle?t.setLatLngs(this._uneditedLayerProps[e].latlngs):t instanceof L.Circle?(t.setLatLng(this._uneditedLayerProps[e].latlng),t.setRadius(this._uneditedLayerProps[e].radius)):(t instanceof L.Marker||t instanceof L.CircleMarker)&&t.setLatLng(this._uneditedLayerProps[e].latlng),t.fire("revert-edited",{layer:t}))},_enableLayerEdit:function(t){var e,i,o=t.layer||t.target||t;this._backupLayer(o),this.options.poly&&(i=L.Util.extend({},this.options.poly),o.options.poly=i),this.options.selectedPathOptions&&(e=L.Util.extend({},this.options.selectedPathOptions),e.maintainColor&&(e.color=o.options.color,e.fillColor=o.options.fillColor),o.options.original=L.extend({},o.options),o.options.editing=e),o instanceof L.Marker?(o.editing&&o.editing.enable(),o.dragging.enable(),o.on("dragend",this._onMarkerDragEnd).on("touchmove",this._onTouchMove,this).on("MSPointerMove",this._onTouchMove,this).on("touchend",this._onMarkerDragEnd,this).on("MSPointerUp",this._onMarkerDragEnd,this)):o.editing.enable()},_disableLayerEdit:function(t){var e=t.layer||t.target||t;e.edited=!1,e.editing&&e.editing.disable(), delete e.options.editing,delete e.options.original,this._selectedPathOptions&&(e instanceof L.Marker?this._toggleMarkerHighlight(e):(e.setStyle(e.options.previousOptions),delete e.options.previousOptions)),e instanceof L.Marker?(e.dragging.disable(),e.off("dragend",this._onMarkerDragEnd,this).off("touchmove",this._onTouchMove,this).off("MSPointerMove",this._onTouchMove,this).off("touchend",this._onMarkerDragEnd,this).off("MSPointerUp",this._onMarkerDragEnd,this)):e.editing.disable()},_onMouseMove:function(t){this._tooltip.updatePosition(t.latlng)},_onMarkerDragEnd:function(t){var e=t.target;e.edited=!0,this._map.fire(L.Draw.Event.EDITMOVE,{layer:e})},_onTouchMove:function(t){var e=t.originalEvent.changedTouches[0],i=this._map.mouseEventToLayerPoint(e),o=this._map.layerPointToLatLng(i);t.target.setLatLng(o)},_hasAvailableLayers:function(){return 0!==this._featureGroup.getLayers().length}}),L.EditToolbar.Delete=L.Handler.extend({statics:{TYPE:"remove"},initialize:function(t,e){if(L.Handler.prototype.initialize.call(this,t),L.Util.setOptions(this,e),this._deletableLayers=this.options.featureGroup,!(this._deletableLayers instanceof L.FeatureGroup))throw new Error("options.featureGroup must be a L.FeatureGroup");this.type=L.EditToolbar.Delete.TYPE;var i=L.version.split(".");1===parseInt(i[0],10)&&parseInt(i[1],10)>=2?L.EditToolbar.Delete.include(L.Evented.prototype):L.EditToolbar.Delete.include(L.Mixin.Events)},enable:function(){!this._enabled&&this._hasAvailableLayers()&&(this.fire("enabled",{handler:this.type}),this._map.fire(L.Draw.Event.DELETESTART,{handler:this.type}),L.Handler.prototype.enable.call(this),this._deletableLayers.on("layeradd",this._enableLayerDelete,this).on("layerremove",this._disableLayerDelete,this))},disable:function(){this._enabled&&(this._deletableLayers.off("layeradd",this._enableLayerDelete,this).off("layerremove",this._disableLayerDelete,this),L.Handler.prototype.disable.call(this),this._map.fire(L.Draw.Event.DELETESTOP,{handler:this.type}),this.fire("disabled",{handler:this.type}))},addHooks:function(){var t=this._map;t&&(t.getContainer().focus(),this._deletableLayers.eachLayer(this._enableLayerDelete,this),this._deletedLayers=new L.LayerGroup,this._tooltip=new L.Draw.Tooltip(this._map),this._tooltip.updateContent({text:L.drawLocal.edit.handlers.remove.tooltip.text}),this._map.on("mousemove",this._onMouseMove,this))},removeHooks:function(){this._map&&(this._deletableLayers.eachLayer(this._disableLayerDelete,this),this._deletedLayers=null,this._tooltip.dispose(),this._tooltip=null,this._map.off("mousemove",this._onMouseMove,this))},revertLayers:function(){this._deletedLayers.eachLayer(function(t){this._deletableLayers.addLayer(t),t.fire("revert-deleted",{layer:t})},this)},save:function(){this._map.fire(L.Draw.Event.DELETED,{layers:this._deletedLayers})},removeAllLayers:function(){this._deletableLayers.eachLayer(function(t){this._removeLayer({layer:t})},this),this.save()},_enableLayerDelete:function(t){(t.layer||t.target||t).on("click",this._removeLayer,this)},_disableLayerDelete:function(t){var e=t.layer||t.target||t;e.off("click",this._removeLayer,this),this._deletedLayers.removeLayer(e)},_removeLayer:function(t){var e=t.layer||t.target||t;this._deletableLayers.removeLayer(e),this._deletedLayers.addLayer(e),e.fire("deleted")},_onMouseMove:function(t){this._tooltip.updatePosition(t.latlng)},_hasAvailableLayers:function(){return 0!==this._deletableLayers.getLayers().length}})}(window,document); \ No newline at end of file From 2538bd99d58eaf00ba98520add0f019a01637b43 Mon Sep 17 00:00:00 2001 From: BONDA Sai Aswath Date: Fri, 4 Feb 2022 21:42:26 +0530 Subject: [PATCH 5/6] Added changes for package-lock json --- package-lock.json | 87 +++++++++++++++++++++++++++++++++++------------ 1 file changed, 65 insertions(+), 22 deletions(-) diff --git a/package-lock.json b/package-lock.json index 89128cf8f..141840745 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1464,7 +1464,8 @@ "ansi-regex": { "version": "2.1.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "aproba": { "version": "1.1.1", @@ -1515,7 +1516,8 @@ "balanced-match": { "version": "0.4.2", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "bcrypt-pbkdf": { "version": "1.0.1", @@ -1530,6 +1532,7 @@ "version": "0.0.9", "bundled": true, "dev": true, + "optional": true, "requires": { "inherits": "~2.0.0" } @@ -1538,6 +1541,7 @@ "version": "2.10.1", "bundled": true, "dev": true, + "optional": true, "requires": { "hoek": "2.x.x" } @@ -1546,6 +1550,7 @@ "version": "1.1.7", "bundled": true, "dev": true, + "optional": true, "requires": { "balanced-match": "^0.4.1", "concat-map": "0.0.1" @@ -1554,7 +1559,8 @@ "buffer-shims": { "version": "1.0.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "caseless": { "version": "0.12.0", @@ -1571,12 +1577,14 @@ "code-point-at": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "combined-stream": { "version": "1.0.5", "bundled": true, "dev": true, + "optional": true, "requires": { "delayed-stream": "~1.0.0" } @@ -1584,22 +1592,26 @@ "concat-map": { "version": "0.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "console-control-strings": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "core-util-is": { "version": "1.0.2", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "cryptiles": { "version": "2.0.5", "bundled": true, "dev": true, + "optional": true, "requires": { "boom": "2.x.x" } @@ -1639,7 +1651,8 @@ "delayed-stream": { "version": "1.0.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "delegates": { "version": "1.0.0", @@ -1671,7 +1684,8 @@ "extsprintf": { "version": "1.0.2", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "forever-agent": { "version": "0.6.1", @@ -1693,12 +1707,14 @@ "fs.realpath": { "version": "1.0.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "fstream": { "version": "1.0.11", "bundled": true, "dev": true, + "optional": true, "requires": { "graceful-fs": "^4.1.2", "inherits": "~2.0.0", @@ -1754,6 +1770,7 @@ "version": "7.1.2", "bundled": true, "dev": true, + "optional": true, "requires": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", @@ -1766,7 +1783,8 @@ "graceful-fs": { "version": "4.1.11", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "har-schema": { "version": "1.0.5", @@ -1794,6 +1812,7 @@ "version": "3.1.3", "bundled": true, "dev": true, + "optional": true, "requires": { "boom": "2.x.x", "cryptiles": "2.x.x", @@ -1804,7 +1823,8 @@ "hoek": { "version": "2.16.3", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "http-signature": { "version": "1.1.1", @@ -1821,6 +1841,7 @@ "version": "1.0.6", "bundled": true, "dev": true, + "optional": true, "requires": { "once": "^1.3.0", "wrappy": "1" @@ -1829,7 +1850,8 @@ "inherits": { "version": "2.0.3", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "ini": { "version": "1.3.4", @@ -1841,6 +1863,7 @@ "version": "1.0.0", "bundled": true, "dev": true, + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -1854,7 +1877,8 @@ "isarray": { "version": "1.0.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "isstream": { "version": "0.1.2", @@ -1927,12 +1951,14 @@ "mime-db": { "version": "1.27.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "mime-types": { "version": "2.1.15", "bundled": true, "dev": true, + "optional": true, "requires": { "mime-db": "~1.27.0" } @@ -1941,6 +1967,7 @@ "version": "3.0.4", "bundled": true, "dev": true, + "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -1948,12 +1975,14 @@ "minimist": { "version": "0.0.8", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "mkdirp": { "version": "0.5.1", "bundled": true, "dev": true, + "optional": true, "requires": { "minimist": "0.0.8" } @@ -2008,7 +2037,8 @@ "number-is-nan": { "version": "1.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "oauth-sign": { "version": "0.8.2", @@ -2026,6 +2056,7 @@ "version": "1.4.0", "bundled": true, "dev": true, + "optional": true, "requires": { "wrappy": "1" } @@ -2055,7 +2086,8 @@ "path-is-absolute": { "version": "1.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "performance-now": { "version": "0.2.0", @@ -2066,7 +2098,8 @@ "process-nextick-args": { "version": "1.0.7", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "punycode": { "version": "1.4.1", @@ -2104,6 +2137,7 @@ "version": "2.2.9", "bundled": true, "dev": true, + "optional": true, "requires": { "buffer-shims": "~1.0.0", "core-util-is": "~1.0.0", @@ -2148,6 +2182,7 @@ "version": "2.6.1", "bundled": true, "dev": true, + "optional": true, "requires": { "glob": "^7.0.5" } @@ -2155,7 +2190,8 @@ "safe-buffer": { "version": "5.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "semver": { "version": "5.3.0", @@ -2179,6 +2215,7 @@ "version": "1.0.9", "bundled": true, "dev": true, + "optional": true, "requires": { "hoek": "2.x.x" } @@ -2212,6 +2249,7 @@ "version": "1.0.2", "bundled": true, "dev": true, + "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -2222,6 +2260,7 @@ "version": "1.0.1", "bundled": true, "dev": true, + "optional": true, "requires": { "safe-buffer": "^5.0.1" } @@ -2236,6 +2275,7 @@ "version": "3.0.1", "bundled": true, "dev": true, + "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -2250,6 +2290,7 @@ "version": "2.2.1", "bundled": true, "dev": true, + "optional": true, "requires": { "block-stream": "*", "fstream": "^1.0.2", @@ -2305,7 +2346,8 @@ "util-deprecate": { "version": "1.0.2", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "uuid": { "version": "3.0.1", @@ -2334,7 +2376,8 @@ "wrappy": { "version": "1.0.2", "bundled": true, - "dev": true + "dev": true, + "optional": true } } }, From 507fa04993005ca65e224ccf97b4067975ec3114 Mon Sep 17 00:00:00 2001 From: BONDA Sai Aswath Date: Sat, 5 Feb 2022 09:49:06 +0530 Subject: [PATCH 6/6] Adjusted editTooltip --- dist/leaflet.draw-src.js | 8 ++++---- dist/leaflet.draw-src.map | 2 +- dist/leaflet.draw.js | 4 ++-- src/edit/handler/Edit.Circle.js | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/dist/leaflet.draw-src.js b/dist/leaflet.draw-src.js index 02a6353b2..72a229e60 100644 --- a/dist/leaflet.draw-src.js +++ b/dist/leaflet.draw-src.js @@ -1,5 +1,5 @@ /* - Leaflet.draw 1.0.3+638b962, a plugin that adds drawing and editing tools to Leaflet powered maps. + Leaflet.draw 1.0.3+2538bd9, a plugin that adds drawing and editing tools to Leaflet powered maps. (c) 2012-2017, Jacob Toye, Jon West, Smartrak, Leaflet https://github.com/Leaflet/Leaflet.draw @@ -8,7 +8,7 @@ (function (window, document, undefined) {/** * Leaflet.draw assumes that you have already included the Leaflet library. */ -L.drawVersion = "1.0.3+638b962"; +L.drawVersion = "1.0.3+2538bd9"; /** * @class L.Draw * @aka Draw @@ -2755,8 +2755,8 @@ L.Edit.Circle = L.Edit.CircleMarker.extend({ this._shape.setRadius(radius); if (this._map._editTooltip) { - this._map._editTooltip.updatePosition(latlng); - this._map._editTooltip.updateContent({ + this._map._editTooltip.updatePosition(latlng); + this._map._editTooltip.updateContent({ text: L.drawLocal.edit.handlers.edit.tooltip.subtext + '
' + L.drawLocal.edit.handlers.edit.tooltip.text, subtext: L.drawLocal.draw.handlers.circle.radius + ': ' + L.GeometryUtil.readableDistance(radius, true, this.options.feet, this.options.nautic) diff --git a/dist/leaflet.draw-src.map b/dist/leaflet.draw-src.map index d13d09e00..303659ac9 100644 --- a/dist/leaflet.draw-src.map +++ b/dist/leaflet.draw-src.map @@ -1 +1 @@ -{"version":3,"sources":["src/Leaflet.draw.js","src/Leaflet.Draw.Event.js","src/draw/handler/Draw.Feature.js","src/draw/handler/Draw.Polyline.js","src/draw/handler/Draw.Polygon.js","src/draw/handler/Draw.SimpleShape.js","src/draw/handler/Draw.Rectangle.js","src/draw/handler/Draw.Marker.js","src/draw/handler/Draw.CircleMarker.js","src/draw/handler/Draw.Circle.js","src/edit/handler/Edit.Marker.js","src/edit/handler/Edit.Poly.js","src/edit/handler/Edit.SimpleShape.js","src/edit/handler/Edit.Rectangle.js","src/edit/handler/Edit.CircleMarker.js","src/edit/handler/Edit.Circle.js","src/ext/TouchEvents.js","src/ext/LatLngUtil.js","src/ext/GeometryUtil.js","src/ext/LineUtil.Intersect.js","src/ext/Polyline.Intersect.js","src/ext/Polygon.Intersect.js","src/Control.Draw.js","src/Toolbar.js","src/Tooltip.js","src/draw/DrawToolbar.js","src/edit/EditToolbar.js","src/edit/handler/EditToolbar.Edit.js","src/edit/handler/EditToolbar.Delete.js"],"names":[],"mappings":";;;;;;;yCAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC7LA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AChLA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACxGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AChlBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACjIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACvHA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AClGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC/HA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC1CA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACnFA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACpFA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACxgBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACrOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC7HA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACrDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC1DA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AChRA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC5BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACrKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACtBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC1GA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACjCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACtHA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC9UA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACtHA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC9GA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AClMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACnSA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","sourcesContent":["/**\r\n * Leaflet.draw assumes that you have already included the Leaflet library.\r\n */\r\nL.drawVersion = \"1.0.3+638b962\";\r\n/**\r\n * @class L.Draw\r\n * @aka Draw\r\n *\r\n *\r\n * To add the draw toolbar set the option drawControl: true in the map options.\r\n *\r\n * @example\r\n * ```js\r\n * var map = L.map('map', {drawControl: true}).setView([51.505, -0.09], 13);\r\n *\r\n * L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {\r\n * attribution: '© OpenStreetMap contributors'\r\n * }).addTo(map);\r\n * ```\r\n *\r\n * ### Adding the edit toolbar\r\n * To use the edit toolbar you must initialise the Leaflet.draw control and manually add it to the map.\r\n *\r\n * ```js\r\n * var map = L.map('map').setView([51.505, -0.09], 13);\r\n *\r\n * L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {\r\n * attribution: '© OpenStreetMap contributors'\r\n * }).addTo(map);\r\n *\r\n * // FeatureGroup is to store editable layers\r\n * var drawnItems = new L.FeatureGroup();\r\n * map.addLayer(drawnItems);\r\n *\r\n * var drawControl = new L.Control.Draw({\r\n * edit: {\r\n * featureGroup: drawnItems\r\n * }\r\n * });\r\n * map.addControl(drawControl);\r\n * ```\r\n *\r\n * The key here is the featureGroup option. This tells the plugin which FeatureGroup contains the layers that\r\n * should be editable. The featureGroup can contain 0 or more features with geometry types Point, LineString, and Polygon.\r\n * Leaflet.draw does not work with multigeometry features such as MultiPoint, MultiLineString, MultiPolygon,\r\n * or GeometryCollection. If you need to add multigeometry features to the draw plugin, convert them to a\r\n * FeatureCollection of non-multigeometries (Points, LineStrings, or Polygons).\r\n */\r\nL.Draw = {};\r\n\r\n/**\r\n * @class L.drawLocal\r\n * @aka L.drawLocal\r\n *\r\n * The core toolbar class of the API — it is used to create the toolbar ui\r\n *\r\n * @example\r\n * ```js\r\n * var modifiedDraw = L.drawLocal.extend({\r\n * draw: {\r\n * toolbar: {\r\n * buttons: {\r\n * polygon: 'Draw an awesome polygon'\r\n * }\r\n * }\r\n * }\r\n * });\r\n * ```\r\n *\r\n * The default state for the control is the draw toolbar just below the zoom control.\r\n * This will allow map users to draw vectors and markers.\r\n * **Please note the edit toolbar is not enabled by default.**\r\n */\r\nL.drawLocal = {\r\n\t// format: {\r\n\t// \tnumeric: {\r\n\t// \t\tdelimiters: {\r\n\t// \t\t\tthousands: ',',\r\n\t// \t\t\tdecimal: '.'\r\n\t// \t\t}\r\n\t// \t}\r\n\t// },\r\n\tdraw: {\r\n\t\ttoolbar: {\r\n\t\t\t// #TODO: this should be reorganized where actions are nested in actions\r\n\t\t\t// ex: actions.undo or actions.cancel\r\n\t\t\tactions: {\r\n\t\t\t\ttitle: 'Cancel drawing',\r\n\t\t\t\ttext: 'Cancel'\r\n\t\t\t},\r\n\t\t\tfinish: {\r\n\t\t\t\ttitle: 'Finish drawing',\r\n\t\t\t\ttext: 'Finish'\r\n\t\t\t},\r\n\t\t\tundo: {\r\n\t\t\t\ttitle: 'Delete last point drawn',\r\n\t\t\t\ttext: 'Delete last point'\r\n\t\t\t},\r\n\t\t\tbuttons: {\r\n\t\t\t\tpolyline: 'Draw a polyline',\r\n\t\t\t\tpolygon: 'Draw a polygon',\r\n\t\t\t\trectangle: 'Draw a rectangle',\r\n\t\t\t\tcircle: 'Draw a circle',\r\n\t\t\t\tmarker: 'Draw a marker',\r\n\t\t\t\tcirclemarker: 'Draw a circlemarker'\r\n\t\t\t}\r\n\t\t},\r\n\t\thandlers: {\r\n\t\t\tcircle: {\r\n\t\t\t\ttooltip: {\r\n\t\t\t\t\tstart: 'Click and drag to draw circle.'\r\n\t\t\t\t},\r\n\t\t\t\tradius: 'Radius'\r\n\t\t\t},\r\n\t\t\tcirclemarker: {\r\n\t\t\t\ttooltip: {\r\n\t\t\t\t\tstart: 'Click map to place circle marker.'\r\n\t\t\t\t}\r\n\t\t\t},\r\n\t\t\tmarker: {\r\n\t\t\t\ttooltip: {\r\n\t\t\t\t\tstart: 'Click map to place marker.'\r\n\t\t\t\t}\r\n\t\t\t},\r\n\t\t\tpolygon: {\r\n\t\t\t\ttooltip: {\r\n\t\t\t\t\tstart: 'Click to start drawing shape.',\r\n\t\t\t\t\tcont: 'Click to continue drawing shape.',\r\n\t\t\t\t\tend: 'Click first point to close this shape.'\r\n\t\t\t\t}\r\n\t\t\t},\r\n\t\t\tpolyline: {\r\n\t\t\t\terror: 'Error: shape edges cannot cross!',\r\n\t\t\t\ttooltip: {\r\n\t\t\t\t\tstart: 'Click to start drawing line.',\r\n\t\t\t\t\tcont: 'Click to continue drawing line.',\r\n\t\t\t\t\tend: 'Click last point to finish line.'\r\n\t\t\t\t}\r\n\t\t\t},\r\n\t\t\trectangle: {\r\n\t\t\t\ttooltip: {\r\n\t\t\t\t\tstart: 'Click and drag to draw rectangle.'\r\n\t\t\t\t}\r\n\t\t\t},\r\n\t\t\tsimpleshape: {\r\n\t\t\t\ttooltip: {\r\n\t\t\t\t\tend: 'Release mouse to finish drawing.'\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t},\r\n\tedit: {\r\n\t\ttoolbar: {\r\n\t\t\tactions: {\r\n\t\t\t\tsave: {\r\n\t\t\t\t\ttitle: 'Save changes',\r\n\t\t\t\t\ttext: 'Save'\r\n\t\t\t\t},\r\n\t\t\t\tcancel: {\r\n\t\t\t\t\ttitle: 'Cancel editing, discards all changes',\r\n\t\t\t\t\ttext: 'Cancel'\r\n\t\t\t\t},\r\n\t\t\t\tclearAll: {\r\n\t\t\t\t\ttitle: 'Clear all layers',\r\n\t\t\t\t\ttext: 'Clear All'\r\n\t\t\t\t}\r\n\t\t\t},\r\n\t\t\tbuttons: {\r\n\t\t\t\tedit: 'Edit layers',\r\n\t\t\t\teditDisabled: 'No layers to edit',\r\n\t\t\t\tremove: 'Delete layers',\r\n\t\t\t\tremoveDisabled: 'No layers to delete'\r\n\t\t\t}\r\n\t\t},\r\n\t\thandlers: {\r\n\t\t\tedit: {\r\n\t\t\t\ttooltip: {\r\n\t\t\t\t\ttext: 'Drag handles or markers to edit features.',\r\n\t\t\t\t\tsubtext: 'Click cancel to undo changes.'\r\n\t\t\t\t}\r\n\t\t\t},\r\n\t\t\tremove: {\r\n\t\t\t\ttooltip: {\r\n\t\t\t\t\ttext: 'Click on a feature to remove.'\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n};\r\n","/**\r\n * ### Events\r\n * Once you have successfully added the Leaflet.draw plugin to your map you will want to respond to the different\r\n * actions users can initiate. The following events will be triggered on the map:\r\n *\r\n * @class L.Draw.Event\r\n * @aka Draw.Event\r\n *\r\n * Use `L.Draw.Event.EVENTNAME` constants to ensure events are correct.\r\n *\r\n * @example\r\n * ```js\r\n * map.on(L.Draw.Event.CREATED; function (e) {\r\n * var type = e.layerType,\r\n * layer = e.layer;\r\n *\r\n * if (type === 'marker') {\r\n * // Do marker specific actions\r\n * }\r\n *\r\n * // Do whatever else you need to. (save to db; add to map etc)\r\n * map.addLayer(layer);\r\n *});\r\n * ```\r\n */\r\nL.Draw.Event = {};\r\n/**\r\n * @event draw:created: PolyLine; Polygon; Rectangle; Circle; Marker | String\r\n *\r\n * Layer that was just created.\r\n * The type of layer this is. One of: `polyline`; `polygon`; `rectangle`; `circle`; `marker`\r\n * Triggered when a new vector or marker has been created.\r\n *\r\n */\r\nL.Draw.Event.CREATED = 'draw:created';\r\n\r\n/**\r\n * @event draw:edited: LayerGroup\r\n *\r\n * List of all layers just edited on the map.\r\n *\r\n *\r\n * Triggered when layers in the FeatureGroup; initialised with the plugin; have been edited and saved.\r\n *\r\n * @example\r\n * ```js\r\n * map.on('draw:edited', function (e) {\r\n * var layers = e.layers;\r\n * layers.eachLayer(function (layer) {\r\n * //do whatever you want; most likely save back to db\r\n * });\r\n * });\r\n * ```\r\n */\r\nL.Draw.Event.EDITED = 'draw:edited';\r\n\r\n/**\r\n * @event draw:deleted: LayerGroup\r\n *\r\n * List of all layers just removed from the map.\r\n *\r\n * Triggered when layers have been removed (and saved) from the FeatureGroup.\r\n */\r\nL.Draw.Event.DELETED = 'draw:deleted';\r\n\r\n/**\r\n * @event draw:drawstart: String\r\n *\r\n * The type of layer this is. One of:`polyline`; `polygon`; `rectangle`; `circle`; `marker`\r\n *\r\n * Triggered when the user has chosen to draw a particular vector or marker.\r\n */\r\nL.Draw.Event.DRAWSTART = 'draw:drawstart';\r\n\r\n/**\r\n * @event draw:drawstop: String\r\n *\r\n * The type of layer this is. One of: `polyline`; `polygon`; `rectangle`; `circle`; `marker`\r\n *\r\n * Triggered when the user has finished a particular vector or marker.\r\n */\r\n\r\nL.Draw.Event.DRAWSTOP = 'draw:drawstop';\r\n\r\n/**\r\n * @event draw:drawvertex: LayerGroup\r\n *\r\n * List of all layers just being added from the map.\r\n *\r\n * Triggered when a vertex is created on a polyline or polygon.\r\n */\r\nL.Draw.Event.DRAWVERTEX = 'draw:drawvertex';\r\n\r\n/**\r\n * @event draw:editstart: String\r\n *\r\n * The type of edit this is. One of: `edit`\r\n *\r\n * Triggered when the user starts edit mode by clicking the edit tool button.\r\n */\r\n\r\nL.Draw.Event.EDITSTART = 'draw:editstart';\r\n\r\n/**\r\n * @event draw:editmove: ILayer\r\n *\r\n * Layer that was just moved.\r\n *\r\n * Triggered as the user moves a rectangle; circle or marker.\r\n */\r\nL.Draw.Event.EDITMOVE = 'draw:editmove';\r\n\r\n/**\r\n * @event draw:editresize: ILayer\r\n *\r\n * Layer that was just moved.\r\n *\r\n * Triggered as the user resizes a rectangle or circle.\r\n */\r\nL.Draw.Event.EDITRESIZE = 'draw:editresize';\r\n\r\n/**\r\n * @event draw:editvertex: LayerGroup\r\n *\r\n * List of all layers just being edited from the map.\r\n *\r\n * Triggered when a vertex is edited on a polyline or polygon.\r\n */\r\nL.Draw.Event.EDITVERTEX = 'draw:editvertex';\r\n\r\n/**\r\n * @event draw:editstop: String\r\n *\r\n * The type of edit this is. One of: `edit`\r\n *\r\n * Triggered when the user has finshed editing (edit mode) and saves edits.\r\n */\r\nL.Draw.Event.EDITSTOP = 'draw:editstop';\r\n\r\n/**\r\n * @event draw:deletestart: String\r\n *\r\n * The type of edit this is. One of: `remove`\r\n *\r\n * Triggered when the user starts remove mode by clicking the remove tool button.\r\n */\r\nL.Draw.Event.DELETESTART = 'draw:deletestart';\r\n\r\n/**\r\n * @event draw:deletestop: String\r\n *\r\n * The type of edit this is. One of: `remove`\r\n *\r\n * Triggered when the user has finished removing shapes (remove mode) and saves.\r\n */\r\nL.Draw.Event.DELETESTOP = 'draw:deletestop';\r\n\r\n/**\r\n * @event draw:toolbaropened: String\r\n *\r\n * Triggered when a toolbar is opened.\r\n */\r\nL.Draw.Event.TOOLBAROPENED = 'draw:toolbaropened';\r\n\r\n/**\r\n * @event draw:toolbarclosed: String\r\n *\r\n * Triggered when a toolbar is closed.\r\n */\r\nL.Draw.Event.TOOLBARCLOSED = 'draw:toolbarclosed';\r\n\r\n/**\r\n * @event draw:markercontext: String\r\n *\r\n * Triggered when a marker is right clicked.\r\n */\r\nL.Draw.Event.MARKERCONTEXT = 'draw:markercontext';","L.Draw = L.Draw || {};\r\n\r\n/**\r\n * @class L.Draw.Feature\r\n * @aka Draw.Feature\r\n */\r\nL.Draw.Feature = L.Handler.extend({\r\n\r\n\t// @method initialize(): void\r\n\tinitialize: function (map, options) {\r\n\t\tthis._map = map;\r\n\t\tthis._container = map._container;\r\n\t\tthis._overlayPane = map._panes.overlayPane;\r\n\t\tthis._popupPane = map._panes.popupPane;\r\n\r\n\t\t// Merge default shapeOptions options with custom shapeOptions\r\n\t\tif (options && options.shapeOptions) {\r\n\t\t\toptions.shapeOptions = L.Util.extend({}, this.options.shapeOptions, options.shapeOptions);\r\n\t\t}\r\n\t\tL.setOptions(this, options);\r\n\r\n\t\tvar version = L.version.split('.');\r\n\t\t//If Version is >= 1.2.0\r\n\t\tif (parseInt(version[0], 10) === 1 && parseInt(version[1], 10) >= 2) {\r\n\t\t\tL.Draw.Feature.include(L.Evented.prototype);\r\n\t\t} else {\r\n\t\t\tL.Draw.Feature.include(L.Mixin.Events);\r\n\t\t}\r\n\t},\r\n\r\n\t// @method enable(): void\r\n\t// Enables this handler\r\n\tenable: function () {\r\n\t\tif (this._enabled) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tL.Handler.prototype.enable.call(this);\r\n\r\n\t\tthis.fire('enabled', {handler: this.type});\r\n\r\n\t\tthis._map.fire(L.Draw.Event.DRAWSTART, {layerType: this.type});\r\n\t},\r\n\r\n\t// @method disable(): void\r\n\tdisable: function () {\r\n\t\tif (!this._enabled) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tL.Handler.prototype.disable.call(this);\r\n\r\n\t\tthis._map.fire(L.Draw.Event.DRAWSTOP, {layerType: this.type});\r\n\r\n\t\tthis.fire('disabled', {handler: this.type});\r\n\t},\r\n\r\n\t// @method addHooks(): void\r\n\t// Add's event listeners to this handler\r\n\taddHooks: function () {\r\n\t\tvar map = this._map;\r\n\r\n\t\tif (map) {\r\n\t\t\tL.DomUtil.disableTextSelection();\r\n\r\n\t\t\tmap.getContainer().focus();\r\n\r\n\t\t\tthis._tooltip = new L.Draw.Tooltip(this._map);\r\n\r\n\t\t\tL.DomEvent.on(this._container, 'keyup', this._cancelDrawing, this);\r\n\t\t}\r\n\t},\r\n\r\n\t// @method removeHooks(): void\r\n\t// Removes event listeners from this handler\r\n\tremoveHooks: function () {\r\n\t\tif (this._map) {\r\n\t\t\tL.DomUtil.enableTextSelection();\r\n\r\n\t\t\tthis._tooltip.dispose();\r\n\t\t\tthis._tooltip = null;\r\n\r\n\t\t\tL.DomEvent.off(this._container, 'keyup', this._cancelDrawing, this);\r\n\t\t}\r\n\t},\r\n\r\n\t// @method setOptions(object): void\r\n\t// Sets new options to this handler\r\n\tsetOptions: function (options) {\r\n\t\tL.setOptions(this, options);\r\n\t},\r\n\r\n\t_fireCreatedEvent: function (layer) {\r\n\t\tthis._map.fire(L.Draw.Event.CREATED, {layer: layer, layerType: this.type});\r\n\t},\r\n\r\n\t// Cancel drawing when the escape key is pressed\r\n\t_cancelDrawing: function (e) {\r\n\t\tif (e.keyCode === 27) {\r\n\t\t\tthis._map.fire('draw:canceled', {layerType: this.type});\r\n\t\t\tthis.disable();\r\n\t\t}\r\n\t}\r\n});\r\n","/**\r\n * @class L.Draw.Polyline\r\n * @aka Draw.Polyline\r\n * @inherits L.Draw.Feature\r\n */\r\nL.Draw.Polyline = L.Draw.Feature.extend({\r\n\tstatics: {\r\n\t\tTYPE: 'polyline'\r\n\t},\r\n\r\n\tPoly: L.Polyline,\r\n\r\n\toptions: {\r\n\t\tallowIntersection: true,\r\n\t\trepeatMode: false,\r\n\t\tdrawError: {\r\n\t\t\tcolor: '#b00b00',\r\n\t\t\ttimeout: 2500\r\n\t\t},\r\n\t\ticon: new L.DivIcon({\r\n\t\t\ticonSize: new L.Point(8, 8),\r\n\t\t\tclassName: 'leaflet-div-icon leaflet-editing-icon'\r\n\t\t}),\r\n\t\ttouchIcon: new L.DivIcon({\r\n\t\t\ticonSize: new L.Point(20, 20),\r\n\t\t\tclassName: 'leaflet-div-icon leaflet-editing-icon leaflet-touch-icon'\r\n\t\t}),\r\n\t\tguidelineDistance: 20,\r\n\t\tmaxGuideLineLength: 4000,\r\n\t\tshapeOptions: {\r\n\t\t\tstroke: true,\r\n\t\t\tcolor: '#3388ff',\r\n\t\t\tweight: 4,\r\n\t\t\topacity: 0.5,\r\n\t\t\tfill: false,\r\n\t\t\tclickable: true\r\n\t\t},\r\n\t\tmetric: true, // Whether to use the metric measurement system or imperial\r\n\t\tfeet: true, // When not metric, to use feet instead of yards for display.\r\n\t\tnautic: false, // When not metric, not feet use nautic mile for display\r\n\t\tshowLength: true, // Whether to display distance in the tooltip\r\n\t\tzIndexOffset: 2000, // This should be > than the highest z-index any map layers\r\n\t\tfactor: 1, // To change distance calculation\r\n\t\tmaxPoints: 0 // Once this number of points are placed, finish shape\r\n\t},\r\n\r\n\t// @method initialize(): void\r\n\tinitialize: function (map, options) {\r\n\t\t// if touch, switch to touch icon\r\n\t\tif (L.Browser.touch) {\r\n\t\t\tthis.options.icon = this.options.touchIcon;\r\n\t\t}\r\n\r\n\t\t// Need to set this here to ensure the correct message is used.\r\n\t\tthis.options.drawError.message = L.drawLocal.draw.handlers.polyline.error;\r\n\r\n\t\t// Merge default drawError options with custom options\r\n\t\tif (options && options.drawError) {\r\n\t\t\toptions.drawError = L.Util.extend({}, this.options.drawError, options.drawError);\r\n\t\t}\r\n\r\n\t\t// Save the type so super can fire, need to do this as cannot do this.TYPE :(\r\n\t\tthis.type = L.Draw.Polyline.TYPE;\r\n\r\n\t\tL.Draw.Feature.prototype.initialize.call(this, map, options);\r\n\t},\r\n\r\n\t// @method addHooks(): void\r\n\t// Add listener hooks to this handler\r\n\taddHooks: function () {\r\n\t\tL.Draw.Feature.prototype.addHooks.call(this);\r\n\t\tif (this._map) {\r\n\t\t\tthis._markers = [];\r\n\r\n\t\t\tthis._markerGroup = new L.LayerGroup();\r\n\t\t\tthis._map.addLayer(this._markerGroup);\r\n\r\n\t\t\tthis._poly = new L.Polyline([], this.options.shapeOptions);\r\n\r\n\t\t\tthis._tooltip.updateContent(this._getTooltipText());\r\n\r\n\t\t\t// Make a transparent marker that will used to catch click events. These click\r\n\t\t\t// events will create the vertices. We need to do this so we can ensure that\r\n\t\t\t// we can create vertices over other map layers (markers, vector layers). We\r\n\t\t\t// also do not want to trigger any click handlers of objects we are clicking on\r\n\t\t\t// while drawing.\r\n\t\t\tif (!this._mouseMarker) {\r\n\t\t\t\tthis._mouseMarker = L.marker(this._map.getCenter(), {\r\n\t\t\t\t\ticon: L.divIcon({\r\n\t\t\t\t\t\tclassName: 'leaflet-mouse-marker',\r\n\t\t\t\t\t\ticonAnchor: [20, 20],\r\n\t\t\t\t\t\ticonSize: [40, 40]\r\n\t\t\t\t\t}),\r\n\t\t\t\t\topacity: 0,\r\n\t\t\t\t\tzIndexOffset: this.options.zIndexOffset\r\n\t\t\t\t});\r\n\t\t\t}\r\n\r\n\t\t\tthis._mouseMarker\r\n\t\t\t\t.on('mouseout', this._onMouseOut, this)\r\n\t\t\t\t.on('mousemove', this._onMouseMove, this) // Necessary to prevent 0.8 stutter\r\n\t\t\t\t.on('mousedown', this._onMouseDown, this)\r\n\t\t\t\t.on('mouseup', this._onMouseUp, this) // Necessary for 0.8 compatibility\r\n\t\t\t\t.addTo(this._map);\r\n\r\n\t\t\tthis._map\r\n\t\t\t\t.on('mouseup', this._onMouseUp, this) // Necessary for 0.7 compatibility\r\n\t\t\t\t.on('mousemove', this._onMouseMove, this)\r\n\t\t\t\t.on('zoomlevelschange', this._onZoomEnd, this)\r\n\t\t\t\t.on('touchstart', this._onTouch, this)\r\n\t\t\t\t.on('zoomend', this._onZoomEnd, this);\r\n\r\n\t\t}\r\n\t},\r\n\r\n\t// @method removeHooks(): void\r\n\t// Remove listener hooks from this handler.\r\n\tremoveHooks: function () {\r\n\t\tL.Draw.Feature.prototype.removeHooks.call(this);\r\n\r\n\t\tthis._clearHideErrorTimeout();\r\n\r\n\t\tthis._cleanUpShape();\r\n\r\n\t\t// remove markers from map\r\n\t\tthis._map.removeLayer(this._markerGroup);\r\n\t\tdelete this._markerGroup;\r\n\t\tdelete this._markers;\r\n\r\n\t\tthis._map.removeLayer(this._poly);\r\n\t\tdelete this._poly;\r\n\r\n\t\tthis._mouseMarker\r\n\t\t\t.off('mousedown', this._onMouseDown, this)\r\n\t\t\t.off('mouseout', this._onMouseOut, this)\r\n\t\t\t.off('mouseup', this._onMouseUp, this)\r\n\t\t\t.off('mousemove', this._onMouseMove, this);\r\n\t\tthis._map.removeLayer(this._mouseMarker);\r\n\t\tdelete this._mouseMarker;\r\n\r\n\t\t// clean up DOM\r\n\t\tthis._clearGuides();\r\n\r\n\t\tthis._map\r\n\t\t\t.off('mouseup', this._onMouseUp, this)\r\n\t\t\t.off('mousemove', this._onMouseMove, this)\r\n\t\t\t.off('zoomlevelschange', this._onZoomEnd, this)\r\n\t\t\t.off('zoomend', this._onZoomEnd, this)\r\n\t\t\t.off('touchstart', this._onTouch, this)\r\n\t\t\t.off('click', this._onTouch, this);\r\n\t},\r\n\r\n\t// @method deleteLastVertex(): void\r\n\t// Remove the last vertex from the polyline, removes polyline from map if only one point exists.\r\n\tdeleteLastVertex: function () {\r\n\t\tif (this._markers.length <= 1) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tvar lastMarker = this._markers.pop(),\r\n\t\t\tpoly = this._poly,\r\n\t\t\t// Replaces .spliceLatLngs()\r\n\t\t\tlatlngs = poly.getLatLngs(),\r\n\t\t\tlatlng = latlngs.splice(-1, 1)[0];\r\n\t\tthis._poly.setLatLngs(latlngs);\r\n\r\n\t\tthis._markerGroup.removeLayer(lastMarker);\r\n\r\n\t\tif (poly.getLatLngs().length < 2) {\r\n\t\t\tthis._map.removeLayer(poly);\r\n\t\t}\r\n\r\n\t\tthis._vertexChanged(latlng, false);\r\n\t},\r\n\r\n\t// @method addVertex(): void\r\n\t// Add a vertex to the end of the polyline\r\n\taddVertex: function (latlng) {\r\n\t\tvar markersLength = this._markers.length;\r\n\t\t// markersLength must be greater than or equal to 2 before intersections can occur\r\n\t\tif (markersLength >= 2 && !this.options.allowIntersection && this._poly.newLatLngIntersects(latlng)) {\r\n\t\t\tthis._showErrorTooltip();\r\n\t\t\treturn;\r\n\t\t}\r\n\t\telse if (this._errorShown) {\r\n\t\t\tthis._hideErrorTooltip();\r\n\t\t}\r\n\r\n\t\tthis._markers.push(this._createMarker(latlng));\r\n\r\n\t\tthis._poly.addLatLng(latlng);\r\n\r\n\t\tif (this._poly.getLatLngs().length === 2) {\r\n\t\t\tthis._map.addLayer(this._poly);\r\n\t\t}\r\n\r\n\t\tthis._vertexChanged(latlng, true);\r\n\t},\r\n\r\n\t// @method completeShape(): void\r\n\t// Closes the polyline between the first and last points\r\n\tcompleteShape: function () {\r\n\t\tif (this._markers.length <= 1 || !this._shapeIsValid()) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tthis._fireCreatedEvent();\r\n\t\tthis.disable();\r\n\r\n\t\tif (this.options.repeatMode) {\r\n\t\t\tthis.enable();\r\n\t\t}\r\n\t},\r\n\r\n\t_finishShape: function () {\r\n\t\tvar latlngs = this._poly._defaultShape ? this._poly._defaultShape() : this._poly.getLatLngs();\r\n\t\tvar intersects = this._poly.newLatLngIntersects(latlngs[latlngs.length - 1]);\r\n\r\n\t\tif ((!this.options.allowIntersection && intersects) || !this._shapeIsValid()) {\r\n\t\t\tthis._showErrorTooltip();\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tthis._fireCreatedEvent();\r\n\t\tthis.disable();\r\n\t\tif (this.options.repeatMode) {\r\n\t\t\tthis.enable();\r\n\t\t}\r\n\t},\r\n\r\n\t// Called to verify the shape is valid when the user tries to finish it\r\n\t// Return false if the shape is not valid\r\n\t_shapeIsValid: function () {\r\n\t\treturn true;\r\n\t},\r\n\r\n\t_onZoomEnd: function () {\r\n\t\tif (this._markers !== null) {\r\n\t\t\tthis._updateGuide();\r\n\t\t}\r\n\t},\r\n\r\n\t_onMouseMove: function (e) {\r\n\t\tvar newPos = this._map.mouseEventToLayerPoint(e.originalEvent);\r\n\t\tvar latlng = this._map.layerPointToLatLng(newPos);\r\n\r\n\t\t// Save latlng\r\n\t\t// should this be moved to _updateGuide() ?\r\n\t\tthis._currentLatLng = latlng;\r\n\r\n\t\tthis._updateTooltip(latlng);\r\n\r\n\t\t// Update the guide line\r\n\t\tthis._updateGuide(newPos);\r\n\r\n\t\t// Update the mouse marker position\r\n\t\tthis._mouseMarker.setLatLng(latlng);\r\n\r\n\t\tL.DomEvent.preventDefault(e.originalEvent);\r\n\t},\r\n\r\n\t_vertexChanged: function (latlng, added) {\r\n\t\tthis._map.fire(L.Draw.Event.DRAWVERTEX, {layers: this._markerGroup});\r\n\t\tthis._updateFinishHandler();\r\n\r\n\t\tthis._updateRunningMeasure(latlng, added);\r\n\r\n\t\tthis._clearGuides();\r\n\r\n\t\tthis._updateTooltip();\r\n\t},\r\n\r\n\t_onMouseDown: function (e) {\r\n\t\tif (!this._clickHandled && !this._touchHandled && !this._disableMarkers) {\r\n\t\t\tthis._onMouseMove(e);\r\n\t\t\tthis._clickHandled = true;\r\n\t\t\tthis._disableNewMarkers();\r\n\t\t\tvar originalEvent = e.originalEvent;\r\n\t\t\tvar clientX = originalEvent.clientX;\r\n\t\t\tvar clientY = originalEvent.clientY;\r\n\t\t\tthis._startPoint.call(this, clientX, clientY);\r\n\t\t}\r\n\t},\r\n\r\n\t_startPoint: function (clientX, clientY) {\r\n\t\tthis._mouseDownOrigin = L.point(clientX, clientY);\r\n\t},\r\n\r\n\t_onMouseUp: function (e) {\r\n\t\tvar originalEvent = e.originalEvent;\r\n\t\tvar clientX = originalEvent.clientX;\r\n\t\tvar clientY = originalEvent.clientY;\r\n\t\tthis._endPoint.call(this, clientX, clientY, e);\r\n\t\tthis._clickHandled = null;\r\n\t},\r\n\r\n\t_endPoint: function (clientX, clientY, e) {\r\n\t\tif (this._mouseDownOrigin) {\r\n\t\t\tvar dragCheckDistance = L.point(clientX, clientY)\r\n\t\t\t\t.distanceTo(this._mouseDownOrigin);\r\n\t\t\tvar lastPtDistance = this._calculateFinishDistance(e.latlng);\r\n\t\t\tif (this.options.maxPoints > 1 && this.options.maxPoints == this._markers.length + 1) {\r\n\t\t\t\tthis.addVertex(e.latlng);\r\n\t\t\t\tthis._finishShape();\r\n\t\t\t} else if (lastPtDistance < 10 && L.Browser.touch) {\r\n\t\t\t\tthis._finishShape();\r\n\t\t\t} else if (Math.abs(dragCheckDistance) < 9 * (window.devicePixelRatio || 1)) {\r\n\t\t\t\tthis.addVertex(e.latlng);\r\n\t\t\t}\r\n\t\t\tthis._enableNewMarkers(); // after a short pause, enable new markers\r\n\t\t}\r\n\t\tthis._mouseDownOrigin = null;\r\n\t},\r\n\r\n\t// ontouch prevented by clickHandled flag because some browsers fire both click/touch events,\r\n\t// causing unwanted behavior\r\n\t_onTouch: function (e) {\r\n\t\tvar originalEvent = e.originalEvent;\r\n\t\tvar clientX;\r\n\t\tvar clientY;\r\n\t\tif (originalEvent.touches && originalEvent.touches[0] && !this._clickHandled && !this._touchHandled && !this._disableMarkers) {\r\n\t\t\tclientX = originalEvent.touches[0].clientX;\r\n\t\t\tclientY = originalEvent.touches[0].clientY;\r\n\t\t\tthis._disableNewMarkers();\r\n\t\t\tthis._touchHandled = true;\r\n\t\t\tthis._startPoint.call(this, clientX, clientY);\r\n\t\t\tthis._endPoint.call(this, clientX, clientY, e);\r\n\t\t\tthis._touchHandled = null;\r\n\t\t}\r\n\t\tthis._clickHandled = null;\r\n\t},\r\n\r\n\t_onMouseOut: function () {\r\n\t\tif (this._tooltip) {\r\n\t\t\tthis._tooltip._onMouseOut.call(this._tooltip);\r\n\t\t}\r\n\t},\r\n\r\n\t// calculate if we are currently within close enough distance\r\n\t// of the closing point (first point for shapes, last point for lines)\r\n\t// this is semi-ugly code but the only reliable way i found to get the job done\r\n\t// note: calculating point.distanceTo between mouseDownOrigin and last marker did NOT work\r\n\t_calculateFinishDistance: function (potentialLatLng) {\r\n\t\tvar lastPtDistance;\r\n\t\tif (this._markers.length > 0) {\r\n\t\t\tvar finishMarker;\r\n\t\t\tif (this.type === L.Draw.Polyline.TYPE) {\r\n\t\t\t\tfinishMarker = this._markers[this._markers.length - 1];\r\n\t\t\t} else if (this.type === L.Draw.Polygon.TYPE) {\r\n\t\t\t\tfinishMarker = this._markers[0];\r\n\t\t\t} else {\r\n\t\t\t\treturn Infinity;\r\n\t\t\t}\r\n\t\t\tvar lastMarkerPoint = this._map.latLngToContainerPoint(finishMarker.getLatLng()),\r\n\t\t\t\tpotentialMarker = new L.Marker(potentialLatLng, {\r\n\t\t\t\t\ticon: this.options.icon,\r\n\t\t\t\t\tzIndexOffset: this.options.zIndexOffset * 2\r\n\t\t\t\t});\r\n\t\t\tvar potentialMarkerPint = this._map.latLngToContainerPoint(potentialMarker.getLatLng());\r\n\t\t\tlastPtDistance = lastMarkerPoint.distanceTo(potentialMarkerPint);\r\n\t\t} else {\r\n\t\t\tlastPtDistance = Infinity;\r\n\t\t}\r\n\t\treturn lastPtDistance;\r\n\t},\r\n\r\n\t_updateFinishHandler: function () {\r\n\t\tvar markerCount = this._markers.length;\r\n\t\t// The last marker should have a click handler to close the polyline\r\n\t\tif (markerCount > 1) {\r\n\t\t\tthis._markers[markerCount - 1].on('click', this._finishShape, this);\r\n\t\t}\r\n\r\n\t\t// Remove the old marker click handler (as only the last point should close the polyline)\r\n\t\tif (markerCount > 2) {\r\n\t\t\tthis._markers[markerCount - 2].off('click', this._finishShape, this);\r\n\t\t}\r\n\t},\r\n\r\n\t_createMarker: function (latlng) {\r\n\t\tvar marker = new L.Marker(latlng, {\r\n\t\t\ticon: this.options.icon,\r\n\t\t\tzIndexOffset: this.options.zIndexOffset * 2\r\n\t\t});\r\n\r\n\t\tthis._markerGroup.addLayer(marker);\r\n\r\n\t\treturn marker;\r\n\t},\r\n\r\n\t_updateGuide: function (newPos) {\r\n\t\tvar markerCount = this._markers ? this._markers.length : 0;\r\n\r\n\t\tif (markerCount > 0) {\r\n\t\t\tnewPos = newPos || this._map.latLngToLayerPoint(this._currentLatLng);\r\n\r\n\t\t\t// draw the guide line\r\n\t\t\tthis._clearGuides();\r\n\t\t\tthis._drawGuide(\r\n\t\t\t\tthis._map.latLngToLayerPoint(this._markers[markerCount - 1].getLatLng()),\r\n\t\t\t\tnewPos\r\n\t\t\t);\r\n\t\t}\r\n\t},\r\n\r\n\t_updateTooltip: function (latLng) {\r\n\t\tvar text = this._getTooltipText();\r\n\r\n\t\tif (latLng) {\r\n\t\t\tthis._tooltip.updatePosition(latLng);\r\n\t\t}\r\n\r\n\t\tif (!this._errorShown) {\r\n\t\t\tthis._tooltip.updateContent(text);\r\n\t\t}\r\n\t},\r\n\r\n\t_drawGuide: function (pointA, pointB) {\r\n\t\tvar length = Math.floor(Math.sqrt(Math.pow((pointB.x - pointA.x), 2) + Math.pow((pointB.y - pointA.y), 2))),\r\n\t\t\tguidelineDistance = this.options.guidelineDistance,\r\n\t\t\tmaxGuideLineLength = this.options.maxGuideLineLength,\r\n\t\t\t// Only draw a guideline with a max length\r\n\t\t\ti = length > maxGuideLineLength ? length - maxGuideLineLength : guidelineDistance,\r\n\t\t\tfraction,\r\n\t\t\tdashPoint,\r\n\t\t\tdash;\r\n\r\n\t\t//create the guides container if we haven't yet\r\n\t\tif (!this._guidesContainer) {\r\n\t\t\tthis._guidesContainer = L.DomUtil.create('div', 'leaflet-draw-guides', this._overlayPane);\r\n\t\t}\r\n\r\n\t\t//draw a dash every GuildeLineDistance\r\n\t\tfor (; i < length; i += this.options.guidelineDistance) {\r\n\t\t\t//work out fraction along line we are\r\n\t\t\tfraction = i / length;\r\n\r\n\t\t\t//calculate new x,y point\r\n\t\t\tdashPoint = {\r\n\t\t\t\tx: Math.floor((pointA.x * (1 - fraction)) + (fraction * pointB.x)),\r\n\t\t\t\ty: Math.floor((pointA.y * (1 - fraction)) + (fraction * pointB.y))\r\n\t\t\t};\r\n\r\n\t\t\t//add guide dash to guide container\r\n\t\t\tdash = L.DomUtil.create('div', 'leaflet-draw-guide-dash', this._guidesContainer);\r\n\t\t\tdash.style.backgroundColor =\r\n\t\t\t\t!this._errorShown ? this.options.shapeOptions.color : this.options.drawError.color;\r\n\r\n\t\t\tL.DomUtil.setPosition(dash, dashPoint);\r\n\t\t}\r\n\t},\r\n\r\n\t_updateGuideColor: function (color) {\r\n\t\tif (this._guidesContainer) {\r\n\t\t\tfor (var i = 0, l = this._guidesContainer.childNodes.length; i < l; i++) {\r\n\t\t\t\tthis._guidesContainer.childNodes[i].style.backgroundColor = color;\r\n\t\t\t}\r\n\t\t}\r\n\t},\r\n\r\n\t// removes all child elements (guide dashes) from the guides container\r\n\t_clearGuides: function () {\r\n\t\tif (this._guidesContainer) {\r\n\t\t\twhile (this._guidesContainer.firstChild) {\r\n\t\t\t\tthis._guidesContainer.removeChild(this._guidesContainer.firstChild);\r\n\t\t\t}\r\n\t\t}\r\n\t},\r\n\r\n\t_getTooltipText: function () {\r\n\t\tvar showLength = this.options.showLength,\r\n\t\t\tlabelText, distanceStr;\r\n\t\tif (this._markers.length === 0) {\r\n\t\t\tlabelText = {\r\n\t\t\t\ttext: L.drawLocal.draw.handlers.polyline.tooltip.start\r\n\t\t\t};\r\n\t\t} else {\r\n\t\t\tdistanceStr = showLength ? this._getMeasurementString() : '';\r\n\r\n\t\t\tif (this._markers.length === 1) {\r\n\t\t\t\tlabelText = {\r\n\t\t\t\t\ttext: L.drawLocal.draw.handlers.polyline.tooltip.cont,\r\n\t\t\t\t\tsubtext: distanceStr\r\n\t\t\t\t};\r\n\t\t\t} else {\r\n\t\t\t\tlabelText = {\r\n\t\t\t\t\ttext: L.drawLocal.draw.handlers.polyline.tooltip.end,\r\n\t\t\t\t\tsubtext: distanceStr\r\n\t\t\t\t};\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn labelText;\r\n\t},\r\n\r\n\t_updateRunningMeasure: function (latlng, added) {\r\n\t\tvar markersLength = this._markers.length,\r\n\t\t\tpreviousMarkerIndex, distance;\r\n\r\n\t\tif (this._markers.length === 1) {\r\n\t\t\tthis._measurementRunningTotal = 0;\r\n\t\t} else {\r\n\t\t\tpreviousMarkerIndex = markersLength - (added ? 2 : 1);\r\n\r\n\t\t\t// Calculate the distance based on the version\r\n\t\t\tif (L.GeometryUtil.isVersion07x()) {\r\n\t\t\t\tdistance = latlng.distanceTo(this._markers[previousMarkerIndex].getLatLng()) * (this.options.factor || 1);\r\n\t\t\t} else {\r\n\t\t\t\tdistance = this._map.distance(latlng, this._markers[previousMarkerIndex].getLatLng()) * (this.options.factor || 1);\r\n\t\t\t}\r\n\r\n\t\t\tthis._measurementRunningTotal += distance * (added ? 1 : -1);\r\n\t\t}\r\n\t},\r\n\r\n\t_getMeasurementString: function () {\r\n\t\tvar currentLatLng = this._currentLatLng,\r\n\t\t\tpreviousLatLng = this._markers[this._markers.length - 1].getLatLng(),\r\n\t\t\tdistance;\r\n\r\n\t\t// Calculate the distance from the last fixed point to the mouse position based on the version\r\n\t\tif (L.GeometryUtil.isVersion07x()) {\r\n\t\t\tdistance = previousLatLng && currentLatLng && currentLatLng.distanceTo ? this._measurementRunningTotal + currentLatLng.distanceTo(previousLatLng) * (this.options.factor || 1) : this._measurementRunningTotal || 0;\r\n\t\t} else {\r\n\t\t\tdistance = previousLatLng && currentLatLng ? this._measurementRunningTotal + this._map.distance(currentLatLng, previousLatLng) * (this.options.factor || 1) : this._measurementRunningTotal || 0;\r\n\t\t}\r\n\r\n\t\treturn L.GeometryUtil.readableDistance(distance, this.options.metric, this.options.feet, this.options.nautic, this.options.precision);\r\n\t},\r\n\r\n\t_showErrorTooltip: function () {\r\n\t\tthis._errorShown = true;\r\n\r\n\t\t// Update tooltip\r\n\t\tthis._tooltip\r\n\t\t\t.showAsError()\r\n\t\t\t.updateContent({text: this.options.drawError.message});\r\n\r\n\t\t// Update shape\r\n\t\tthis._updateGuideColor(this.options.drawError.color);\r\n\t\tthis._poly.setStyle({color: this.options.drawError.color});\r\n\r\n\t\t// Hide the error after 2 seconds\r\n\t\tthis._clearHideErrorTimeout();\r\n\t\tthis._hideErrorTimeout = setTimeout(L.Util.bind(this._hideErrorTooltip, this), this.options.drawError.timeout);\r\n\t},\r\n\r\n\t_hideErrorTooltip: function () {\r\n\t\tthis._errorShown = false;\r\n\r\n\t\tthis._clearHideErrorTimeout();\r\n\r\n\t\t// Revert tooltip\r\n\t\tthis._tooltip\r\n\t\t\t.removeError()\r\n\t\t\t.updateContent(this._getTooltipText());\r\n\r\n\t\t// Revert shape\r\n\t\tthis._updateGuideColor(this.options.shapeOptions.color);\r\n\t\tthis._poly.setStyle({color: this.options.shapeOptions.color});\r\n\t},\r\n\r\n\t_clearHideErrorTimeout: function () {\r\n\t\tif (this._hideErrorTimeout) {\r\n\t\t\tclearTimeout(this._hideErrorTimeout);\r\n\t\t\tthis._hideErrorTimeout = null;\r\n\t\t}\r\n\t},\r\n\r\n\t// disable new markers temporarily;\r\n\t// this is to prevent duplicated touch/click events in some browsers\r\n\t_disableNewMarkers: function () {\r\n\t\tthis._disableMarkers = true;\r\n\t},\r\n\r\n\t// see _disableNewMarkers\r\n\t_enableNewMarkers: function () {\r\n\t\tsetTimeout(function () {\r\n\t\t\tthis._disableMarkers = false;\r\n\t\t}.bind(this), 50);\r\n\t},\r\n\r\n\t_cleanUpShape: function () {\r\n\t\tif (this._markers.length > 1) {\r\n\t\t\tthis._markers[this._markers.length - 1].off('click', this._finishShape, this);\r\n\t\t}\r\n\t},\r\n\r\n\t_fireCreatedEvent: function () {\r\n\t\tvar poly = new this.Poly(this._poly.getLatLngs(), this.options.shapeOptions);\r\n\t\tL.Draw.Feature.prototype._fireCreatedEvent.call(this, poly);\r\n\t}\r\n});\r\n","/**\r\n * @class L.Draw.Polygon\r\n * @aka Draw.Polygon\r\n * @inherits L.Draw.Polyline\r\n */\r\nL.Draw.Polygon = L.Draw.Polyline.extend({\r\n\tstatics: {\r\n\t\tTYPE: 'polygon'\r\n\t},\r\n\r\n\tPoly: L.Polygon,\r\n\r\n\toptions: {\r\n\t\tshowArea: false,\r\n\t\tshowLength: false,\r\n\t\tshapeOptions: {\r\n\t\t\tstroke: true,\r\n\t\t\tcolor: '#3388ff',\r\n\t\t\tweight: 4,\r\n\t\t\topacity: 0.5,\r\n\t\t\tfill: true,\r\n\t\t\tfillColor: null, //same as color by default\r\n\t\t\tfillOpacity: 0.2,\r\n\t\t\tclickable: true\r\n\t\t},\r\n\t\t// Whether to use the metric measurement system (truthy) or not (falsy).\r\n\t\t// Also defines the units to use for the metric system as an array of\r\n\t\t// strings (e.g. `['ha', 'm']`).\r\n\t\tmetric: true,\r\n\t\tfeet: true, // When not metric, to use feet instead of yards for display.\r\n\t\tnautic: false, // When not metric, not feet use nautic mile for display\r\n\t\t// Defines the precision for each type of unit (e.g. {km: 2, ft: 0}\r\n\t\tprecision: {}\r\n\t},\r\n\r\n\t// @method initialize(): void\r\n\tinitialize: function (map, options) {\r\n\t\tL.Draw.Polyline.prototype.initialize.call(this, map, options);\r\n\r\n\t\t// Save the type so super can fire, need to do this as cannot do this.TYPE :(\r\n\t\tthis.type = L.Draw.Polygon.TYPE;\r\n\t},\r\n\r\n\t_updateFinishHandler: function () {\r\n\t\tvar markerCount = this._markers.length;\r\n\r\n\t\t// The first marker should have a click handler to close the polygon\r\n\t\tif (markerCount === 1) {\r\n\t\t\tthis._markers[0].on('click', this._finishShape, this);\r\n\t\t}\r\n\r\n\t\t// Add and update the double click handler\r\n\t\tif (markerCount > 2) {\r\n\t\t\tthis._markers[markerCount - 1].on('dblclick', this._finishShape, this);\r\n\t\t\t// Only need to remove handler if has been added before\r\n\t\t\tif (markerCount > 3) {\r\n\t\t\t\tthis._markers[markerCount - 2].off('dblclick', this._finishShape, this);\r\n\t\t\t}\r\n\t\t}\r\n\t},\r\n\r\n\t_getTooltipText: function () {\r\n\t\tvar text, subtext;\r\n\r\n\t\tif (this._markers.length === 0) {\r\n\t\t\ttext = L.drawLocal.draw.handlers.polygon.tooltip.start;\r\n\t\t} else if (this._markers.length < 3) {\r\n\t\t\ttext = L.drawLocal.draw.handlers.polygon.tooltip.cont;\r\n\t\t\tsubtext = this._getMeasurementString();\r\n\t\t} else {\r\n\t\t\ttext = L.drawLocal.draw.handlers.polygon.tooltip.end;\r\n\t\t\tsubtext = this._getMeasurementString();\r\n\t\t}\r\n\r\n\t\treturn {\r\n\t\t\ttext: text,\r\n\t\t\tsubtext: subtext\r\n\t\t};\r\n\t},\r\n\r\n\t_getMeasurementString: function () {\r\n\t\tvar area = this._area,\r\n\t\t\tmeasurementString = '';\r\n\r\n\r\n\t\tif (!area && !this.options.showLength) {\r\n\t\t\treturn null;\r\n\t\t}\r\n\r\n\t\tif (this.options.showLength) {\r\n\t\t\tmeasurementString = L.Draw.Polyline.prototype._getMeasurementString.call(this);\r\n\t\t}\r\n\r\n\t\tif (area) {\r\n\t\t\tmeasurementString += '
' + L.GeometryUtil.readableArea(area, this.options.metric, this.options.precision);\r\n\t\t}\r\n\r\n\t\treturn measurementString;\r\n\t},\r\n\r\n\t_shapeIsValid: function () {\r\n\t\treturn this._markers.length >= 3;\r\n\t},\r\n\r\n\t_vertexChanged: function (latlng, added) {\r\n\t\tvar latLngs;\r\n\r\n\t\t// Check to see if we should show the area\r\n\t\tif (!this.options.allowIntersection && this.options.showArea) {\r\n\t\t\tlatLngs = this._poly.getLatLngs();\r\n\r\n\t\t\tthis._area = L.GeometryUtil.geodesicArea(latLngs);\r\n\t\t}\r\n\r\n\t\tL.Draw.Polyline.prototype._vertexChanged.call(this, latlng, added);\r\n\t},\r\n\r\n\t_cleanUpShape: function () {\r\n\t\tvar markerCount = this._markers.length;\r\n\r\n\t\tif (markerCount > 0) {\r\n\t\t\tthis._markers[0].off('click', this._finishShape, this);\r\n\r\n\t\t\tif (markerCount > 2) {\r\n\t\t\t\tthis._markers[markerCount - 1].off('dblclick', this._finishShape, this);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n});\r\n","L.SimpleShape = {};\r\n/**\r\n * @class L.Draw.SimpleShape\r\n * @aka Draw.SimpleShape\r\n * @inherits L.Draw.Feature\r\n */\r\nL.Draw.SimpleShape = L.Draw.Feature.extend({\r\n\toptions: {\r\n\t\trepeatMode: false\r\n\t},\r\n\r\n\t// @method initialize(): void\r\n\tinitialize: function (map, options) {\r\n\t\tthis._endLabelText = L.drawLocal.draw.handlers.simpleshape.tooltip.end;\r\n\r\n\t\tL.Draw.Feature.prototype.initialize.call(this, map, options);\r\n\t},\r\n\r\n\t// @method addHooks(): void\r\n\t// Add listener hooks to this handler.\r\n\taddHooks: function () {\r\n\t\tL.Draw.Feature.prototype.addHooks.call(this);\r\n\t\tif (this._map) {\r\n\t\t\tthis._mapDraggable = this._map.dragging.enabled();\r\n\r\n\t\t\tif (this._mapDraggable) {\r\n\t\t\t\tthis._map.dragging.disable();\r\n\t\t\t}\r\n\r\n\t\t\t//TODO refactor: move cursor to styles\r\n\t\t\tthis._container.style.cursor = 'crosshair';\r\n\r\n\t\t\tthis._tooltip.updateContent({text: this._initialLabelText});\r\n\r\n\t\t\tthis._map\r\n\t\t\t\t.on('mousedown', this._onMouseDown, this)\r\n\t\t\t\t.on('mousemove', this._onMouseMove, this)\r\n\t\t\t\t.on('touchstart', this._onMouseDown, this)\r\n\t\t\t\t.on('touchmove', this._onMouseMove, this);\r\n\r\n\t\t\t// we should prevent default, otherwise default behavior (scrolling) will fire,\r\n\t\t\t// and that will cause document.touchend to fire and will stop the drawing\r\n\t\t\t// (circle, rectangle) in touch mode.\r\n\t\t\t// (update): we have to send passive now to prevent scroll, because by default it is {passive: true} now, which means,\r\n\t\t\t// handler can't event.preventDefault\r\n\t\t\t// check the news https://developers.google.com/web/updates/2016/06/passive-event-listeners\r\n\t\t\tdocument.addEventListener('touchstart', L.DomEvent.preventDefault, {passive: false});\r\n\t\t}\r\n\t},\r\n\r\n\t// @method removeHooks(): void\r\n\t// Remove listener hooks from this handler.\r\n\tremoveHooks: function () {\r\n\t\tL.Draw.Feature.prototype.removeHooks.call(this);\r\n\t\tif (this._map) {\r\n\t\t\tif (this._mapDraggable) {\r\n\t\t\t\tthis._map.dragging.enable();\r\n\t\t\t}\r\n\r\n\t\t\t//TODO refactor: move cursor to styles\r\n\t\t\tthis._container.style.cursor = '';\r\n\r\n\t\t\tthis._map\r\n\t\t\t\t.off('mousedown', this._onMouseDown, this)\r\n\t\t\t\t.off('mousemove', this._onMouseMove, this)\r\n\t\t\t\t.off('touchstart', this._onMouseDown, this)\r\n\t\t\t\t.off('touchmove', this._onMouseMove, this);\r\n\r\n\t\t\tL.DomEvent.off(document, 'mouseup', this._onMouseUp, this);\r\n\t\t\tL.DomEvent.off(document, 'touchend', this._onMouseUp, this);\r\n\r\n\t\t\tdocument.removeEventListener('touchstart', L.DomEvent.preventDefault);\r\n\r\n\t\t\t// If the box element doesn't exist they must not have moved the mouse, so don't need to destroy/return\r\n\t\t\tif (this._shape) {\r\n\t\t\t\tthis._map.removeLayer(this._shape);\r\n\t\t\t\tdelete this._shape;\r\n\t\t\t}\r\n\t\t}\r\n\t\tthis._isDrawing = false;\r\n\t},\r\n\r\n\t_getTooltipText: function () {\r\n\t\treturn {\r\n\t\t\ttext: this._endLabelText\r\n\t\t};\r\n\t},\r\n\r\n\t_onMouseDown: function (e) {\r\n\t\tthis._isDrawing = true;\r\n\t\tthis._startLatLng = e.latlng;\r\n\r\n\t\tL.DomEvent\r\n\t\t\t.on(document, 'mouseup', this._onMouseUp, this)\r\n\t\t\t.on(document, 'touchend', this._onMouseUp, this)\r\n\t\t\t.preventDefault(e.originalEvent);\r\n\t},\r\n\r\n\t_onMouseMove: function (e) {\r\n\t\tvar latlng = e.latlng;\r\n\r\n\t\tthis._tooltip.updatePosition(latlng);\r\n\t\tif (this._isDrawing) {\r\n\t\t\tthis._tooltip.updateContent(this._getTooltipText());\r\n\t\t\tthis._drawShape(latlng);\r\n\t\t}\r\n\t},\r\n\r\n\t_onMouseUp: function () {\r\n\t\tif (this._shape) {\r\n\t\t\tthis._fireCreatedEvent();\r\n\t\t}\r\n\r\n\t\tthis.disable();\r\n\t\tif (this.options.repeatMode) {\r\n\t\t\tthis.enable();\r\n\t\t}\r\n\t}\r\n});\r\n","/**\r\n * @class L.Draw.Rectangle\r\n * @aka Draw.Rectangle\r\n * @inherits L.Draw.SimpleShape\r\n */\r\nL.Draw.Rectangle = L.Draw.SimpleShape.extend({\r\n\tstatics: {\r\n\t\tTYPE: 'rectangle'\r\n\t},\r\n\r\n\toptions: {\r\n\t\tshapeOptions: {\r\n\t\t\tstroke: true,\r\n\t\t\tcolor: '#3388ff',\r\n\t\t\tweight: 4,\r\n\t\t\topacity: 0.5,\r\n\t\t\tfill: true,\r\n\t\t\tfillColor: null, //same as color by default\r\n\t\t\tfillOpacity: 0.2,\r\n\t\t\tclickable: true\r\n\t\t},\r\n\t\tshowArea: true, //Whether to show the area in the tooltip\r\n\t\tmetric: true // Whether to use the metric measurement system or imperial\r\n\t},\r\n\r\n\t// @method initialize(): void\r\n\tinitialize: function (map, options) {\r\n\t\t// Save the type so super can fire, need to do this as cannot do this.TYPE :(\r\n\t\tthis.type = L.Draw.Rectangle.TYPE;\r\n\r\n\t\tthis._initialLabelText = L.drawLocal.draw.handlers.rectangle.tooltip.start;\r\n\r\n\t\tL.Draw.SimpleShape.prototype.initialize.call(this, map, options);\r\n\t},\r\n\r\n\t// @method disable(): void\r\n\tdisable: function () {\r\n\t\tif (!this._enabled) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tthis._isCurrentlyTwoClickDrawing = false;\r\n\t\tL.Draw.SimpleShape.prototype.disable.call(this);\r\n\t},\r\n\r\n\t_onMouseUp: function (e) {\r\n\t\tif (!this._shape && !this._isCurrentlyTwoClickDrawing) {\r\n\t\t\tthis._isCurrentlyTwoClickDrawing = true;\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\t// Make sure closing click is on map\r\n\t\tif (this._isCurrentlyTwoClickDrawing && !_hasAncestor(e.target, 'leaflet-pane')) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tL.Draw.SimpleShape.prototype._onMouseUp.call(this);\r\n\t},\r\n\r\n\t_drawShape: function (latlng) {\r\n\t\tif (!this._shape) {\r\n\t\t\tthis._shape = new L.Rectangle(new L.LatLngBounds(this._startLatLng, latlng), this.options.shapeOptions);\r\n\t\t\tthis._map.addLayer(this._shape);\r\n\t\t} else {\r\n\t\t\tthis._shape.setBounds(new L.LatLngBounds(this._startLatLng, latlng));\r\n\t\t}\r\n\t},\r\n\r\n\t_fireCreatedEvent: function () {\r\n\t\tvar rectangle = new L.Rectangle(this._shape.getBounds(), this.options.shapeOptions);\r\n\t\tL.Draw.SimpleShape.prototype._fireCreatedEvent.call(this, rectangle);\r\n\t},\r\n\r\n\t_getTooltipText: function () {\r\n\t\tvar tooltipText = L.Draw.SimpleShape.prototype._getTooltipText.call(this),\r\n\t\t\tshape = this._shape,\r\n\t\t\tshowArea = this.options.showArea,\r\n\t\t\tlatLngs, area, subtext;\r\n\r\n\t\tif (shape) {\r\n\t\t\tlatLngs = this._shape._defaultShape ? this._shape._defaultShape() : this._shape.getLatLngs();\r\n\t\t\tarea = L.GeometryUtil.geodesicArea(latLngs);\r\n\t\t\tsubtext = showArea ? L.GeometryUtil.readableArea(area, this.options.metric) : '';\r\n\t\t}\r\n\r\n\t\treturn {\r\n\t\t\ttext: tooltipText.text,\r\n\t\t\tsubtext: subtext\r\n\t\t};\r\n\t}\r\n});\r\n\r\nfunction _hasAncestor(el, cls) {\r\n\twhile ((el = el.parentElement) && !el.classList.contains(cls)) {\r\n\t\t;\r\n\t}\r\n\treturn el;\r\n}\r\n","/**\r\n * @class L.Draw.Marker\r\n * @aka Draw.Marker\r\n * @inherits L.Draw.Feature\r\n */\r\nL.Draw.Marker = L.Draw.Feature.extend({\r\n\tstatics: {\r\n\t\tTYPE: 'marker'\r\n\t},\r\n\r\n\toptions: {\r\n\t\ticon: new L.Icon.Default(),\r\n\t\trepeatMode: false,\r\n\t\tzIndexOffset: 2000 // This should be > than the highest z-index any markers\r\n\t},\r\n\r\n\t// @method initialize(): void\r\n\tinitialize: function (map, options) {\r\n\t\t// Save the type so super can fire, need to do this as cannot do this.TYPE :(\r\n\t\tthis.type = L.Draw.Marker.TYPE;\r\n\r\n\t\tthis._initialLabelText = L.drawLocal.draw.handlers.marker.tooltip.start;\r\n\r\n\t\tL.Draw.Feature.prototype.initialize.call(this, map, options);\r\n\t},\r\n\r\n\t// @method addHooks(): void\r\n\t// Add listener hooks to this handler.\r\n\taddHooks: function () {\r\n\t\tL.Draw.Feature.prototype.addHooks.call(this);\r\n\r\n\t\tif (this._map) {\r\n\t\t\tthis._tooltip.updateContent({text: this._initialLabelText});\r\n\r\n\t\t\t// Same mouseMarker as in Draw.Polyline\r\n\t\t\tif (!this._mouseMarker) {\r\n\t\t\t\tthis._mouseMarker = L.marker(this._map.getCenter(), {\r\n\t\t\t\t\ticon: L.divIcon({\r\n\t\t\t\t\t\tclassName: 'leaflet-mouse-marker',\r\n\t\t\t\t\t\ticonAnchor: [20, 20],\r\n\t\t\t\t\t\ticonSize: [40, 40]\r\n\t\t\t\t\t}),\r\n\t\t\t\t\topacity: 0,\r\n\t\t\t\t\tzIndexOffset: this.options.zIndexOffset\r\n\t\t\t\t});\r\n\t\t\t}\r\n\r\n\t\t\tthis._mouseMarker\r\n\t\t\t\t.on('click', this._onClick, this)\r\n\t\t\t\t.addTo(this._map);\r\n\r\n\t\t\tthis._map.on('mousemove', this._onMouseMove, this);\r\n\t\t\tthis._map.on('click', this._onTouch, this);\r\n\t\t}\r\n\t},\r\n\r\n\t// @method removeHooks(): void\r\n\t// Remove listener hooks from this handler.\r\n\tremoveHooks: function () {\r\n\t\tL.Draw.Feature.prototype.removeHooks.call(this);\r\n\r\n\t\tif (this._map) {\r\n\t\t\tthis._map\r\n\t\t\t\t.off('click', this._onClick, this)\r\n\t\t\t\t.off('click', this._onTouch, this);\r\n\t\t\tif (this._marker) {\r\n\t\t\t\tthis._marker.off('click', this._onClick, this);\r\n\t\t\t\tthis._map\r\n\t\t\t\t\t.removeLayer(this._marker);\r\n\t\t\t\tdelete this._marker;\r\n\t\t\t}\r\n\r\n\t\t\tthis._mouseMarker.off('click', this._onClick, this);\r\n\t\t\tthis._map.removeLayer(this._mouseMarker);\r\n\t\t\tdelete this._mouseMarker;\r\n\r\n\t\t\tthis._map.off('mousemove', this._onMouseMove, this);\r\n\t\t}\r\n\t},\r\n\r\n\t_onMouseMove: function (e) {\r\n\t\tvar latlng = e.latlng;\r\n\r\n\t\tthis._tooltip.updatePosition(latlng);\r\n\t\tthis._mouseMarker.setLatLng(latlng);\r\n\r\n\t\tif (!this._marker) {\r\n\t\t\tthis._marker = this._createMarker(latlng);\r\n\t\t\t// Bind to both marker and map to make sure we get the click event.\r\n\t\t\tthis._marker.on('click', this._onClick, this);\r\n\t\t\tthis._map\r\n\t\t\t\t.on('click', this._onClick, this)\r\n\t\t\t\t.addLayer(this._marker);\r\n\t\t}\r\n\t\telse {\r\n\t\t\tlatlng = this._mouseMarker.getLatLng();\r\n\t\t\tthis._marker.setLatLng(latlng);\r\n\t\t}\r\n\t},\r\n\r\n\t_createMarker: function (latlng) {\r\n\t\treturn new L.Marker(latlng, {\r\n\t\t\ticon: this.options.icon,\r\n\t\t\tzIndexOffset: this.options.zIndexOffset\r\n\t\t});\r\n\t},\r\n\r\n\t_onClick: function () {\r\n\t\tthis._fireCreatedEvent();\r\n\r\n\t\tthis.disable();\r\n\t\tif (this.options.repeatMode) {\r\n\t\t\tthis.enable();\r\n\t\t}\r\n\t},\r\n\r\n\t_onTouch: function (e) {\r\n\t\t// called on click & tap, only really does any thing on tap\r\n\t\tthis._onMouseMove(e); // creates & places marker\r\n\t\tthis._onClick(); // permanently places marker & ends interaction\r\n\t},\r\n\r\n\t_fireCreatedEvent: function () {\r\n\t\tvar marker = new L.Marker.Touch(this._marker.getLatLng(), {icon: this.options.icon});\r\n\t\tL.Draw.Feature.prototype._fireCreatedEvent.call(this, marker);\r\n\t}\r\n});\r\n","/**\r\n * @class L.Draw.CircleMarker\r\n * @aka Draw.CircleMarker\r\n * @inherits L.Draw.Marker\r\n */\r\nL.Draw.CircleMarker = L.Draw.Marker.extend({\r\n\tstatics: {\r\n\t\tTYPE: 'circlemarker'\r\n\t},\r\n\r\n\toptions: {\r\n\t\tstroke: true,\r\n\t\tcolor: '#3388ff',\r\n\t\tweight: 4,\r\n\t\topacity: 0.5,\r\n\t\tfill: true,\r\n\t\tfillColor: null, //same as color by default\r\n\t\tfillOpacity: 0.2,\r\n\t\tclickable: true,\r\n\t\tzIndexOffset: 2000 // This should be > than the highest z-index any markers\r\n\t},\r\n\r\n\t// @method initialize(): void\r\n\tinitialize: function (map, options) {\r\n\t\t// Save the type so super can fire, need to do this as cannot do this.TYPE :(\r\n\t\tthis.type = L.Draw.CircleMarker.TYPE;\r\n\r\n\t\tthis._initialLabelText = L.drawLocal.draw.handlers.circlemarker.tooltip.start;\r\n\r\n\t\tL.Draw.Feature.prototype.initialize.call(this, map, options);\r\n\t},\r\n\r\n\r\n\t_fireCreatedEvent: function () {\r\n\t\tvar circleMarker = new L.CircleMarker(this._marker.getLatLng(), this.options);\r\n\t\tL.Draw.Feature.prototype._fireCreatedEvent.call(this, circleMarker);\r\n\t},\r\n\r\n\t_createMarker: function (latlng) {\r\n\t\treturn new L.CircleMarker(latlng, this.options);\r\n\t}\r\n});\r\n","/**\r\n * @class L.Draw.Circle\r\n * @aka Draw.Circle\r\n * @inherits L.Draw.SimpleShape\r\n */\r\nL.Draw.Circle = L.Draw.SimpleShape.extend({\r\n\tstatics: {\r\n\t\tTYPE: 'circle'\r\n\t},\r\n\r\n\toptions: {\r\n\t\tshapeOptions: {\r\n\t\t\tstroke: true,\r\n\t\t\tcolor: '#3388ff',\r\n\t\t\tweight: 4,\r\n\t\t\topacity: 0.5,\r\n\t\t\tfill: true,\r\n\t\t\tfillColor: null, //same as color by default\r\n\t\t\tfillOpacity: 0.2,\r\n\t\t\tclickable: true\r\n\t\t},\r\n\t\tshowRadius: true,\r\n\t\tmetric: true, // Whether to use the metric measurement system or imperial\r\n\t\tfeet: true, // When not metric, use feet instead of yards for display\r\n\t\tnautic: false // When not metric, not feet use nautic mile for display\r\n\t},\r\n\r\n\t// @method initialize(): void\r\n\tinitialize: function (map, options) {\r\n\t\t// Save the type so super can fire, need to do this as cannot do this.TYPE :(\r\n\t\tthis.type = L.Draw.Circle.TYPE;\r\n\r\n\t\tthis._initialLabelText = L.drawLocal.draw.handlers.circle.tooltip.start;\r\n\r\n\t\tL.Draw.SimpleShape.prototype.initialize.call(this, map, options);\r\n\t},\r\n\r\n\t_drawShape: function (latlng) {\r\n\t\t// Calculate the distance based on the version\r\n\t\tif (L.GeometryUtil.isVersion07x()) {\r\n\t\t\tvar distance = this._startLatLng.distanceTo(latlng);\r\n\t\t} else {\r\n\t\t\tvar distance = this._map.distance(this._startLatLng, latlng);\r\n\t\t}\r\n\r\n\t\tif (!this._shape) {\r\n\t\t\tthis._shape = new L.Circle(this._startLatLng, distance, this.options.shapeOptions);\r\n\t\t\tthis._map.addLayer(this._shape);\r\n\t\t} else {\r\n\t\t\tthis._shape.setRadius(distance);\r\n\t\t}\r\n\t},\r\n\r\n\t_fireCreatedEvent: function () {\r\n\t\tvar circle = new L.Circle(this._startLatLng, this._shape.getRadius(), this.options.shapeOptions);\r\n\t\tL.Draw.SimpleShape.prototype._fireCreatedEvent.call(this, circle);\r\n\t},\r\n\r\n\t_onMouseMove: function (e) {\r\n\t\tvar latlng = e.latlng,\r\n\t\t\tshowRadius = this.options.showRadius,\r\n\t\t\tuseMetric = this.options.metric,\r\n\t\t\tradius;\r\n\r\n\t\tthis._tooltip.updatePosition(latlng);\r\n\t\tif (this._isDrawing) {\r\n\t\t\tthis._drawShape(latlng);\r\n\r\n\t\t\t// Get the new radius (rounded to 1 dp)\r\n\t\t\tradius = this._shape.getRadius().toFixed(1);\r\n\r\n\t\t\tvar subtext = '';\r\n\t\t\tif (showRadius) {\r\n\t\t\t\tsubtext = L.drawLocal.draw.handlers.circle.radius + ': ' +\r\n\t\t\t\t\tL.GeometryUtil.readableDistance(radius, useMetric, this.options.feet, this.options.nautic);\r\n\t\t\t}\r\n\t\t\tthis._tooltip.updateContent({\r\n\t\t\t\ttext: this._endLabelText,\r\n\t\t\t\tsubtext: subtext\r\n\t\t\t});\r\n\t\t}\r\n\t}\r\n});\r\n","L.Edit = L.Edit || {};\r\n\r\n/**\r\n * @class L.Edit.Marker\r\n * @aka Edit.Marker\r\n */\r\nL.Edit.Marker = L.Handler.extend({\r\n\t// @method initialize(): void\r\n\tinitialize: function (marker, options) {\r\n\t\tthis._marker = marker;\r\n\t\tL.setOptions(this, options);\r\n\t},\r\n\r\n\t// @method addHooks(): void\r\n\t// Add listener hooks to this handler\r\n\taddHooks: function () {\r\n\t\tvar marker = this._marker;\r\n\r\n\t\tmarker.dragging.enable();\r\n\t\tmarker.on('dragend', this._onDragEnd, marker);\r\n\t\tthis._toggleMarkerHighlight();\r\n\t},\r\n\r\n\t// @method removeHooks(): void\r\n\t// Remove listener hooks from this handler\r\n\tremoveHooks: function () {\r\n\t\tvar marker = this._marker;\r\n\r\n\t\tmarker.dragging.disable();\r\n\t\tmarker.off('dragend', this._onDragEnd, marker);\r\n\t\tthis._toggleMarkerHighlight();\r\n\t},\r\n\r\n\t_onDragEnd: function (e) {\r\n\t\tvar layer = e.target;\r\n\t\tlayer.edited = true;\r\n\t\tthis._map.fire(L.Draw.Event.EDITMOVE, {layer: layer});\r\n\t},\r\n\r\n\t_toggleMarkerHighlight: function () {\r\n\t\tvar icon = this._marker._icon;\r\n\r\n\t\t// Don't do anything if this layer is a marker but doesn't have an icon. Markers\r\n\t\t// should usually have icons. If using Leaflet.draw with Leaflet.markercluster there\r\n\t\t// is a chance that a marker doesn't.\r\n\t\tif (!icon) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\t// This is quite naughty, but I don't see another way of doing it. (short of setting a new icon)\r\n\t\ticon.style.display = 'none';\r\n\r\n\t\tif (L.DomUtil.hasClass(icon, 'leaflet-edit-marker-selected')) {\r\n\t\t\tL.DomUtil.removeClass(icon, 'leaflet-edit-marker-selected');\r\n\t\t\t// Offset as the border will make the icon move.\r\n\t\t\tthis._offsetMarker(icon, -4);\r\n\r\n\t\t} else {\r\n\t\t\tL.DomUtil.addClass(icon, 'leaflet-edit-marker-selected');\r\n\t\t\t// Offset as the border will make the icon move.\r\n\t\t\tthis._offsetMarker(icon, 4);\r\n\t\t}\r\n\r\n\t\ticon.style.display = '';\r\n\t},\r\n\r\n\t_offsetMarker: function (icon, offset) {\r\n\t\tvar iconMarginTop = parseInt(icon.style.marginTop, 10) - offset,\r\n\t\t\ticonMarginLeft = parseInt(icon.style.marginLeft, 10) - offset;\r\n\r\n\t\ticon.style.marginTop = iconMarginTop + 'px';\r\n\t\ticon.style.marginLeft = iconMarginLeft + 'px';\r\n\t}\r\n});\r\n\r\nL.Marker.addInitHook(function () {\r\n\tif (L.Edit.Marker) {\r\n\t\tthis.editing = new L.Edit.Marker(this);\r\n\r\n\t\tif (this.options.editable) {\r\n\t\t\tthis.editing.enable();\r\n\t\t}\r\n\t}\r\n});\r\n","L.Edit = L.Edit || {};\r\n\r\n/**\r\n * @class L.Edit.Polyline\r\n * @aka L.Edit.Poly\r\n * @aka Edit.Poly\r\n */\r\nL.Edit.Poly = L.Handler.extend({\r\n\t// @method initialize(): void\r\n\tinitialize: function (poly) {\r\n\r\n\t\tthis.latlngs = [poly._latlngs];\r\n\t\tif (poly._holes) {\r\n\t\t\tthis.latlngs = this.latlngs.concat(poly._holes);\r\n\t\t}\r\n\r\n\t\tthis._poly = poly;\r\n\r\n\t\tthis._poly.on('revert-edited', this._updateLatLngs, this);\r\n\t},\r\n\r\n\t// Compatibility method to normalize Poly* objects\r\n\t// between 0.7.x and 1.0+\r\n\t_defaultShape: function () {\r\n\t\tif (!L.Polyline._flat) {\r\n\t\t\treturn this._poly._latlngs;\r\n\t\t}\r\n\t\treturn L.Polyline._flat(this._poly._latlngs) ? this._poly._latlngs : this._poly._latlngs[0];\r\n\t},\r\n\r\n\t_eachVertexHandler: function (callback) {\r\n\t\tfor (var i = 0; i < this._verticesHandlers.length; i++) {\r\n\t\t\tcallback(this._verticesHandlers[i]);\r\n\t\t}\r\n\t},\r\n\r\n\t// @method addHooks(): void\r\n\t// Add listener hooks to this handler\r\n\taddHooks: function () {\r\n\t\tthis._initHandlers();\r\n\t\tthis._eachVertexHandler(function (handler) {\r\n\t\t\thandler.addHooks();\r\n\t\t});\r\n\t},\r\n\r\n\t// @method removeHooks(): void\r\n\t// Remove listener hooks from this handler\r\n\tremoveHooks: function () {\r\n\t\tthis._eachVertexHandler(function (handler) {\r\n\t\t\thandler.removeHooks();\r\n\t\t});\r\n\t},\r\n\r\n\t// @method updateMarkers(): void\r\n\t// Fire an update for each vertex handler\r\n\tupdateMarkers: function () {\r\n\t\tthis._eachVertexHandler(function (handler) {\r\n\t\t\thandler.updateMarkers();\r\n\t\t});\r\n\t},\r\n\r\n\t_initHandlers: function () {\r\n\t\tthis._verticesHandlers = [];\r\n\t\tfor (var i = 0; i < this.latlngs.length; i++) {\r\n\t\t\tthis._verticesHandlers.push(new L.Edit.PolyVerticesEdit(this._poly, this.latlngs[i], this._poly.options.poly));\r\n\t\t}\r\n\t},\r\n\r\n\t_updateLatLngs: function (e) {\r\n\t\tthis.latlngs = [e.layer._latlngs];\r\n\t\tif (e.layer._holes) {\r\n\t\t\tthis.latlngs = this.latlngs.concat(e.layer._holes);\r\n\t\t}\r\n\t}\r\n\r\n});\r\n\r\n/**\r\n * @class L.Edit.PolyVerticesEdit\r\n * @aka Edit.PolyVerticesEdit\r\n */\r\nL.Edit.PolyVerticesEdit = L.Handler.extend({\r\n\toptions: {\r\n\t\ticon: new L.DivIcon({\r\n\t\t\ticonSize: new L.Point(8, 8),\r\n\t\t\tclassName: 'leaflet-div-icon leaflet-editing-icon'\r\n\t\t}),\r\n\t\ttouchIcon: new L.DivIcon({\r\n\t\t\ticonSize: new L.Point(20, 20),\r\n\t\t\tclassName: 'leaflet-div-icon leaflet-editing-icon leaflet-touch-icon'\r\n\t\t}),\r\n\t\tdrawError: {\r\n\t\t\tcolor: '#b00b00',\r\n\t\t\ttimeout: 1000\r\n\t\t}\r\n\r\n\r\n\t},\r\n\r\n\t// @method intialize(): void\r\n\tinitialize: function (poly, latlngs, options) {\r\n\t\t// if touch, switch to touch icon\r\n\t\tif (L.Browser.touch) {\r\n\t\t\tthis.options.icon = this.options.touchIcon;\r\n\t\t}\r\n\t\tthis._poly = poly;\r\n\r\n\t\tif (options && options.drawError) {\r\n\t\t\toptions.drawError = L.Util.extend({}, this.options.drawError, options.drawError);\r\n\t\t}\r\n\r\n\t\tthis._latlngs = latlngs;\r\n\r\n\t\tL.setOptions(this, options);\r\n\t},\r\n\r\n\t// Compatibility method to normalize Poly* objects\r\n\t// between 0.7.x and 1.0+\r\n\t_defaultShape: function () {\r\n\t\tif (!L.Polyline._flat) {\r\n\t\t\treturn this._latlngs;\r\n\t\t}\r\n\t\treturn L.Polyline._flat(this._latlngs) ? this._latlngs : this._latlngs[0];\r\n\t},\r\n\r\n\t// @method addHooks(): void\r\n\t// Add listener hooks to this handler.\r\n\taddHooks: function () {\r\n\t\tvar poly = this._poly;\r\n\t\tvar path = poly._path;\r\n\r\n\t\tif (!(poly instanceof L.Polygon)) {\r\n\t\t\tpoly.options.fill = false;\r\n\t\t\tif (poly.options.editing) {\r\n\t\t\t\tpoly.options.editing.fill = false;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (path) {\r\n\t\t\tif (poly.options.editing && poly.options.editing.className) {\r\n\t\t\t\tif (poly.options.original.className) {\r\n\t\t\t\t\tpoly.options.original.className.split(' ').forEach(function (className) {\r\n\t\t\t\t\t\tL.DomUtil.removeClass(path, className);\r\n\t\t\t\t\t});\r\n\t\t\t\t}\r\n\t\t\t\tpoly.options.editing.className.split(' ').forEach(function (className) {\r\n\t\t\t\t\tL.DomUtil.addClass(path, className);\r\n\t\t\t\t});\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tpoly.setStyle(poly.options.editing);\r\n\r\n\t\tif (this._poly._map) {\r\n\r\n\t\t\tthis._map = this._poly._map; // Set map\r\n\r\n\t\t\tif (!this._markerGroup) {\r\n\t\t\t\tthis._initMarkers();\r\n\t\t\t}\r\n\t\t\tthis._poly._map.addLayer(this._markerGroup);\r\n\t\t}\r\n\t},\r\n\r\n\t// @method removeHooks(): void\r\n\t// Remove listener hooks from this handler.\r\n\tremoveHooks: function () {\r\n\t\tvar poly = this._poly;\r\n\t\tvar path = poly._path;\r\n\r\n\t\tif (path) {\r\n\t\t\tif (poly.options.editing && poly.options.editing.className) {\r\n\t\t\t\tpoly.options.editing.className.split(' ').forEach(function (className) {\r\n\t\t\t\t\tL.DomUtil.removeClass(path, className);\r\n\t\t\t\t});\r\n\t\t\t\tif (poly.options.original.className) {\r\n\t\t\t\t\tpoly.options.original.className.split(' ').forEach(function (className) {\r\n\t\t\t\t\t\tL.DomUtil.addClass(path, className);\r\n\t\t\t\t\t});\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tpoly.setStyle(poly.options.original);\r\n\r\n\t\tif (poly._map) {\r\n\t\t\tpoly._map.removeLayer(this._markerGroup);\r\n\t\t\tdelete this._markerGroup;\r\n\t\t\tdelete this._markers;\r\n\t\t}\r\n\t},\r\n\r\n\t// @method updateMarkers(): void\r\n\t// Clear markers and update their location\r\n\tupdateMarkers: function () {\r\n\t\tthis._markerGroup.clearLayers();\r\n\t\tthis._initMarkers();\r\n\t},\r\n\r\n\t_initMarkers: function () {\r\n\t\tif (!this._markerGroup) {\r\n\t\t\tthis._markerGroup = new L.LayerGroup();\r\n\t\t}\r\n\t\tthis._markers = [];\r\n\r\n\t\tvar latlngs = this._defaultShape(),\r\n\t\t\ti, j, len, marker;\r\n\r\n\t\tfor (i = 0, len = latlngs.length; i < len; i++) {\r\n\r\n\t\t\tmarker = this._createMarker(latlngs[i], i);\r\n\t\t\tmarker.on('click', this._onMarkerClick, this);\r\n\t\t\tmarker.on('contextmenu', this._onContextMenu, this);\r\n\t\t\tthis._markers.push(marker);\r\n\t\t}\r\n\r\n\t\tvar markerLeft, markerRight;\r\n\r\n\t\tfor (i = 0, j = len - 1; i < len; j = i++) {\r\n\t\t\tif (i === 0 && !(L.Polygon && (this._poly instanceof L.Polygon))) {\r\n\t\t\t\tcontinue;\r\n\t\t\t}\r\n\r\n\t\t\tmarkerLeft = this._markers[j];\r\n\t\t\tmarkerRight = this._markers[i];\r\n\r\n\t\t\tthis._createMiddleMarker(markerLeft, markerRight);\r\n\t\t\tthis._updatePrevNext(markerLeft, markerRight);\r\n\t\t}\r\n\t},\r\n\r\n\t_createMarker: function (latlng, index) {\r\n\t\t// Extending L.Marker in TouchEvents.js to include touch.\r\n\t\tvar marker = new L.Marker.Touch(latlng, {\r\n\t\t\tdraggable: true,\r\n\t\t\ticon: this.options.icon,\r\n\t\t});\r\n\r\n\t\tmarker._origLatLng = latlng;\r\n\t\tmarker._index = index;\r\n\r\n\t\tmarker\r\n\t\t\t.on('dragstart', this._onMarkerDragStart, this)\r\n\t\t\t.on('drag', this._onMarkerDrag, this)\r\n\t\t\t.on('dragend', this._fireEdit, this)\r\n\t\t\t.on('touchmove', this._onTouchMove, this)\r\n\t\t\t.on('touchend', this._fireEdit, this)\r\n\t\t\t.on('MSPointerMove', this._onTouchMove, this)\r\n\t\t\t.on('MSPointerUp', this._fireEdit, this);\r\n\r\n\t\tthis._markerGroup.addLayer(marker);\r\n\r\n\t\treturn marker;\r\n\t},\r\n\r\n\t_onMarkerDragStart: function () {\r\n\t\tthis._poly.fire('editstart');\r\n\t},\r\n\r\n\t_spliceLatLngs: function () {\r\n\t\tvar latlngs = this._defaultShape();\r\n\t\tvar removed = [].splice.apply(latlngs, arguments);\r\n\t\tthis._poly._convertLatLngs(latlngs, true);\r\n\t\tthis._poly.redraw();\r\n\t\treturn removed;\r\n\t},\r\n\r\n\t_removeMarker: function (marker) {\r\n\t\tvar i = marker._index;\r\n\r\n\t\tthis._markerGroup.removeLayer(marker);\r\n\t\tthis._markers.splice(i, 1);\r\n\t\tthis._spliceLatLngs(i, 1);\r\n\t\tthis._updateIndexes(i, -1);\r\n\r\n\t\tmarker\r\n\t\t\t.off('dragstart', this._onMarkerDragStart, this)\r\n\t\t\t.off('drag', this._onMarkerDrag, this)\r\n\t\t\t.off('dragend', this._fireEdit, this)\r\n\t\t\t.off('touchmove', this._onMarkerDrag, this)\r\n\t\t\t.off('touchend', this._fireEdit, this)\r\n\t\t\t.off('click', this._onMarkerClick, this)\r\n\t\t\t.off('MSPointerMove', this._onTouchMove, this)\r\n\t\t\t.off('MSPointerUp', this._fireEdit, this);\r\n\t},\r\n\r\n\t_fireEdit: function () {\r\n\t\tthis._poly.edited = true;\r\n\t\tthis._poly.fire('edit');\r\n\t\tthis._poly._map.fire(L.Draw.Event.EDITVERTEX, {layers: this._markerGroup, poly: this._poly});\r\n\t},\r\n\r\n\t_onMarkerDrag: function (e) {\r\n\t\tvar marker = e.target;\r\n\t\tvar poly = this._poly;\r\n\r\n\t\tvar oldOrigLatLng = L.LatLngUtil.cloneLatLng(marker._origLatLng);\r\n\t\tL.extend(marker._origLatLng, marker._latlng);\r\n\t\tif (poly.options.poly) {\r\n\t\t\tvar tooltip = poly._map._editTooltip; // Access the tooltip\r\n\r\n\t\t\t// If we don't allow intersections and the polygon intersects\r\n\t\t\tif (!poly.options.poly.allowIntersection && poly.intersects()) {\r\n\t\t\t\tL.extend(marker._origLatLng, oldOrigLatLng);\r\n\t\t\t\tmarker.setLatLng(oldOrigLatLng);\r\n\t\t\t\tvar originalColor = poly.options.color;\r\n\t\t\t\tpoly.setStyle({color: this.options.drawError.color});\r\n\t\t\t\tif (tooltip) {\r\n\t\t\t\t\ttooltip.updateContent({\r\n\t\t\t\t\t\ttext: L.drawLocal.draw.handlers.polyline.error\r\n\t\t\t\t\t});\r\n\t\t\t\t}\r\n\r\n\t\t\t\t// Reset everything back to normal after a second\r\n\t\t\t\tsetTimeout(function () {\r\n\t\t\t\t\tpoly.setStyle({color: originalColor});\r\n\t\t\t\t\tif (tooltip) {\r\n\t\t\t\t\t\ttooltip.updateContent({\r\n\t\t\t\t\t\t\ttext: L.drawLocal.edit.handlers.edit.tooltip.text,\r\n\t\t\t\t\t\t\tsubtext: L.drawLocal.edit.handlers.edit.tooltip.subtext\r\n\t\t\t\t\t\t});\r\n\t\t\t\t\t}\r\n\t\t\t\t}, 1000);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (marker._middleLeft) {\r\n\t\t\tmarker._middleLeft.setLatLng(this._getMiddleLatLng(marker._prev, marker));\r\n\t\t}\r\n\t\tif (marker._middleRight) {\r\n\t\t\tmarker._middleRight.setLatLng(this._getMiddleLatLng(marker, marker._next));\r\n\t\t}\r\n\r\n\t\t//refresh the bounds when draging\r\n\t\tthis._poly._bounds._southWest = L.latLng(Infinity, Infinity);\r\n\t\tthis._poly._bounds._northEast = L.latLng(-Infinity, -Infinity);\r\n\t\tvar latlngs = this._poly.getLatLngs();\r\n\t\tthis._poly._convertLatLngs(latlngs, true);\r\n\t\tthis._poly.redraw();\r\n\t\tthis._poly.fire('editdrag');\r\n\t},\r\n\r\n\t_onMarkerClick: function (e) {\r\n\r\n\t\tvar minPoints = L.Polygon && (this._poly instanceof L.Polygon) ? 4 : 3,\r\n\t\t\tmarker = e.target;\r\n\r\n\t\t// If removing this point would create an invalid polyline/polygon don't remove\r\n\t\tif (this._defaultShape().length < minPoints) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\t// remove the marker\r\n\t\tthis._removeMarker(marker);\r\n\r\n\t\t// update prev/next links of adjacent markers\r\n\t\tthis._updatePrevNext(marker._prev, marker._next);\r\n\r\n\t\t// remove ghost markers near the removed marker\r\n\t\tif (marker._middleLeft) {\r\n\t\t\tthis._markerGroup.removeLayer(marker._middleLeft);\r\n\t\t}\r\n\t\tif (marker._middleRight) {\r\n\t\t\tthis._markerGroup.removeLayer(marker._middleRight);\r\n\t\t}\r\n\r\n\t\t// create a ghost marker in place of the removed one\r\n\t\tif (marker._prev && marker._next) {\r\n\t\t\tthis._createMiddleMarker(marker._prev, marker._next);\r\n\r\n\t\t} else if (!marker._prev) {\r\n\t\t\tmarker._next._middleLeft = null;\r\n\r\n\t\t} else if (!marker._next) {\r\n\t\t\tmarker._prev._middleRight = null;\r\n\t\t}\r\n\r\n\t\tthis._fireEdit();\r\n\t},\r\n\r\n\t_onContextMenu: function (e) {\r\n\t\tvar marker = e.target;\r\n\t\tvar poly = this._poly;\r\n\t\tthis._poly._map.fire(L.Draw.Event.MARKERCONTEXT, {marker: marker, layers: this._markerGroup, poly: this._poly});\r\n\t\tL.DomEvent.stopPropagation;\r\n\t},\r\n\r\n\t_onTouchMove: function (e) {\r\n\r\n\t\tvar layerPoint = this._map.mouseEventToLayerPoint(e.originalEvent.touches[0]),\r\n\t\t\tlatlng = this._map.layerPointToLatLng(layerPoint),\r\n\t\t\tmarker = e.target;\r\n\r\n\t\tL.extend(marker._origLatLng, latlng);\r\n\r\n\t\tif (marker._middleLeft) {\r\n\t\t\tmarker._middleLeft.setLatLng(this._getMiddleLatLng(marker._prev, marker));\r\n\t\t}\r\n\t\tif (marker._middleRight) {\r\n\t\t\tmarker._middleRight.setLatLng(this._getMiddleLatLng(marker, marker._next));\r\n\t\t}\r\n\r\n\t\tthis._poly.redraw();\r\n\t\tthis.updateMarkers();\r\n\t},\r\n\r\n\t_updateIndexes: function (index, delta) {\r\n\t\tthis._markerGroup.eachLayer(function (marker) {\r\n\t\t\tif (marker._index > index) {\r\n\t\t\t\tmarker._index += delta;\r\n\t\t\t}\r\n\t\t});\r\n\t},\r\n\r\n\t_createMiddleMarker: function (marker1, marker2) {\r\n\t\tvar latlng = this._getMiddleLatLng(marker1, marker2),\r\n\t\t\tmarker = this._createMarker(latlng),\r\n\t\t\tonClick,\r\n\t\t\tonDragStart,\r\n\t\t\tonDragEnd;\r\n\r\n\t\tmarker.setOpacity(0.6);\r\n\r\n\t\tmarker1._middleRight = marker2._middleLeft = marker;\r\n\r\n\t\tonDragStart = function () {\r\n\t\t\tmarker.off('touchmove', onDragStart, this);\r\n\t\t\tvar i = marker2._index;\r\n\r\n\t\t\tmarker._index = i;\r\n\r\n\t\t\tmarker\r\n\t\t\t\t.off('click', onClick, this)\r\n\t\t\t\t.on('click', this._onMarkerClick, this);\r\n\r\n\t\t\tlatlng.lat = marker.getLatLng().lat;\r\n\t\t\tlatlng.lng = marker.getLatLng().lng;\r\n\t\t\tthis._spliceLatLngs(i, 0, latlng);\r\n\t\t\tthis._markers.splice(i, 0, marker);\r\n\r\n\t\t\tmarker.setOpacity(1);\r\n\r\n\t\t\tthis._updateIndexes(i, 1);\r\n\t\t\tmarker2._index++;\r\n\t\t\tthis._updatePrevNext(marker1, marker);\r\n\t\t\tthis._updatePrevNext(marker, marker2);\r\n\r\n\t\t\tthis._poly.fire('editstart');\r\n\t\t};\r\n\r\n\t\tonDragEnd = function () {\r\n\t\t\tmarker.off('dragstart', onDragStart, this);\r\n\t\t\tmarker.off('dragend', onDragEnd, this);\r\n\t\t\tmarker.off('touchmove', onDragStart, this);\r\n\r\n\t\t\tthis._createMiddleMarker(marker1, marker);\r\n\t\t\tthis._createMiddleMarker(marker, marker2);\r\n\t\t};\r\n\r\n\t\tonClick = function () {\r\n\t\t\tonDragStart.call(this);\r\n\t\t\tonDragEnd.call(this);\r\n\t\t\tthis._fireEdit();\r\n\t\t};\r\n\r\n\t\tmarker\r\n\t\t\t.on('click', onClick, this)\r\n\t\t\t.on('dragstart', onDragStart, this)\r\n\t\t\t.on('dragend', onDragEnd, this)\r\n\t\t\t.on('touchmove', onDragStart, this);\r\n\r\n\t\tthis._markerGroup.addLayer(marker);\r\n\t},\r\n\r\n\t_updatePrevNext: function (marker1, marker2) {\r\n\t\tif (marker1) {\r\n\t\t\tmarker1._next = marker2;\r\n\t\t}\r\n\t\tif (marker2) {\r\n\t\t\tmarker2._prev = marker1;\r\n\t\t}\r\n\t},\r\n\r\n\t_getMiddleLatLng: function (marker1, marker2) {\r\n\t\tvar map = this._poly._map,\r\n\t\t\tp1 = map.project(marker1.getLatLng()),\r\n\t\t\tp2 = map.project(marker2.getLatLng());\r\n\r\n\t\treturn map.unproject(p1._add(p2)._divideBy(2));\r\n\t}\r\n});\r\n\r\nL.Polyline.addInitHook(function () {\r\n\r\n\t// Check to see if handler has already been initialized. This is to support versions of Leaflet that still have L.Handler.PolyEdit\r\n\tif (this.editing) {\r\n\t\treturn;\r\n\t}\r\n\r\n\tif (L.Edit.Poly) {\r\n\r\n\t\tthis.editing = new L.Edit.Poly(this);\r\n\r\n\t\tif (this.options.editable) {\r\n\t\t\tthis.editing.enable();\r\n\t\t}\r\n\t}\r\n\r\n\tthis.on('add', function () {\r\n\t\tif (this.editing && this.editing.enabled()) {\r\n\t\t\tthis.editing.addHooks();\r\n\t\t}\r\n\t});\r\n\r\n\tthis.on('remove', function () {\r\n\t\tif (this.editing && this.editing.enabled()) {\r\n\t\t\tthis.editing.removeHooks();\r\n\t\t}\r\n\t});\r\n});\r\n","L.Edit = L.Edit || {};\r\n/**\r\n * @class L.Edit.SimpleShape\r\n * @aka Edit.SimpleShape\r\n */\r\nL.Edit.SimpleShape = L.Handler.extend({\r\n\toptions: {\r\n\t\tmoveIcon: new L.DivIcon({\r\n\t\t\ticonSize: new L.Point(8, 8),\r\n\t\t\tclassName: 'leaflet-div-icon leaflet-editing-icon leaflet-edit-move'\r\n\t\t}),\r\n\t\tresizeIcon: new L.DivIcon({\r\n\t\t\ticonSize: new L.Point(8, 8),\r\n\t\t\tclassName: 'leaflet-div-icon leaflet-editing-icon leaflet-edit-resize'\r\n\t\t}),\r\n\t\ttouchMoveIcon: new L.DivIcon({\r\n\t\t\ticonSize: new L.Point(20, 20),\r\n\t\t\tclassName: 'leaflet-div-icon leaflet-editing-icon leaflet-edit-move leaflet-touch-icon'\r\n\t\t}),\r\n\t\ttouchResizeIcon: new L.DivIcon({\r\n\t\t\ticonSize: new L.Point(20, 20),\r\n\t\t\tclassName: 'leaflet-div-icon leaflet-editing-icon leaflet-edit-resize leaflet-touch-icon'\r\n\t\t}),\r\n\t},\r\n\r\n\t// @method intialize(): void\r\n\tinitialize: function (shape, options) {\r\n\t\t// if touch, switch to touch icon\r\n\t\tif (L.Browser.touch) {\r\n\t\t\tthis.options.moveIcon = this.options.touchMoveIcon;\r\n\t\t\tthis.options.resizeIcon = this.options.touchResizeIcon;\r\n\t\t}\r\n\r\n\t\tthis._shape = shape;\r\n\t\tL.Util.setOptions(this, options);\r\n\t},\r\n\r\n\t// @method addHooks(): void\r\n\t// Add listener hooks to this handler\r\n\taddHooks: function () {\r\n\t\tvar shape = this._shape;\r\n\t\tif (this._shape._map) {\r\n\t\t\tthis._map = this._shape._map;\r\n\t\t\tshape.setStyle(shape.options.editing);\r\n\r\n\t\t\tif (shape._map) {\r\n\t\t\t\tthis._map = shape._map;\r\n\t\t\t\tif (!this._markerGroup) {\r\n\t\t\t\t\tthis._initMarkers();\r\n\t\t\t\t}\r\n\t\t\t\tthis._map.addLayer(this._markerGroup);\r\n\t\t\t}\r\n\t\t}\r\n\t},\r\n\r\n\t// @method removeHooks(): void\r\n\t// Remove listener hooks from this handler\r\n\tremoveHooks: function () {\r\n\t\tvar shape = this._shape;\r\n\r\n\t\tshape.setStyle(shape.options.original);\r\n\r\n\t\tif (shape._map) {\r\n\t\t\tthis._unbindMarker(this._moveMarker);\r\n\r\n\t\t\tfor (var i = 0, l = this._resizeMarkers.length; i < l; i++) {\r\n\t\t\t\tthis._unbindMarker(this._resizeMarkers[i]);\r\n\t\t\t}\r\n\t\t\tthis._resizeMarkers = null;\r\n\r\n\t\t\tthis._map.removeLayer(this._markerGroup);\r\n\t\t\tdelete this._markerGroup;\r\n\t\t}\r\n\r\n\t\tthis._map = null;\r\n\t},\r\n\r\n\t// @method updateMarkers(): void\r\n\t// Remove the edit markers from this layer\r\n\tupdateMarkers: function () {\r\n\t\tthis._markerGroup.clearLayers();\r\n\t\tthis._initMarkers();\r\n\t},\r\n\r\n\t_initMarkers: function () {\r\n\t\tif (!this._markerGroup) {\r\n\t\t\tthis._markerGroup = new L.LayerGroup();\r\n\t\t}\r\n\r\n\t\t// Create center marker\r\n\t\tthis._createMoveMarker();\r\n\r\n\t\t// Create edge marker\r\n\t\tthis._createResizeMarker();\r\n\t},\r\n\r\n\t_createMoveMarker: function () {\r\n\t\t// Children override\r\n\t},\r\n\r\n\t_createResizeMarker: function () {\r\n\t\t// Children override\r\n\t},\r\n\r\n\t_createMarker: function (latlng, icon) {\r\n\t\t// Extending L.Marker in TouchEvents.js to include touch.\r\n\t\tvar marker = new L.Marker.Touch(latlng, {\r\n\t\t\tdraggable: true,\r\n\t\t\ticon: icon,\r\n\t\t\tzIndexOffset: 10\r\n\t\t});\r\n\r\n\t\tthis._bindMarker(marker);\r\n\r\n\t\tthis._markerGroup.addLayer(marker);\r\n\r\n\t\treturn marker;\r\n\t},\r\n\r\n\t_bindMarker: function (marker) {\r\n\t\tmarker\r\n\t\t\t.on('dragstart', this._onMarkerDragStart, this)\r\n\t\t\t.on('drag', this._onMarkerDrag, this)\r\n\t\t\t.on('dragend', this._onMarkerDragEnd, this)\r\n\t\t\t.on('touchstart', this._onTouchStart, this)\r\n\t\t\t.on('touchmove', this._onTouchMove, this)\r\n\t\t\t.on('MSPointerMove', this._onTouchMove, this)\r\n\t\t\t.on('touchend', this._onTouchEnd, this)\r\n\t\t\t.on('MSPointerUp', this._onTouchEnd, this);\r\n\t},\r\n\r\n\t_unbindMarker: function (marker) {\r\n\t\tmarker\r\n\t\t\t.off('dragstart', this._onMarkerDragStart, this)\r\n\t\t\t.off('drag', this._onMarkerDrag, this)\r\n\t\t\t.off('dragend', this._onMarkerDragEnd, this)\r\n\t\t\t.off('touchstart', this._onTouchStart, this)\r\n\t\t\t.off('touchmove', this._onTouchMove, this)\r\n\t\t\t.off('MSPointerMove', this._onTouchMove, this)\r\n\t\t\t.off('touchend', this._onTouchEnd, this)\r\n\t\t\t.off('MSPointerUp', this._onTouchEnd, this);\r\n\t},\r\n\r\n\t_onMarkerDragStart: function (e) {\r\n\t\tvar marker = e.target;\r\n\t\tmarker.setOpacity(0);\r\n\r\n\t\tthis._shape.fire('editstart');\r\n\t},\r\n\r\n\t_fireEdit: function () {\r\n\t\tthis._shape.edited = true;\r\n\t\tthis._shape.fire('edit');\r\n\t},\r\n\r\n\t_onMarkerDrag: function (e) {\r\n\t\tvar marker = e.target,\r\n\t\t\tlatlng = marker.getLatLng();\r\n\r\n\t\tif (marker === this._moveMarker) {\r\n\t\t\tthis._move(latlng);\r\n\t\t} else {\r\n\t\t\tthis._resize(latlng);\r\n\t\t}\r\n\r\n\t\tthis._shape.redraw();\r\n\t\tthis._shape.fire('editdrag');\r\n\t},\r\n\r\n\t_onMarkerDragEnd: function (e) {\r\n\t\tvar marker = e.target;\r\n\t\tmarker.setOpacity(1);\r\n\r\n\t\tthis._fireEdit();\r\n\t},\r\n\r\n\t_onTouchStart: function (e) {\r\n\t\tL.Edit.SimpleShape.prototype._onMarkerDragStart.call(this, e);\r\n\r\n\t\tif (typeof(this._getCorners) === 'function') {\r\n\t\t\t// Save a reference to the opposite point\r\n\t\t\tvar corners = this._getCorners(),\r\n\t\t\t\tmarker = e.target,\r\n\t\t\t\tcurrentCornerIndex = marker._cornerIndex;\r\n\r\n\t\t\tmarker.setOpacity(0);\r\n\r\n\t\t\t// Copyed from Edit.Rectangle.js line 23 _onMarkerDragStart()\r\n\t\t\t// Latlng is null otherwise.\r\n\t\t\tthis._oppositeCorner = corners[(currentCornerIndex + 2) % 4];\r\n\t\t\tthis._toggleCornerMarkers(0, currentCornerIndex);\r\n\t\t}\r\n\r\n\t\tthis._shape.fire('editstart');\r\n\t},\r\n\r\n\t_onTouchMove: function (e) {\r\n\t\tvar layerPoint = this._map.mouseEventToLayerPoint(e.originalEvent.touches[0]),\r\n\t\t\tlatlng = this._map.layerPointToLatLng(layerPoint),\r\n\t\t\tmarker = e.target;\r\n\r\n\t\tif (marker === this._moveMarker) {\r\n\t\t\tthis._move(latlng);\r\n\t\t} else {\r\n\t\t\tthis._resize(latlng);\r\n\t\t}\r\n\r\n\t\tthis._shape.redraw();\r\n\r\n\t\t// prevent touchcancel in IOS\r\n\t\t// e.preventDefault();\r\n\t\treturn false;\r\n\t},\r\n\r\n\t_onTouchEnd: function (e) {\r\n\t\tvar marker = e.target;\r\n\t\tmarker.setOpacity(1);\r\n\t\tthis.updateMarkers();\r\n\t\tthis._fireEdit();\r\n\t},\r\n\r\n\t_move: function () {\r\n\t\t// Children override\r\n\t},\r\n\r\n\t_resize: function () {\r\n\t\t// Children override\r\n\t}\r\n});\r\n","L.Edit = L.Edit || {};\r\n/**\r\n * @class L.Edit.Rectangle\r\n * @aka Edit.Rectangle\r\n * @inherits L.Edit.SimpleShape\r\n */\r\nL.Edit.Rectangle = L.Edit.SimpleShape.extend({\r\n\t_createMoveMarker: function () {\r\n\t\tvar bounds = this._shape.getBounds(),\r\n\t\t\tcenter = bounds.getCenter();\r\n\r\n\t\tthis._moveMarker = this._createMarker(center, this.options.moveIcon);\r\n\t},\r\n\r\n\t_createResizeMarker: function () {\r\n\t\tvar corners = this._getCorners();\r\n\r\n\t\tthis._resizeMarkers = [];\r\n\r\n\t\tfor (var i = 0, l = corners.length; i < l; i++) {\r\n\t\t\tthis._resizeMarkers.push(this._createMarker(corners[i], this.options.resizeIcon));\r\n\t\t\t// Monkey in the corner index as we will need to know this for dragging\r\n\t\t\tthis._resizeMarkers[i]._cornerIndex = i;\r\n\t\t}\r\n\t},\r\n\r\n\t_onMarkerDragStart: function (e) {\r\n\t\tL.Edit.SimpleShape.prototype._onMarkerDragStart.call(this, e);\r\n\r\n\t\t// Save a reference to the opposite point\r\n\t\tvar corners = this._getCorners(),\r\n\t\t\tmarker = e.target,\r\n\t\t\tcurrentCornerIndex = marker._cornerIndex;\r\n\r\n\t\tthis._oppositeCorner = corners[(currentCornerIndex + 2) % 4];\r\n\r\n\t\tthis._toggleCornerMarkers(0, currentCornerIndex);\r\n\t},\r\n\r\n\t_onMarkerDragEnd: function (e) {\r\n\t\tvar marker = e.target,\r\n\t\t\tbounds, center;\r\n\r\n\t\t// Reset move marker position to the center\r\n\t\tif (marker === this._moveMarker) {\r\n\t\t\tbounds = this._shape.getBounds();\r\n\t\t\tcenter = bounds.getCenter();\r\n\r\n\t\t\tmarker.setLatLng(center);\r\n\t\t}\r\n\r\n\t\tthis._toggleCornerMarkers(1);\r\n\r\n\t\tthis._repositionCornerMarkers();\r\n\r\n\t\tL.Edit.SimpleShape.prototype._onMarkerDragEnd.call(this, e);\r\n\t},\r\n\r\n\t_move: function (newCenter) {\r\n\t\tvar latlngs = this._shape._defaultShape ? this._shape._defaultShape() : this._shape.getLatLngs(),\r\n\t\t\tbounds = this._shape.getBounds(),\r\n\t\t\tcenter = bounds.getCenter(),\r\n\t\t\toffset, newLatLngs = [];\r\n\r\n\t\t// Offset the latlngs to the new center\r\n\t\tfor (var i = 0, l = latlngs.length; i < l; i++) {\r\n\t\t\toffset = [latlngs[i].lat - center.lat, latlngs[i].lng - center.lng];\r\n\t\t\tnewLatLngs.push([newCenter.lat + offset[0], newCenter.lng + offset[1]]);\r\n\t\t}\r\n\r\n\t\tthis._shape.setLatLngs(newLatLngs);\r\n\r\n\t\t// Reposition the resize markers\r\n\t\tthis._repositionCornerMarkers();\r\n\r\n\t\tthis._map.fire(L.Draw.Event.EDITMOVE, {layer: this._shape});\r\n\t},\r\n\r\n\t_resize: function (latlng) {\r\n\t\tvar bounds;\r\n\r\n\t\t// Update the shape based on the current position of this corner and the opposite point\r\n\t\tthis._shape.setBounds(L.latLngBounds(latlng, this._oppositeCorner));\r\n\r\n\t\t// Reposition the move marker\r\n\t\tbounds = this._shape.getBounds();\r\n\t\tthis._moveMarker.setLatLng(bounds.getCenter());\r\n\r\n\t\tthis._map.fire(L.Draw.Event.EDITRESIZE, {layer: this._shape});\r\n\t},\r\n\r\n\t_getCorners: function () {\r\n\t\tvar bounds = this._shape.getBounds(),\r\n\t\t\tnw = bounds.getNorthWest(),\r\n\t\t\tne = bounds.getNorthEast(),\r\n\t\t\tse = bounds.getSouthEast(),\r\n\t\t\tsw = bounds.getSouthWest();\r\n\r\n\t\treturn [nw, ne, se, sw];\r\n\t},\r\n\r\n\t_toggleCornerMarkers: function (opacity) {\r\n\t\tfor (var i = 0, l = this._resizeMarkers.length; i < l; i++) {\r\n\t\t\tthis._resizeMarkers[i].setOpacity(opacity);\r\n\t\t}\r\n\t},\r\n\r\n\t_repositionCornerMarkers: function () {\r\n\t\tvar corners = this._getCorners();\r\n\r\n\t\tfor (var i = 0, l = this._resizeMarkers.length; i < l; i++) {\r\n\t\t\tthis._resizeMarkers[i].setLatLng(corners[i]);\r\n\t\t}\r\n\t}\r\n});\r\n\r\nL.Rectangle.addInitHook(function () {\r\n\tif (L.Edit.Rectangle) {\r\n\t\tthis.editing = new L.Edit.Rectangle(this);\r\n\r\n\t\tif (this.options.editable) {\r\n\t\t\tthis.editing.enable();\r\n\t\t}\r\n\t}\r\n});\r\n","L.Edit = L.Edit || {};\r\n/**\r\n * @class L.Edit.CircleMarker\r\n * @aka Edit.Circle\r\n * @inherits L.Edit.SimpleShape\r\n */\r\nL.Edit.CircleMarker = L.Edit.SimpleShape.extend({\r\n\t_createMoveMarker: function () {\r\n\t\tvar center = this._shape.getLatLng();\r\n\t\tthis._map._editTooltip = new L.Draw.Tooltip(this._map);\r\n\t\tthis._moveMarker = this._createMarker(center, this.options.moveIcon);\r\n\t},\r\n\r\n\t_createResizeMarker: function () {\r\n\t\t// To avoid an undefined check in L.Edit.SimpleShape.removeHooks\r\n\t\tthis._resizeMarkers = [];\r\n\t},\r\n\r\n\t_move: function (latlng) {\r\n\t\tif (this._resizeMarkers.length) {\r\n\t\t\tvar resizemarkerPoint = this._getResizeMarkerPoint(latlng);\r\n\t\t\t// Move the resize marker\r\n\t\t\tthis._resizeMarkers[0].setLatLng(resizemarkerPoint);\r\n\t\t}\r\n\r\n\t\t// Move the circle\r\n\t\tthis._shape.setLatLng(latlng);\r\n\r\n\t\tthis._map.fire(L.Draw.Event.EDITMOVE, {layer: this._shape});\r\n\t},\r\n});\r\n\r\nL.CircleMarker.addInitHook(function () {\r\n\tif (L.Edit.CircleMarker) {\r\n\t\tthis.editing = new L.Edit.CircleMarker(this);\r\n\r\n\t\tif (this.options.editable) {\r\n\t\t\tthis.editing.enable();\r\n\t\t}\r\n\t}\r\n\r\n\tthis.on('add', function () {\r\n\t\tif (this.editing && this.editing.enabled()) {\r\n\t\t\tthis.editing.addHooks();\r\n\t\t}\r\n\t});\r\n\r\n\tthis.on('remove', function () {\r\n\t\tif (this.editing && this.editing.enabled()) {\r\n\t\t\tthis.editing.removeHooks();\r\n\t\t}\r\n\t});\r\n});\r\n","L.Edit = L.Edit || {};\r\n/**\r\n * @class L.Edit.Circle\r\n * @aka Edit.Circle\r\n * @inherits L.Edit.CircleMarker\r\n */\r\nL.Edit.Circle = L.Edit.CircleMarker.extend({\r\n\r\n\t_createResizeMarker: function () {\r\n\t\tvar center = this._shape.getLatLng(),\r\n\t\t\tresizemarkerPoint = this._getResizeMarkerPoint(center);\r\n\r\n\t\tthis._resizeMarkers = [];\r\n\t\tthis._resizeMarkers.push(this._createMarker(resizemarkerPoint, this.options.resizeIcon));\r\n\t},\r\n\r\n\t_getResizeMarkerPoint: function (latlng) {\r\n\t\t// From L.shape.getBounds()\r\n\t\tvar delta = this._shape._radius * Math.cos(Math.PI / 4),\r\n\t\t\tpoint = this._map.project(latlng);\r\n\t\treturn this._map.unproject([point.x + delta, point.y - delta]);\r\n\t},\r\n\r\n\t_resize: function (latlng) {\r\n\t\tvar moveLatLng = this._moveMarker.getLatLng();\r\n\r\n\t\t// Calculate the radius based on the version\r\n\t\tif (L.GeometryUtil.isVersion07x()) {\r\n\t\t\tradius = moveLatLng.distanceTo(latlng);\r\n\t\t} else {\r\n\t\t\tradius = this._map.distance(moveLatLng, latlng);\r\n\t\t}\r\n\t\tthis._shape.setRadius(radius);\r\n\r\n\t\tif (this._map._editTooltip) {\r\n\t\t\tthis._map._editTooltip.updatePosition(latlng);\r\n\t\t\tthis._map._editTooltip.updateContent({\r\n\t\t\t\ttext: L.drawLocal.edit.handlers.edit.tooltip.subtext + '
' + L.drawLocal.edit.handlers.edit.tooltip.text,\r\n\t\t\t\tsubtext: L.drawLocal.draw.handlers.circle.radius + ': ' +\r\n\t\t\t\tL.GeometryUtil.readableDistance(radius, true, this.options.feet, this.options.nautic)\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\tthis._shape.setRadius(radius);\r\n\r\n\t\tthis._map.fire(L.Draw.Event.EDITRESIZE, {layer: this._shape});\r\n\t}\r\n});\r\n\r\nL.Circle.addInitHook(function () {\r\n\tif (L.Edit.Circle) {\r\n\t\tthis.editing = new L.Edit.Circle(this);\r\n\r\n\t\tif (this.options.editable) {\r\n\t\t\tthis.editing.enable();\r\n\t\t}\r\n\t}\r\n});\r\n","L.Map.mergeOptions({\r\n\ttouchExtend: true\r\n});\r\n\r\n/**\r\n * @class L.Map.TouchExtend\r\n * @aka TouchExtend\r\n */\r\nL.Map.TouchExtend = L.Handler.extend({\r\n\r\n\t// @method initialize(): void\r\n\t// Sets TouchExtend private accessor variables\r\n\tinitialize: function (map) {\r\n\t\tthis._map = map;\r\n\t\tthis._container = map._container;\r\n\t\tthis._pane = map._panes.overlayPane;\r\n\t},\r\n\r\n\t// @method addHooks(): void\r\n\t// Adds dom listener events to the map container\r\n\taddHooks: function () {\r\n\t\tL.DomEvent.on(this._container, 'touchstart', this._onTouchStart, this);\r\n\t\tL.DomEvent.on(this._container, 'touchend', this._onTouchEnd, this);\r\n\t\tL.DomEvent.on(this._container, 'touchmove', this._onTouchMove, this);\r\n\t\tif (this._detectIE()) {\r\n\t\t\tL.DomEvent.on(this._container, 'MSPointerDown', this._onTouchStart, this);\r\n\t\t\tL.DomEvent.on(this._container, 'MSPointerUp', this._onTouchEnd, this);\r\n\t\t\tL.DomEvent.on(this._container, 'MSPointerMove', this._onTouchMove, this);\r\n\t\t\tL.DomEvent.on(this._container, 'MSPointerCancel', this._onTouchCancel, this);\r\n\r\n\t\t} else {\r\n\t\t\tL.DomEvent.on(this._container, 'touchcancel', this._onTouchCancel, this);\r\n\t\t\tL.DomEvent.on(this._container, 'touchleave', this._onTouchLeave, this);\r\n\t\t}\r\n\t},\r\n\r\n\t// @method removeHooks(): void\r\n\t// Removes dom listener events from the map container\r\n\tremoveHooks: function () {\r\n\t\tL.DomEvent.off(this._container, 'touchstart', this._onTouchStart, this);\r\n\t\tL.DomEvent.off(this._container, 'touchend', this._onTouchEnd, this);\r\n\t\tL.DomEvent.off(this._container, 'touchmove', this._onTouchMove, this);\r\n\t\tif (this._detectIE()) {\r\n\t\t\tL.DomEvent.off(this._container, 'MSPointerDown', this._onTouchStart, this);\r\n\t\t\tL.DomEvent.off(this._container, 'MSPointerUp', this._onTouchEnd, this);\r\n\t\t\tL.DomEvent.off(this._container, 'MSPointerMove', this._onTouchMove, this);\r\n\t\t\tL.DomEvent.off(this._container, 'MSPointerCancel', this._onTouchCancel, this);\r\n\t\t} else {\r\n\t\t\tL.DomEvent.off(this._container, 'touchcancel', this._onTouchCancel, this);\r\n\t\t\tL.DomEvent.off(this._container, 'touchleave', this._onTouchLeave, this);\r\n\t\t}\r\n\t},\r\n\r\n\t_touchEvent: function (e, type) {\r\n\t\t// #TODO: fix the pageX error that is do a bug in Android where a single touch triggers two click events\r\n\t\t// _filterClick is what leaflet uses as a workaround.\r\n\t\t// This is a problem with more things than just android. Another problem is touchEnd has no touches in\r\n\t\t// its touch list.\r\n\t\tvar touchEvent = {};\r\n\t\tif (typeof e.touches !== 'undefined') {\r\n\t\t\tif (!e.touches.length) {\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\t\t\ttouchEvent = e.touches[0];\r\n\t\t} else if (e.pointerType === 'touch') {\r\n\t\t\ttouchEvent = e;\r\n\t\t\tif (!this._filterClick(e)) {\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\t\t} else {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tvar containerPoint = this._map.mouseEventToContainerPoint(touchEvent),\r\n\t\t\tlayerPoint = this._map.mouseEventToLayerPoint(touchEvent),\r\n\t\t\tlatlng = this._map.layerPointToLatLng(layerPoint);\r\n\r\n\t\tthis._map.fire(type, {\r\n\t\t\tlatlng: latlng,\r\n\t\t\tlayerPoint: layerPoint,\r\n\t\t\tcontainerPoint: containerPoint,\r\n\t\t\tpageX: touchEvent.pageX,\r\n\t\t\tpageY: touchEvent.pageY,\r\n\t\t\toriginalEvent: e\r\n\t\t});\r\n\t},\r\n\r\n\t/** Borrowed from Leaflet and modified for bool ops **/\r\n\t_filterClick: function (e) {\r\n\t\tvar timeStamp = (e.timeStamp || e.originalEvent.timeStamp),\r\n\t\t\telapsed = L.DomEvent._lastClick && (timeStamp - L.DomEvent._lastClick);\r\n\r\n\t\t// are they closer together than 500ms yet more than 100ms?\r\n\t\t// Android typically triggers them ~300ms apart while multiple listeners\r\n\t\t// on the same event should be triggered far faster;\r\n\t\t// or check if click is simulated on the element, and if it is, reject any non-simulated events\r\n\t\tif ((elapsed && elapsed > 100 && elapsed < 500) || (e.target._simulatedClick && !e._simulated)) {\r\n\t\t\tL.DomEvent.stop(e);\r\n\t\t\treturn false;\r\n\t\t}\r\n\t\tL.DomEvent._lastClick = timeStamp;\r\n\t\treturn true;\r\n\t},\r\n\r\n\t_onTouchStart: function (e) {\r\n\t\tif (!this._map._loaded) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tvar type = 'touchstart';\r\n\t\tthis._touchEvent(e, type);\r\n\r\n\t},\r\n\r\n\t_onTouchEnd: function (e) {\r\n\t\tif (!this._map._loaded) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tvar type = 'touchend';\r\n\t\tthis._touchEvent(e, type);\r\n\t},\r\n\r\n\t_onTouchCancel: function (e) {\r\n\t\tif (!this._map._loaded) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tvar type = 'touchcancel';\r\n\t\tif (this._detectIE()) {\r\n\t\t\ttype = 'pointercancel';\r\n\t\t}\r\n\t\tthis._touchEvent(e, type);\r\n\t},\r\n\r\n\t_onTouchLeave: function (e) {\r\n\t\tif (!this._map._loaded) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tvar type = 'touchleave';\r\n\t\tthis._touchEvent(e, type);\r\n\t},\r\n\r\n\t_onTouchMove: function (e) {\r\n\t\tif (!this._map._loaded) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tvar type = 'touchmove';\r\n\t\tthis._touchEvent(e, type);\r\n\t},\r\n\r\n\t_detectIE: function () {\r\n\t\tvar ua = window.navigator.userAgent;\r\n\r\n\t\tvar msie = ua.indexOf('MSIE ');\r\n\t\tif (msie > 0) {\r\n\t\t\t// IE 10 or older => return version number\r\n\t\t\treturn parseInt(ua.substring(msie + 5, ua.indexOf('.', msie)), 10);\r\n\t\t}\r\n\r\n\t\tvar trident = ua.indexOf('Trident/');\r\n\t\tif (trident > 0) {\r\n\t\t\t// IE 11 => return version number\r\n\t\t\tvar rv = ua.indexOf('rv:');\r\n\t\t\treturn parseInt(ua.substring(rv + 3, ua.indexOf('.', rv)), 10);\r\n\t\t}\r\n\r\n\t\tvar edge = ua.indexOf('Edge/');\r\n\t\tif (edge > 0) {\r\n\t\t\t// IE 12 => return version number\r\n\t\t\treturn parseInt(ua.substring(edge + 5, ua.indexOf('.', edge)), 10);\r\n\t\t}\r\n\r\n\t\t// other browser\r\n\t\treturn false;\r\n\t}\r\n});\r\n\r\nL.Map.addInitHook('addHandler', 'touchExtend', L.Map.TouchExtend);\r\n\r\n\r\n/**\r\n * @class L.Marker.Touch\r\n * @aka Marker.Touch\r\n *\r\n * This isn't full Touch support. This is just to get markers to also support dom touch events after creation\r\n * #TODO: find a better way of getting markers to support touch.\r\n */\r\nL.Marker.Touch = L.Marker.extend({\r\n\r\n\t_initInteraction: function () {\r\n\t\tif (!this.addInteractiveTarget) {\r\n\t\t\t// 0.7.x support\r\n\t\t\treturn this._initInteractionLegacy();\r\n\t\t}\r\n\t\t// TODO this may need be updated to re-add touch events for 1.0+\r\n\t\treturn L.Marker.prototype._initInteraction.apply(this);\r\n\t},\r\n\r\n\t// This is an exact copy of https://github.com/Leaflet/Leaflet/blob/v0.7/src/layer/marker/Marker.js\r\n\t// with the addition of the touch events\r\n\t_initInteractionLegacy: function () {\r\n\r\n\t\tif (!this.options.clickable) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\t// TODO refactor into something shared with Map/Path/etc. to DRY it up\r\n\r\n\t\tvar icon = this._icon,\r\n\t\t\tevents = ['dblclick',\r\n\t\t\t\t'mousedown',\r\n\t\t\t\t'mouseover',\r\n\t\t\t\t'mouseout',\r\n\t\t\t\t'contextmenu',\r\n\t\t\t\t'touchstart',\r\n\t\t\t\t'touchend',\r\n\t\t\t\t'touchmove'];\r\n\t\tif (this._detectIE) {\r\n\t\t\tevents.concat(['MSPointerDown',\r\n\t\t\t\t'MSPointerUp',\r\n\t\t\t\t'MSPointerMove',\r\n\t\t\t\t'MSPointerCancel']);\r\n\t\t} else {\r\n\t\t\tevents.concat(['touchcancel']);\r\n\t\t}\r\n\r\n\t\tL.DomUtil.addClass(icon, 'leaflet-clickable');\r\n\t\tL.DomEvent.on(icon, 'click', this._onMouseClick, this);\r\n\t\tL.DomEvent.on(icon, 'keypress', this._onKeyPress, this);\r\n\r\n\t\tfor (var i = 0; i < events.length; i++) {\r\n\t\t\tL.DomEvent.on(icon, events[i], this._fireMouseEvent, this);\r\n\t\t}\r\n\r\n\t\tif (L.Handler.MarkerDrag) {\r\n\t\t\tthis.dragging = new L.Handler.MarkerDrag(this);\r\n\r\n\t\t\tif (this.options.draggable) {\r\n\t\t\t\tthis.dragging.enable();\r\n\t\t\t}\r\n\t\t}\r\n\t},\r\n\r\n\t_detectIE: function () {\r\n\t\tvar ua = window.navigator.userAgent;\r\n\r\n\t\tvar msie = ua.indexOf('MSIE ');\r\n\t\tif (msie > 0) {\r\n\t\t\t// IE 10 or older => return version number\r\n\t\t\treturn parseInt(ua.substring(msie + 5, ua.indexOf('.', msie)), 10);\r\n\t\t}\r\n\r\n\t\tvar trident = ua.indexOf('Trident/');\r\n\t\tif (trident > 0) {\r\n\t\t\t// IE 11 => return version number\r\n\t\t\tvar rv = ua.indexOf('rv:');\r\n\t\t\treturn parseInt(ua.substring(rv + 3, ua.indexOf('.', rv)), 10);\r\n\t\t}\r\n\r\n\t\tvar edge = ua.indexOf('Edge/');\r\n\t\tif (edge > 0) {\r\n\t\t\t// IE 12 => return version number\r\n\t\t\treturn parseInt(ua.substring(edge + 5, ua.indexOf('.', edge)), 10);\r\n\t\t}\r\n\r\n\t\t// other browser\r\n\t\treturn false;\r\n\t}\r\n});\r\n","/**\r\n * @class L.LatLngUtil\r\n * @aka LatLngUtil\r\n */\r\nL.LatLngUtil = {\r\n\t// Clones a LatLngs[], returns [][]\r\n\r\n\t// @method cloneLatLngs(LatLngs[]): L.LatLngs[]\r\n\t// Clone the latLng point or points or nested points and return an array with those points\r\n\tcloneLatLngs: function (latlngs) {\r\n\t\tvar clone = [];\r\n\t\tfor (var i = 0, l = latlngs.length; i < l; i++) {\r\n\t\t\t// Check for nested array (Polyline/Polygon)\r\n\t\t\tif (Array.isArray(latlngs[i])) {\r\n\t\t\t\tclone.push(L.LatLngUtil.cloneLatLngs(latlngs[i]));\r\n\t\t\t} else {\r\n\t\t\t\tclone.push(this.cloneLatLng(latlngs[i]));\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn clone;\r\n\t},\r\n\r\n\t// @method cloneLatLng(LatLng): L.LatLng\r\n\t// Clone the latLng and return a new LatLng object.\r\n\tcloneLatLng: function (latlng) {\r\n\t\treturn L.latLng(latlng.lat, latlng.lng);\r\n\t}\r\n};\r\n","(function () {\r\n\r\n\tvar defaultPrecision = {\r\n\t\tkm: 2,\r\n\t\tha: 2,\r\n\t\tm: 0,\r\n\t\tmi: 2,\r\n\t\tac: 2,\r\n\t\tyd: 0,\r\n\t\tft: 0,\r\n\t\tnm: 2\r\n\t};\r\n\r\n\r\n\t/**\r\n\t * @class L.GeometryUtil\r\n\t * @aka GeometryUtil\r\n\t */\r\n\tL.GeometryUtil = L.extend(L.GeometryUtil || {}, {\r\n\t\t// Ported from the OpenLayers implementation. See https://github.com/openlayers/openlayers/blob/master/lib/OpenLayers/Geometry/LinearRing.js#L270\r\n\r\n\t\t// @method geodesicArea(): number\r\n\t\tgeodesicArea: function (latLngs) {\r\n\t\t\tvar pointsCount = latLngs.length,\r\n\t\t\t\tarea = 0.0,\r\n\t\t\t\td2r = Math.PI / 180,\r\n\t\t\t\tp1, p2;\r\n\r\n\t\t\tif (pointsCount > 2) {\r\n\t\t\t\tfor (var i = 0; i < pointsCount; i++) {\r\n\t\t\t\t\tp1 = latLngs[i];\r\n\t\t\t\t\tp2 = latLngs[(i + 1) % pointsCount];\r\n\t\t\t\t\tarea += ((p2.lng - p1.lng) * d2r) *\r\n\t\t\t\t\t\t(2 + Math.sin(p1.lat * d2r) + Math.sin(p2.lat * d2r));\r\n\t\t\t\t}\r\n\t\t\t\tarea = area * 6378137.0 * 6378137.0 / 2.0;\r\n\t\t\t}\r\n\r\n\t\t\treturn Math.abs(area);\r\n\t\t},\r\n\r\n\t\t// @method formattedNumber(n, precision): string\r\n\t\t// Returns n in specified number format (if defined) and precision\r\n\t\tformattedNumber: function (n, precision) {\r\n\t\t\tvar formatted = parseFloat(n).toFixed(precision),\r\n\t\t\t\tformat = L.drawLocal.format && L.drawLocal.format.numeric,\r\n\t\t\t\tdelimiters = format && format.delimiters,\r\n\t\t\t\tthousands = delimiters && delimiters.thousands,\r\n\t\t\t\tdecimal = delimiters && delimiters.decimal;\r\n\r\n\t\t\tif (thousands || decimal) {\r\n\t\t\t\tvar splitValue = formatted.split('.');\r\n\t\t\t\tformatted = thousands ? splitValue[0].replace(/(\\d)(?=(\\d{3})+(?!\\d))/g, '$1' + thousands) : splitValue[0];\r\n\t\t\t\tdecimal = decimal || '.';\r\n\t\t\t\tif (splitValue.length > 1) {\r\n\t\t\t\t\tformatted = formatted + decimal + splitValue[1];\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\treturn formatted;\r\n\t\t},\r\n\r\n\t\t// @method readableArea(area, isMetric, precision): string\r\n\t\t// Returns a readable area string in yards or metric.\r\n\t\t// The value will be rounded as defined by the precision option object.\r\n\t\treadableArea: function (area, isMetric, precision) {\r\n\t\t\tvar areaStr,\r\n\t\t\t\tunits,\r\n\t\t\t\tprecision = L.Util.extend({}, defaultPrecision, precision);\r\n\r\n\t\t\tif (isMetric) {\r\n\t\t\t\tunits = ['ha', 'm'];\r\n\t\t\t\ttype = typeof isMetric;\r\n\t\t\t\tif (type === 'string') {\r\n\t\t\t\t\tunits = [isMetric];\r\n\t\t\t\t} else if (type !== 'boolean') {\r\n\t\t\t\t\tunits = isMetric;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif (area >= 1000000 && units.indexOf('km') !== -1) {\r\n\t\t\t\t\tareaStr = L.GeometryUtil.formattedNumber(area * 0.000001, precision['km']) + ' km²';\r\n\t\t\t\t} else if (area >= 10000 && units.indexOf('ha') !== -1) {\r\n\t\t\t\t\tareaStr = L.GeometryUtil.formattedNumber(area * 0.0001, precision['ha']) + ' ha';\r\n\t\t\t\t} else {\r\n\t\t\t\t\tareaStr = L.GeometryUtil.formattedNumber(area, precision['m']) + ' m²';\r\n\t\t\t\t}\r\n\t\t\t} else {\r\n\t\t\t\tarea /= 0.836127; // Square yards in 1 meter\r\n\r\n\t\t\t\tif (area >= 3097600) { //3097600 square yards in 1 square mile\r\n\t\t\t\t\tareaStr = L.GeometryUtil.formattedNumber(area / 3097600, precision['mi']) + ' mi²';\r\n\t\t\t\t} else if (area >= 4840) { //4840 square yards in 1 acre\r\n\t\t\t\t\tareaStr = L.GeometryUtil.formattedNumber(area / 4840, precision['ac']) + ' acres';\r\n\t\t\t\t} else {\r\n\t\t\t\t\tareaStr = L.GeometryUtil.formattedNumber(area, precision['yd']) + ' yd²';\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\treturn areaStr;\r\n\t\t},\r\n\r\n\t\t// @method readableDistance(distance, units): string\r\n\t\t// Converts a metric distance to one of [ feet, nauticalMile, metric or yards ] string\r\n\t\t//\r\n\t\t// @alternative\r\n\t\t// @method readableDistance(distance, isMetric, useFeet, isNauticalMile, precision): string\r\n\t\t// Converts metric distance to distance string.\r\n\t\t// The value will be rounded as defined by the precision option object.\r\n\t\treadableDistance: function (distance, isMetric, isFeet, isNauticalMile, precision) {\r\n\t\t\tvar distanceStr,\r\n\t\t\t\tunits,\r\n\t\t\t\tprecision = L.Util.extend({}, defaultPrecision, precision);\r\n\r\n\t\t\tif (isMetric) {\r\n\t\t\t\tunits = typeof isMetric == 'string' ? isMetric : 'metric';\r\n\t\t\t} else if (isFeet) {\r\n\t\t\t\tunits = 'feet';\r\n\t\t\t} else if (isNauticalMile) {\r\n\t\t\t\tunits = 'nauticalMile';\r\n\t\t\t} else {\r\n\t\t\t\tunits = 'yards';\r\n\t\t\t}\r\n\r\n\t\t\tswitch (units) {\r\n\t\t\t\tcase 'metric':\r\n\t\t\t\t\t// show metres when distance is < 1km, then show km\r\n\t\t\t\t\tif (distance > 1000) {\r\n\t\t\t\t\t\tdistanceStr = L.GeometryUtil.formattedNumber(distance / 1000, precision['km']) + ' km';\r\n\t\t\t\t\t} else {\r\n\t\t\t\t\t\tdistanceStr = L.GeometryUtil.formattedNumber(distance, precision['m']) + ' m';\r\n\t\t\t\t\t}\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase 'feet':\r\n\t\t\t\t\tdistance *= 1.09361 * 3;\r\n\t\t\t\t\tdistanceStr = L.GeometryUtil.formattedNumber(distance, precision['ft']) + ' ft';\r\n\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase 'nauticalMile':\r\n\t\t\t\t\tdistance *= 0.53996;\r\n\t\t\t\t\tdistanceStr = L.GeometryUtil.formattedNumber(distance / 1000, precision['nm']) + ' nm';\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase 'yards':\r\n\t\t\t\tdefault:\r\n\t\t\t\t\tdistance *= 1.09361;\r\n\r\n\t\t\t\t\tif (distance > 1760) {\r\n\t\t\t\t\t\tdistanceStr = L.GeometryUtil.formattedNumber(distance / 1760, precision['mi']) + ' miles';\r\n\t\t\t\t\t} else {\r\n\t\t\t\t\t\tdistanceStr = L.GeometryUtil.formattedNumber(distance, precision['yd']) + ' yd';\r\n\t\t\t\t\t}\r\n\t\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t\treturn distanceStr;\r\n\t\t},\r\n\r\n\t\t// @method isVersion07x(): boolean\r\n\t\t// Returns true if the Leaflet version is 0.7.x, false otherwise.\r\n\t\tisVersion07x: function () {\r\n\t\t\tvar version = L.version.split('.');\r\n\t\t\t//If Version is == 0.7.*\r\n\t\t\treturn parseInt(version[0], 10) === 0 && parseInt(version[1], 10) === 7;\r\n\t\t},\r\n\t});\r\n\r\n})();\r\n","/**\r\n * @class L.LineUtil\r\n * @aka Util\r\n * @aka L.Utils\r\n */\r\nL.Util.extend(L.LineUtil, {\r\n\r\n\t// @method segmentsIntersect(): boolean\r\n\t// Checks to see if two line segments intersect. Does not handle degenerate cases.\r\n\t// http://compgeom.cs.uiuc.edu/~jeffe/teaching/373/notes/x06-sweepline.pdf\r\n\tsegmentsIntersect: function (/*Point*/ p, /*Point*/ p1, /*Point*/ p2, /*Point*/ p3) {\r\n\t\treturn this._checkCounterclockwise(p, p2, p3) !==\r\n\t\t\tthis._checkCounterclockwise(p1, p2, p3) &&\r\n\t\t\tthis._checkCounterclockwise(p, p1, p2) !==\r\n\t\t\tthis._checkCounterclockwise(p, p1, p3);\r\n\t},\r\n\r\n\t// check to see if points are in counterclockwise order\r\n\t_checkCounterclockwise: function (/*Point*/ p, /*Point*/ p1, /*Point*/ p2) {\r\n\t\treturn (p2.y - p.y) * (p1.x - p.x) > (p1.y - p.y) * (p2.x - p.x);\r\n\t}\r\n});\r\n","/**\r\n * @class L.Polyline\r\n * @aka Polyline\r\n */\r\nL.Polyline.include({\r\n\r\n\t// @method intersects(): boolean\r\n\t// Check to see if this polyline has any linesegments that intersect.\r\n\t// NOTE: does not support detecting intersection for degenerate cases.\r\n\tintersects: function () {\r\n\t\tvar points = this._getProjectedPoints(),\r\n\t\t\tlen = points ? points.length : 0,\r\n\t\t\ti, p, p1;\r\n\r\n\t\tif (this._tooFewPointsForIntersection()) {\r\n\t\t\treturn false;\r\n\t\t}\r\n\r\n\t\tfor (i = len - 1; i >= 3; i--) {\r\n\t\t\tp = points[i - 1];\r\n\t\t\tp1 = points[i];\r\n\r\n\r\n\t\t\tif (this._lineSegmentsIntersectsRange(p, p1, i - 2)) {\r\n\t\t\t\treturn true;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn false;\r\n\t},\r\n\r\n\t// @method newLatLngIntersects(): boolean\r\n\t// Check for intersection if new latlng was added to this polyline.\r\n\t// NOTE: does not support detecting intersection for degenerate cases.\r\n\tnewLatLngIntersects: function (latlng, skipFirst) {\r\n\t\t// Cannot check a polyline for intersecting lats/lngs when not added to the map\r\n\t\tif (!this._map) {\r\n\t\t\treturn false;\r\n\t\t}\r\n\r\n\t\treturn this.newPointIntersects(this._map.latLngToLayerPoint(latlng), skipFirst);\r\n\t},\r\n\r\n\t// @method newPointIntersects(): boolean\r\n\t// Check for intersection if new point was added to this polyline.\r\n\t// newPoint must be a layer point.\r\n\t// NOTE: does not support detecting intersection for degenerate cases.\r\n\tnewPointIntersects: function (newPoint, skipFirst) {\r\n\t\tvar points = this._getProjectedPoints(),\r\n\t\t\tlen = points ? points.length : 0,\r\n\t\t\tlastPoint = points ? points[len - 1] : null,\r\n\t\t\t// The previous previous line segment. Previous line segment doesn't need testing.\r\n\t\t\tmaxIndex = len - 2;\r\n\r\n\t\tif (this._tooFewPointsForIntersection(1)) {\r\n\t\t\treturn false;\r\n\t\t}\r\n\r\n\t\treturn this._lineSegmentsIntersectsRange(lastPoint, newPoint, maxIndex, skipFirst ? 1 : 0);\r\n\t},\r\n\r\n\t// Polylines with 2 sides can only intersect in cases where points are collinear (we don't support detecting these).\r\n\t// Cannot have intersection when < 3 line segments (< 4 points)\r\n\t_tooFewPointsForIntersection: function (extraPoints) {\r\n\t\tvar points = this._getProjectedPoints(),\r\n\t\t\tlen = points ? points.length : 0;\r\n\t\t// Increment length by extraPoints if present\r\n\t\tlen += extraPoints || 0;\r\n\r\n\t\treturn !points || len <= 3;\r\n\t},\r\n\r\n\t// Checks a line segment intersections with any line segments before its predecessor.\r\n\t// Don't need to check the predecessor as will never intersect.\r\n\t_lineSegmentsIntersectsRange: function (p, p1, maxIndex, minIndex) {\r\n\t\tvar points = this._getProjectedPoints(),\r\n\t\t\tp2, p3;\r\n\r\n\t\tminIndex = minIndex || 0;\r\n\r\n\t\t// Check all previous line segments (beside the immediately previous) for intersections\r\n\t\tfor (var j = maxIndex; j > minIndex; j--) {\r\n\t\t\tp2 = points[j - 1];\r\n\t\t\tp3 = points[j];\r\n\r\n\t\t\tif (L.LineUtil.segmentsIntersect(p, p1, p2, p3)) {\r\n\t\t\t\treturn true;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn false;\r\n\t},\r\n\r\n\t_getProjectedPoints: function () {\r\n\t\tif (!this._defaultShape) {\r\n\t\t\treturn this._originalPoints;\r\n\t\t}\r\n\t\tvar points = [],\r\n\t\t\t_shape = this._defaultShape();\r\n\r\n\t\tfor (var i = 0; i < _shape.length; i++) {\r\n\t\t\tpoints.push(this._map.latLngToLayerPoint(_shape[i]));\r\n\t\t}\r\n\t\treturn points;\r\n\t}\r\n});\r\n","/**\r\n * @class L.Polygon\r\n * @aka Polygon\r\n */\r\nL.Polygon.include({\r\n\r\n\t// @method intersects(): boolean\r\n\t// Checks a polygon for any intersecting line segments. Ignores holes.\r\n\tintersects: function () {\r\n\t\tvar polylineIntersects,\r\n\t\t\tpoints = this._getProjectedPoints(),\r\n\t\t\tlen, firstPoint, lastPoint, maxIndex;\r\n\r\n\t\tif (this._tooFewPointsForIntersection()) {\r\n\t\t\treturn false;\r\n\t\t}\r\n\r\n\t\tpolylineIntersects = L.Polyline.prototype.intersects.call(this);\r\n\r\n\t\t// If already found an intersection don't need to check for any more.\r\n\t\tif (polylineIntersects) {\r\n\t\t\treturn true;\r\n\t\t}\r\n\r\n\t\tlen = points.length;\r\n\t\tfirstPoint = points[0];\r\n\t\tlastPoint = points[len - 1];\r\n\t\tmaxIndex = len - 2;\r\n\r\n\t\t// Check the line segment between last and first point. Don't need to check the first line segment (minIndex = 1)\r\n\t\treturn this._lineSegmentsIntersectsRange(lastPoint, firstPoint, maxIndex, 1);\r\n\t}\r\n});\r\n","/**\r\n * @class L.Control.Draw\r\n * @aka L.Draw\r\n */\r\nL.Control.Draw = L.Control.extend({\r\n\r\n\t// Options\r\n\toptions: {\r\n\t\tposition: 'topleft',\r\n\t\tdraw: {},\r\n\t\tedit: false\r\n\t},\r\n\r\n\t// @method initialize(): void\r\n\t// Initializes draw control, toolbars from the options\r\n\tinitialize: function (options) {\r\n\t\tif (L.version < '0.7') {\r\n\t\t\tthrow new Error('Leaflet.draw 0.2.3+ requires Leaflet 0.7.0+. Download latest from https://github.com/Leaflet/Leaflet/');\r\n\t\t}\r\n\r\n\t\tL.Control.prototype.initialize.call(this, options);\r\n\r\n\t\tvar toolbar;\r\n\r\n\t\tthis._toolbars = {};\r\n\r\n\t\t// Initialize toolbars\r\n\t\tif (L.DrawToolbar && this.options.draw) {\r\n\t\t\ttoolbar = new L.DrawToolbar(this.options.draw);\r\n\r\n\t\t\tthis._toolbars[L.DrawToolbar.TYPE] = toolbar;\r\n\r\n\t\t\t// Listen for when toolbar is enabled\r\n\t\t\tthis._toolbars[L.DrawToolbar.TYPE].on('enable', this._toolbarEnabled, this);\r\n\t\t}\r\n\r\n\t\tif (L.EditToolbar && this.options.edit) {\r\n\t\t\ttoolbar = new L.EditToolbar(this.options.edit);\r\n\r\n\t\t\tthis._toolbars[L.EditToolbar.TYPE] = toolbar;\r\n\r\n\t\t\t// Listen for when toolbar is enabled\r\n\t\t\tthis._toolbars[L.EditToolbar.TYPE].on('enable', this._toolbarEnabled, this);\r\n\t\t}\r\n\t\tL.toolbar = this; //set global var for editing the toolbar\r\n\t},\r\n\r\n\t// @method onAdd(): container\r\n\t// Adds the toolbar container to the map\r\n\tonAdd: function (map) {\r\n\t\tvar container = L.DomUtil.create('div', 'leaflet-draw'),\r\n\t\t\taddedTopClass = false,\r\n\t\t\ttopClassName = 'leaflet-draw-toolbar-top',\r\n\t\t\ttoolbarContainer;\r\n\r\n\t\tfor (var toolbarId in this._toolbars) {\r\n\t\t\tif (this._toolbars.hasOwnProperty(toolbarId)) {\r\n\t\t\t\ttoolbarContainer = this._toolbars[toolbarId].addToolbar(map);\r\n\r\n\t\t\t\tif (toolbarContainer) {\r\n\t\t\t\t\t// Add class to the first toolbar to remove the margin\r\n\t\t\t\t\tif (!addedTopClass) {\r\n\t\t\t\t\t\tif (!L.DomUtil.hasClass(toolbarContainer, topClassName)) {\r\n\t\t\t\t\t\t\tL.DomUtil.addClass(toolbarContainer.childNodes[0], topClassName);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\taddedTopClass = true;\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tcontainer.appendChild(toolbarContainer);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn container;\r\n\t},\r\n\r\n\t// @method onRemove(): void\r\n\t// Removes the toolbars from the map toolbar container\r\n\tonRemove: function () {\r\n\t\tfor (var toolbarId in this._toolbars) {\r\n\t\t\tif (this._toolbars.hasOwnProperty(toolbarId)) {\r\n\t\t\t\tthis._toolbars[toolbarId].removeToolbar();\r\n\t\t\t}\r\n\t\t}\r\n\t},\r\n\r\n\t// @method setDrawingOptions(options): void\r\n\t// Sets options to all toolbar instances\r\n\tsetDrawingOptions: function (options) {\r\n\t\tfor (var toolbarId in this._toolbars) {\r\n\t\t\tif (this._toolbars[toolbarId] instanceof L.DrawToolbar) {\r\n\t\t\t\tthis._toolbars[toolbarId].setOptions(options);\r\n\t\t\t}\r\n\t\t}\r\n\t},\r\n\r\n\t_toolbarEnabled: function (e) {\r\n\t\tvar enabledToolbar = e.target;\r\n\r\n\t\tfor (var toolbarId in this._toolbars) {\r\n\t\t\tif (this._toolbars[toolbarId] !== enabledToolbar) {\r\n\t\t\t\tthis._toolbars[toolbarId].disable();\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n});\r\n\r\nL.Map.mergeOptions({\r\n\tdrawControlTooltips: true,\r\n\tdrawControl: false\r\n});\r\n\r\nL.Map.addInitHook(function () {\r\n\tif (this.options.drawControl) {\r\n\t\tthis.drawControl = new L.Control.Draw();\r\n\t\tthis.addControl(this.drawControl);\r\n\t}\r\n});\r\n","/**\r\n * @class L.Draw.Toolbar\r\n * @aka Toolbar\r\n *\r\n * The toolbar class of the API — it is used to create the ui\r\n * This will be depreciated\r\n *\r\n * @example\r\n *\r\n * ```js\r\n * var toolbar = L.Toolbar();\r\n * toolbar.addToolbar(map);\r\n * ```\r\n *\r\n * ### Disabling a toolbar\r\n *\r\n * If you do not want a particular toolbar in your app you can turn it off by setting the toolbar to false.\r\n *\r\n * ```js\r\n * var drawControl = new L.Control.Draw({\r\n * draw: false,\r\n * edit: {\r\n * featureGroup: editableLayers\r\n * }\r\n * });\r\n * ```\r\n *\r\n * ### Disabling a toolbar item\r\n *\r\n * If you want to turn off a particular toolbar item, set it to false. The following disables drawing polygons and\r\n * markers. It also turns off the ability to edit layers.\r\n *\r\n * ```js\r\n * var drawControl = new L.Control.Draw({\r\n * draw: {\r\n * polygon: false,\r\n * marker: false\r\n * },\r\n * edit: {\r\n * featureGroup: editableLayers,\r\n * edit: false\r\n * }\r\n * });\r\n * ```\r\n */\r\nL.Toolbar = L.Class.extend({\r\n\t// @section Methods for modifying the toolbar\r\n\r\n\t// @method initialize(options): void\r\n\t// Toolbar constructor\r\n\tinitialize: function (options) {\r\n\t\tL.setOptions(this, options);\r\n\r\n\t\tthis._modes = {};\r\n\t\tthis._actionButtons = [];\r\n\t\tthis._activeMode = null;\r\n\r\n\t\tvar version = L.version.split('.');\r\n\t\t//If Version is >= 1.2.0\r\n\t\tif (parseInt(version[0], 10) === 1 && parseInt(version[1], 10) >= 2) {\r\n\t\t\tL.Toolbar.include(L.Evented.prototype);\r\n\t\t} else {\r\n\t\t\tL.Toolbar.include(L.Mixin.Events);\r\n\t\t}\r\n\t},\r\n\r\n\t// @method enabled(): boolean\r\n\t// Gets a true/false of whether the toolbar is enabled\r\n\tenabled: function () {\r\n\t\treturn this._activeMode !== null;\r\n\t},\r\n\r\n\t// @method disable(): void\r\n\t// Disables the toolbar\r\n\tdisable: function () {\r\n\t\tif (!this.enabled()) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tthis._activeMode.handler.disable();\r\n\t},\r\n\r\n\t// @method addToolbar(map): L.DomUtil\r\n\t// Adds the toolbar to the map and returns the toolbar dom element\r\n\taddToolbar: function (map) {\r\n\t\tvar container = L.DomUtil.create('div', 'leaflet-draw-section'),\r\n\t\t\tbuttonIndex = 0,\r\n\t\t\tbuttonClassPrefix = this._toolbarClass || '',\r\n\t\t\tmodeHandlers = this.getModeHandlers(map),\r\n\t\t\ti;\r\n\r\n\t\tthis._toolbarContainer = L.DomUtil.create('div', 'leaflet-draw-toolbar leaflet-bar');\r\n\t\tthis._map = map;\r\n\r\n\t\tfor (i = 0; i < modeHandlers.length; i++) {\r\n\t\t\tif (modeHandlers[i].enabled) {\r\n\t\t\t\tthis._initModeHandler(\r\n\t\t\t\t\tmodeHandlers[i].handler,\r\n\t\t\t\t\tthis._toolbarContainer,\r\n\t\t\t\t\tbuttonIndex++,\r\n\t\t\t\t\tbuttonClassPrefix,\r\n\t\t\t\t\tmodeHandlers[i].title\r\n\t\t\t\t);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// if no buttons were added, do not add the toolbar\r\n\t\tif (!buttonIndex) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\t// Save button index of the last button, -1 as we would have ++ after the last button\r\n\t\tthis._lastButtonIndex = --buttonIndex;\r\n\r\n\t\t// Create empty actions part of the toolbar\r\n\t\tthis._actionsContainer = L.DomUtil.create('ul', 'leaflet-draw-actions');\r\n\r\n\t\t// Add draw and cancel containers to the control container\r\n\t\tcontainer.appendChild(this._toolbarContainer);\r\n\t\tcontainer.appendChild(this._actionsContainer);\r\n\r\n\t\treturn container;\r\n\t},\r\n\r\n\t// @method removeToolbar(): void\r\n\t// Removes the toolbar and drops the handler event listeners\r\n\tremoveToolbar: function () {\r\n\t\t// Dispose each handler\r\n\t\tfor (var handlerId in this._modes) {\r\n\t\t\tif (this._modes.hasOwnProperty(handlerId)) {\r\n\t\t\t\t// Unbind handler button\r\n\t\t\t\tthis._disposeButton(\r\n\t\t\t\t\tthis._modes[handlerId].button,\r\n\t\t\t\t\tthis._modes[handlerId].handler.enable,\r\n\t\t\t\t\tthis._modes[handlerId].handler\r\n\t\t\t\t);\r\n\r\n\t\t\t\t// Make sure is disabled\r\n\t\t\t\tthis._modes[handlerId].handler.disable();\r\n\r\n\t\t\t\t// Unbind handler\r\n\t\t\t\tthis._modes[handlerId].handler\r\n\t\t\t\t\t.off('enabled', this._handlerActivated, this)\r\n\t\t\t\t\t.off('disabled', this._handlerDeactivated, this);\r\n\t\t\t}\r\n\t\t}\r\n\t\tthis._modes = {};\r\n\r\n\t\t// Dispose the actions toolbar\r\n\t\tfor (var i = 0, l = this._actionButtons.length; i < l; i++) {\r\n\t\t\tthis._disposeButton(\r\n\t\t\t\tthis._actionButtons[i].button,\r\n\t\t\t\tthis._actionButtons[i].callback,\r\n\t\t\t\tthis\r\n\t\t\t);\r\n\t\t}\r\n\t\tthis._actionButtons = [];\r\n\t\tthis._actionsContainer = null;\r\n\t},\r\n\r\n\t_initModeHandler: function (handler, container, buttonIndex, classNamePredix, buttonTitle) {\r\n\t\tvar type = handler.type;\r\n\r\n\t\tthis._modes[type] = {};\r\n\r\n\t\tthis._modes[type].handler = handler;\r\n\r\n\t\tthis._modes[type].button = this._createButton({\r\n\t\t\ttype: type,\r\n\t\t\ttitle: buttonTitle,\r\n\t\t\tclassName: classNamePredix + '-' + type,\r\n\t\t\tcontainer: container,\r\n\t\t\tcallback: this._modes[type].handler.enable,\r\n\t\t\tcontext: this._modes[type].handler\r\n\t\t});\r\n\r\n\t\tthis._modes[type].buttonIndex = buttonIndex;\r\n\r\n\t\tthis._modes[type].handler\r\n\t\t\t.on('enabled', this._handlerActivated, this)\r\n\t\t\t.on('disabled', this._handlerDeactivated, this);\r\n\t},\r\n\r\n\t/* Detect iOS based on browser User Agent, based on:\r\n\t * http://stackoverflow.com/a/9039885 */\r\n\t_detectIOS: function () {\r\n\t\tvar iOS = (/iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream);\r\n\t\treturn iOS;\r\n\t},\r\n\r\n\t_createButton: function (options) {\r\n\r\n\t\tvar link = L.DomUtil.create('a', options.className || '', options.container);\r\n\t\t// Screen reader tag\r\n\t\tvar sr = L.DomUtil.create('span', 'sr-only', options.container);\r\n\r\n\t\tlink.href = '#';\r\n\t\tlink.appendChild(sr);\r\n\r\n\t\tif (options.title) {\r\n\t\t\tlink.title = options.title;\r\n\t\t\tsr.innerHTML = options.title;\r\n\t\t}\r\n\r\n\t\tif (options.text) {\r\n\t\t\tlink.innerHTML = options.text;\r\n\t\t\tsr.innerHTML = options.text;\r\n\t\t}\r\n\r\n\t\t/* iOS does not use click events */\r\n\t\tvar buttonEvent = this._detectIOS() ? 'touchstart' : 'click';\r\n\r\n\t\tL.DomEvent\r\n\t\t\t.on(link, 'click', L.DomEvent.stopPropagation)\r\n\t\t\t.on(link, 'mousedown', L.DomEvent.stopPropagation)\r\n\t\t\t.on(link, 'dblclick', L.DomEvent.stopPropagation)\r\n\t\t\t.on(link, 'touchstart', L.DomEvent.stopPropagation)\r\n\t\t\t.on(link, 'click', L.DomEvent.preventDefault)\r\n\t\t\t.on(link, buttonEvent, options.callback, options.context);\r\n\r\n\t\treturn link;\r\n\t},\r\n\r\n\t_disposeButton: function (button, callback) {\r\n\t\t/* iOS does not use click events */\r\n\t\tvar buttonEvent = this._detectIOS() ? 'touchstart' : 'click';\r\n\r\n\t\tL.DomEvent\r\n\t\t\t.off(button, 'click', L.DomEvent.stopPropagation)\r\n\t\t\t.off(button, 'mousedown', L.DomEvent.stopPropagation)\r\n\t\t\t.off(button, 'dblclick', L.DomEvent.stopPropagation)\r\n\t\t\t.off(button, 'touchstart', L.DomEvent.stopPropagation)\r\n\t\t\t.off(button, 'click', L.DomEvent.preventDefault)\r\n\t\t\t.off(button, buttonEvent, callback);\r\n\t},\r\n\r\n\t_handlerActivated: function (e) {\r\n\t\t// Disable active mode (if present)\r\n\t\tthis.disable();\r\n\r\n\t\t// Cache new active feature\r\n\t\tthis._activeMode = this._modes[e.handler];\r\n\r\n\t\tL.DomUtil.addClass(this._activeMode.button, 'leaflet-draw-toolbar-button-enabled');\r\n\r\n\t\tthis._showActionsToolbar();\r\n\r\n\t\tthis.fire('enable');\r\n\t},\r\n\r\n\t_handlerDeactivated: function () {\r\n\t\tthis._hideActionsToolbar();\r\n\r\n\t\tL.DomUtil.removeClass(this._activeMode.button, 'leaflet-draw-toolbar-button-enabled');\r\n\r\n\t\tthis._activeMode = null;\r\n\r\n\t\tthis.fire('disable');\r\n\t},\r\n\r\n\t_createActions: function (handler) {\r\n\t\tvar container = this._actionsContainer,\r\n\t\t\tbuttons = this.getActions(handler),\r\n\t\t\tl = buttons.length,\r\n\t\t\tli, di, dl, button;\r\n\r\n\t\t// Dispose the actions toolbar (todo: dispose only not used buttons)\r\n\t\tfor (di = 0, dl = this._actionButtons.length; di < dl; di++) {\r\n\t\t\tthis._disposeButton(this._actionButtons[di].button, this._actionButtons[di].callback);\r\n\t\t}\r\n\t\tthis._actionButtons = [];\r\n\r\n\t\t// Remove all old buttons\r\n\t\twhile (container.firstChild) {\r\n\t\t\tcontainer.removeChild(container.firstChild);\r\n\t\t}\r\n\r\n\t\tfor (var i = 0; i < l; i++) {\r\n\t\t\tif ('enabled' in buttons[i] && !buttons[i].enabled) {\r\n\t\t\t\tcontinue;\r\n\t\t\t}\r\n\r\n\t\t\tli = L.DomUtil.create('li', '', container);\r\n\r\n\t\t\tbutton = this._createButton({\r\n\t\t\t\ttitle: buttons[i].title,\r\n\t\t\t\ttext: buttons[i].text,\r\n\t\t\t\tcontainer: li,\r\n\t\t\t\tcallback: buttons[i].callback,\r\n\t\t\t\tcontext: buttons[i].context\r\n\t\t\t});\r\n\r\n\t\t\tthis._actionButtons.push({\r\n\t\t\t\tbutton: button,\r\n\t\t\t\tcallback: buttons[i].callback\r\n\t\t\t});\r\n\t\t}\r\n\t},\r\n\r\n\t_showActionsToolbar: function () {\r\n\t\tvar buttonIndex = this._activeMode.buttonIndex,\r\n\t\t\tlastButtonIndex = this._lastButtonIndex,\r\n\t\t\ttoolbarPosition = this._activeMode.button.offsetTop - 1;\r\n\r\n\t\t// Recreate action buttons on every click\r\n\t\tthis._createActions(this._activeMode.handler);\r\n\r\n\t\t// Correctly position the cancel button\r\n\t\tthis._actionsContainer.style.top = toolbarPosition + 'px';\r\n\r\n\t\tif (buttonIndex === 0) {\r\n\t\t\tL.DomUtil.addClass(this._toolbarContainer, 'leaflet-draw-toolbar-notop');\r\n\t\t\tL.DomUtil.addClass(this._actionsContainer, 'leaflet-draw-actions-top');\r\n\t\t}\r\n\r\n\t\tif (buttonIndex === lastButtonIndex) {\r\n\t\t\tL.DomUtil.addClass(this._toolbarContainer, 'leaflet-draw-toolbar-nobottom');\r\n\t\t\tL.DomUtil.addClass(this._actionsContainer, 'leaflet-draw-actions-bottom');\r\n\t\t}\r\n\r\n\t\tthis._actionsContainer.style.display = 'block';\r\n\t\tthis._map.fire(L.Draw.Event.TOOLBAROPENED);\r\n\t},\r\n\r\n\t_hideActionsToolbar: function () {\r\n\t\tthis._actionsContainer.style.display = 'none';\r\n\r\n\t\tL.DomUtil.removeClass(this._toolbarContainer, 'leaflet-draw-toolbar-notop');\r\n\t\tL.DomUtil.removeClass(this._toolbarContainer, 'leaflet-draw-toolbar-nobottom');\r\n\t\tL.DomUtil.removeClass(this._actionsContainer, 'leaflet-draw-actions-top');\r\n\t\tL.DomUtil.removeClass(this._actionsContainer, 'leaflet-draw-actions-bottom');\r\n\t\tthis._map.fire(L.Draw.Event.TOOLBARCLOSED);\r\n\t}\r\n});\r\n","L.Draw = L.Draw || {};\r\n/**\r\n * @class L.Draw.Tooltip\r\n * @aka Tooltip\r\n *\r\n * The tooltip class — it is used to display the tooltip while drawing\r\n * This will be depreciated\r\n *\r\n * @example\r\n *\r\n * ```js\r\n * var tooltip = L.Draw.Tooltip();\r\n * ```\r\n *\r\n */\r\nL.Draw.Tooltip = L.Class.extend({\r\n\r\n\t// @section Methods for modifying draw state\r\n\r\n\t// @method initialize(map): void\r\n\t// Tooltip constructor\r\n\tinitialize: function (map) {\r\n\t\tthis._map = map;\r\n\t\tthis._popupPane = map._panes.popupPane;\r\n\t\tthis._visible = false;\r\n\r\n\t\tthis._container = map.options.drawControlTooltips ?\r\n\t\t\tL.DomUtil.create('div', 'leaflet-draw-tooltip', this._popupPane) : null;\r\n\t\tthis._singleLineLabel = false;\r\n\r\n\t\tthis._map.on('mouseout', this._onMouseOut, this);\r\n\t},\r\n\r\n\t// @method dispose(): void\r\n\t// Remove Tooltip DOM and unbind events\r\n\tdispose: function () {\r\n\t\tthis._map.off('mouseout', this._onMouseOut, this);\r\n\r\n\t\tif (this._container) {\r\n\t\t\tthis._popupPane.removeChild(this._container);\r\n\t\t\tthis._container = null;\r\n\t\t}\r\n\t},\r\n\r\n\t// @method updateContent(labelText): this\r\n\t// Changes the tooltip text to string in function call\r\n\tupdateContent: function (labelText) {\r\n\t\tif (!this._container) {\r\n\t\t\treturn this;\r\n\t\t}\r\n\t\tlabelText.subtext = labelText.subtext || '';\r\n\r\n\t\t// update the vertical position (only if changed)\r\n\t\tif (labelText.subtext.length === 0 && !this._singleLineLabel) {\r\n\t\t\tL.DomUtil.addClass(this._container, 'leaflet-draw-tooltip-single');\r\n\t\t\tthis._singleLineLabel = true;\r\n\t\t}\r\n\t\telse if (labelText.subtext.length > 0 && this._singleLineLabel) {\r\n\t\t\tL.DomUtil.removeClass(this._container, 'leaflet-draw-tooltip-single');\r\n\t\t\tthis._singleLineLabel = false;\r\n\t\t}\r\n\r\n\t\tthis._container.innerHTML =\r\n\t\t\t(labelText.subtext.length > 0 ?\r\n\t\t\t\t'' + labelText.subtext + '' + '
' : '') +\r\n\t\t\t'' + labelText.text + '';\r\n\r\n\t\tif (!labelText.text && !labelText.subtext) {\r\n\t\t\tthis._visible = false;\r\n\t\t\tthis._container.style.visibility = 'hidden';\r\n\t\t} else {\r\n\t\t\tthis._visible = true;\r\n\t\t\tthis._container.style.visibility = 'inherit';\r\n\t\t}\r\n\r\n\t\treturn this;\r\n\t},\r\n\r\n\t// @method updatePosition(latlng): this\r\n\t// Changes the location of the tooltip\r\n\tupdatePosition: function (latlng) {\r\n\t\tvar pos = this._map.latLngToLayerPoint(latlng),\r\n\t\t\ttooltipContainer = this._container;\r\n\r\n\t\tif (this._container) {\r\n\t\t\tif (this._visible) {\r\n\t\t\t\ttooltipContainer.style.visibility = 'inherit';\r\n\t\t\t}\r\n\t\t\tL.DomUtil.setPosition(tooltipContainer, pos);\r\n\t\t}\r\n\r\n\t\treturn this;\r\n\t},\r\n\r\n\t// @method showAsError(): this\r\n\t// Applies error class to tooltip\r\n\tshowAsError: function () {\r\n\t\tif (this._container) {\r\n\t\t\tL.DomUtil.addClass(this._container, 'leaflet-error-draw-tooltip');\r\n\t\t}\r\n\t\treturn this;\r\n\t},\r\n\r\n\t// @method removeError(): this\r\n\t// Removes the error class from the tooltip\r\n\tremoveError: function () {\r\n\t\tif (this._container) {\r\n\t\t\tL.DomUtil.removeClass(this._container, 'leaflet-error-draw-tooltip');\r\n\t\t}\r\n\t\treturn this;\r\n\t},\r\n\r\n\t_onMouseOut: function () {\r\n\t\tif (this._container) {\r\n\t\t\tthis._container.style.visibility = 'hidden';\r\n\t\t}\r\n\t}\r\n});\r\n","/**\r\n * @class L.DrawToolbar\r\n * @aka Toolbar\r\n */\r\nL.DrawToolbar = L.Toolbar.extend({\r\n\r\n\tstatics: {\r\n\t\tTYPE: 'draw'\r\n\t},\r\n\r\n\toptions: {\r\n\t\tpolyline: {},\r\n\t\tpolygon: {},\r\n\t\trectangle: {},\r\n\t\tcircle: {},\r\n\t\tmarker: {},\r\n\t\tcirclemarker: {}\r\n\t},\r\n\r\n\t// @method initialize(): void\r\n\tinitialize: function (options) {\r\n\t\t// Ensure that the options are merged correctly since L.extend is only shallow\r\n\t\tfor (var type in this.options) {\r\n\t\t\tif (this.options.hasOwnProperty(type)) {\r\n\t\t\t\tif (options[type]) {\r\n\t\t\t\t\toptions[type] = L.extend({}, this.options[type], options[type]);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tthis._toolbarClass = 'leaflet-draw-draw';\r\n\t\tL.Toolbar.prototype.initialize.call(this, options);\r\n\t},\r\n\r\n\t// @method getModeHandlers(): object\r\n\t// Get mode handlers information\r\n\tgetModeHandlers: function (map) {\r\n\t\treturn [\r\n\t\t\t{\r\n\t\t\t\tenabled: this.options.polyline,\r\n\t\t\t\thandler: new L.Draw.Polyline(map, this.options.polyline),\r\n\t\t\t\ttitle: L.drawLocal.draw.toolbar.buttons.polyline\r\n\t\t\t},\r\n\t\t\t{\r\n\t\t\t\tenabled: this.options.polygon,\r\n\t\t\t\thandler: new L.Draw.Polygon(map, this.options.polygon),\r\n\t\t\t\ttitle: L.drawLocal.draw.toolbar.buttons.polygon\r\n\t\t\t},\r\n\t\t\t{\r\n\t\t\t\tenabled: this.options.rectangle,\r\n\t\t\t\thandler: new L.Draw.Rectangle(map, this.options.rectangle),\r\n\t\t\t\ttitle: L.drawLocal.draw.toolbar.buttons.rectangle\r\n\t\t\t},\r\n\t\t\t{\r\n\t\t\t\tenabled: this.options.circle,\r\n\t\t\t\thandler: new L.Draw.Circle(map, this.options.circle),\r\n\t\t\t\ttitle: L.drawLocal.draw.toolbar.buttons.circle\r\n\t\t\t},\r\n\t\t\t{\r\n\t\t\t\tenabled: this.options.marker,\r\n\t\t\t\thandler: new L.Draw.Marker(map, this.options.marker),\r\n\t\t\t\ttitle: L.drawLocal.draw.toolbar.buttons.marker\r\n\t\t\t},\r\n\t\t\t{\r\n\t\t\t\tenabled: this.options.circlemarker,\r\n\t\t\t\thandler: new L.Draw.CircleMarker(map, this.options.circlemarker),\r\n\t\t\t\ttitle: L.drawLocal.draw.toolbar.buttons.circlemarker\r\n\t\t\t}\r\n\t\t];\r\n\t},\r\n\r\n\t// @method getActions(): object\r\n\t// Get action information\r\n\tgetActions: function (handler) {\r\n\t\treturn [\r\n\t\t\t{\r\n\t\t\t\tenabled: handler.completeShape,\r\n\t\t\t\ttitle: L.drawLocal.draw.toolbar.finish.title,\r\n\t\t\t\ttext: L.drawLocal.draw.toolbar.finish.text,\r\n\t\t\t\tcallback: handler.completeShape,\r\n\t\t\t\tcontext: handler\r\n\t\t\t},\r\n\t\t\t{\r\n\t\t\t\tenabled: handler.deleteLastVertex,\r\n\t\t\t\ttitle: L.drawLocal.draw.toolbar.undo.title,\r\n\t\t\t\ttext: L.drawLocal.draw.toolbar.undo.text,\r\n\t\t\t\tcallback: handler.deleteLastVertex,\r\n\t\t\t\tcontext: handler\r\n\t\t\t},\r\n\t\t\t{\r\n\t\t\t\ttitle: L.drawLocal.draw.toolbar.actions.title,\r\n\t\t\t\ttext: L.drawLocal.draw.toolbar.actions.text,\r\n\t\t\t\tcallback: this.disable,\r\n\t\t\t\tcontext: this\r\n\t\t\t}\r\n\t\t];\r\n\t},\r\n\r\n\t// @method setOptions(): void\r\n\t// Sets the options to the toolbar\r\n\tsetOptions: function (options) {\r\n\t\tL.setOptions(this, options);\r\n\r\n\t\tfor (var type in this._modes) {\r\n\t\t\tif (this._modes.hasOwnProperty(type) && options.hasOwnProperty(type)) {\r\n\t\t\t\tthis._modes[type].handler.setOptions(options[type]);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n});\r\n","/*L.Map.mergeOptions({\r\n editControl: true\r\n });*/\r\n/**\r\n * @class L.EditToolbar\r\n * @aka EditToolbar\r\n */\r\nL.EditToolbar = L.Toolbar.extend({\r\n\tstatics: {\r\n\t\tTYPE: 'edit'\r\n\t},\r\n\r\n\toptions: {\r\n\t\tedit: {\r\n\t\t\tselectedPathOptions: {\r\n\t\t\t\tdashArray: '10, 10',\r\n\r\n\t\t\t\tfill: true,\r\n\t\t\t\tfillColor: '#fe57a1',\r\n\t\t\t\tfillOpacity: 0.1,\r\n\r\n\t\t\t\t// Whether to user the existing layers color\r\n\t\t\t\tmaintainColor: false\r\n\t\t\t}\r\n\t\t},\r\n\t\tremove: {},\r\n\t\tpoly: null,\r\n\t\tfeatureGroup: null /* REQUIRED! TODO: perhaps if not set then all layers on the map are selectable? */\r\n\t},\r\n\r\n\t// @method intialize(): void\r\n\tinitialize: function (options) {\r\n\t\t// Need to set this manually since null is an acceptable value here\r\n\t\tif (options.edit) {\r\n\t\t\tif (typeof options.edit.selectedPathOptions === 'undefined') {\r\n\t\t\t\toptions.edit.selectedPathOptions = this.options.edit.selectedPathOptions;\r\n\t\t\t}\r\n\t\t\toptions.edit.selectedPathOptions = L.extend({}, this.options.edit.selectedPathOptions, options.edit.selectedPathOptions);\r\n\t\t}\r\n\r\n\t\tif (options.remove) {\r\n\t\t\toptions.remove = L.extend({}, this.options.remove, options.remove);\r\n\t\t}\r\n\r\n\t\tif (options.poly) {\r\n\t\t\toptions.poly = L.extend({}, this.options.poly, options.poly);\r\n\t\t}\r\n\r\n\t\tthis._toolbarClass = 'leaflet-draw-edit';\r\n\t\tL.Toolbar.prototype.initialize.call(this, options);\r\n\r\n\t\tthis._selectedFeatureCount = 0;\r\n\t},\r\n\r\n\t// @method getModeHandlers(): object\r\n\t// Get mode handlers information\r\n\tgetModeHandlers: function (map) {\r\n\t\tvar featureGroup = this.options.featureGroup;\r\n\t\treturn [\r\n\t\t\t{\r\n\t\t\t\tenabled: this.options.edit,\r\n\t\t\t\thandler: new L.EditToolbar.Edit(map, {\r\n\t\t\t\t\tfeatureGroup: featureGroup,\r\n\t\t\t\t\tselectedPathOptions: this.options.edit.selectedPathOptions,\r\n\t\t\t\t\tpoly: this.options.poly\r\n\t\t\t\t}),\r\n\t\t\t\ttitle: L.drawLocal.edit.toolbar.buttons.edit\r\n\t\t\t},\r\n\t\t\t{\r\n\t\t\t\tenabled: this.options.remove,\r\n\t\t\t\thandler: new L.EditToolbar.Delete(map, {\r\n\t\t\t\t\tfeatureGroup: featureGroup\r\n\t\t\t\t}),\r\n\t\t\t\ttitle: L.drawLocal.edit.toolbar.buttons.remove\r\n\t\t\t}\r\n\t\t];\r\n\t},\r\n\r\n\t// @method getActions(): object\r\n\t// Get actions information\r\n\tgetActions: function (handler) {\r\n\t\tvar actions = [\r\n\t\t\t{\r\n\t\t\t\ttitle: L.drawLocal.edit.toolbar.actions.save.title,\r\n\t\t\t\ttext: L.drawLocal.edit.toolbar.actions.save.text,\r\n\t\t\t\tcallback: this._save,\r\n\t\t\t\tcontext: this\r\n\t\t\t},\r\n\t\t\t{\r\n\t\t\t\ttitle: L.drawLocal.edit.toolbar.actions.cancel.title,\r\n\t\t\t\ttext: L.drawLocal.edit.toolbar.actions.cancel.text,\r\n\t\t\t\tcallback: this.disable,\r\n\t\t\t\tcontext: this\r\n\t\t\t}\r\n\t\t];\r\n\r\n\t\tif (handler.removeAllLayers) {\r\n\t\t\tactions.push({\r\n\t\t\t\ttitle: L.drawLocal.edit.toolbar.actions.clearAll.title,\r\n\t\t\t\ttext: L.drawLocal.edit.toolbar.actions.clearAll.text,\r\n\t\t\t\tcallback: this._clearAllLayers,\r\n\t\t\t\tcontext: this\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\treturn actions;\r\n\t},\r\n\r\n\t// @method addToolbar(map): L.DomUtil\r\n\t// Adds the toolbar to the map\r\n\taddToolbar: function (map) {\r\n\t\tvar container = L.Toolbar.prototype.addToolbar.call(this, map);\r\n\r\n\t\tthis._checkDisabled();\r\n\r\n\t\tthis.options.featureGroup.on('layeradd layerremove', this._checkDisabled, this);\r\n\r\n\t\treturn container;\r\n\t},\r\n\r\n\t// @method removeToolbar(): void\r\n\t// Removes the toolbar from the map\r\n\tremoveToolbar: function () {\r\n\t\tthis.options.featureGroup.off('layeradd layerremove', this._checkDisabled, this);\r\n\r\n\t\tL.Toolbar.prototype.removeToolbar.call(this);\r\n\t},\r\n\r\n\t// @method disable(): void\r\n\t// Disables the toolbar\r\n\tdisable: function () {\r\n\t\tif (!this.enabled()) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tthis._activeMode.handler.revertLayers();\r\n\r\n\t\tL.Toolbar.prototype.disable.call(this);\r\n\t},\r\n\r\n\t_save: function () {\r\n\t\tthis._activeMode.handler.save();\r\n\t\tif (this._activeMode) {\r\n\t\t\tthis._activeMode.handler.disable();\r\n\t\t}\r\n\t},\r\n\r\n\t_clearAllLayers: function () {\r\n\t\tthis._activeMode.handler.removeAllLayers();\r\n\t\tif (this._activeMode) {\r\n\t\t\tthis._activeMode.handler.disable();\r\n\t\t}\r\n\t},\r\n\r\n\t_checkDisabled: function () {\r\n\t\tvar featureGroup = this.options.featureGroup,\r\n\t\t\thasLayers = featureGroup.getLayers().length !== 0,\r\n\t\t\tbutton;\r\n\r\n\t\tif (this.options.edit) {\r\n\t\t\tbutton = this._modes[L.EditToolbar.Edit.TYPE].button;\r\n\r\n\t\t\tif (hasLayers) {\r\n\t\t\t\tL.DomUtil.removeClass(button, 'leaflet-disabled');\r\n\t\t\t} else {\r\n\t\t\t\tL.DomUtil.addClass(button, 'leaflet-disabled');\r\n\t\t\t}\r\n\r\n\t\t\tbutton.setAttribute(\r\n\t\t\t\t'title',\r\n\t\t\t\thasLayers ?\r\n\t\t\t\t\tL.drawLocal.edit.toolbar.buttons.edit\r\n\t\t\t\t\t: L.drawLocal.edit.toolbar.buttons.editDisabled\r\n\t\t\t);\r\n\t\t}\r\n\r\n\t\tif (this.options.remove) {\r\n\t\t\tbutton = this._modes[L.EditToolbar.Delete.TYPE].button;\r\n\r\n\t\t\tif (hasLayers) {\r\n\t\t\t\tL.DomUtil.removeClass(button, 'leaflet-disabled');\r\n\t\t\t} else {\r\n\t\t\t\tL.DomUtil.addClass(button, 'leaflet-disabled');\r\n\t\t\t}\r\n\r\n\t\t\tbutton.setAttribute(\r\n\t\t\t\t'title',\r\n\t\t\t\thasLayers ?\r\n\t\t\t\t\tL.drawLocal.edit.toolbar.buttons.remove\r\n\t\t\t\t\t: L.drawLocal.edit.toolbar.buttons.removeDisabled\r\n\t\t\t);\r\n\t\t}\r\n\t}\r\n});\r\n","/**\r\n * @class L.EditToolbar.Edit\r\n * @aka EditToolbar.Edit\r\n */\r\nL.EditToolbar.Edit = L.Handler.extend({\r\n\tstatics: {\r\n\t\tTYPE: 'edit'\r\n\t},\r\n\r\n\t// @method intialize(): void\r\n\tinitialize: function (map, options) {\r\n\t\tL.Handler.prototype.initialize.call(this, map);\r\n\r\n\t\tL.setOptions(this, options);\r\n\r\n\t\t// Store the selectable layer group for ease of access\r\n\t\tthis._featureGroup = options.featureGroup;\r\n\r\n\t\tif (!(this._featureGroup instanceof L.FeatureGroup)) {\r\n\t\t\tthrow new Error('options.featureGroup must be a L.FeatureGroup');\r\n\t\t}\r\n\r\n\t\tthis._uneditedLayerProps = {};\r\n\r\n\t\t// Save the type so super can fire, need to do this as cannot do this.TYPE :(\r\n\t\tthis.type = L.EditToolbar.Edit.TYPE;\r\n\r\n\t\tvar version = L.version.split('.');\r\n\t\t//If Version is >= 1.2.0\r\n\t\tif (parseInt(version[0], 10) === 1 && parseInt(version[1], 10) >= 2) {\r\n\t\t\tL.EditToolbar.Edit.include(L.Evented.prototype);\r\n\t\t} else {\r\n\t\t\tL.EditToolbar.Edit.include(L.Mixin.Events);\r\n\t\t}\r\n\t},\r\n\r\n\t// @method enable(): void\r\n\t// Enable the edit toolbar\r\n\tenable: function () {\r\n\t\tif (this._enabled || !this._hasAvailableLayers()) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tthis.fire('enabled', {handler: this.type});\r\n\t\t//this disable other handlers\r\n\r\n\t\tthis._map.fire(L.Draw.Event.EDITSTART, {handler: this.type});\r\n\t\t//allow drawLayer to be updated before beginning edition.\r\n\r\n\t\tL.Handler.prototype.enable.call(this);\r\n\t\tthis._featureGroup\r\n\t\t\t.on('layeradd', this._enableLayerEdit, this)\r\n\t\t\t.on('layerremove', this._disableLayerEdit, this);\r\n\t},\r\n\r\n\t// @method disable(): void\r\n\t// Disable the edit toolbar\r\n\tdisable: function () {\r\n\t\tif (!this._enabled) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tthis._featureGroup\r\n\t\t\t.off('layeradd', this._enableLayerEdit, this)\r\n\t\t\t.off('layerremove', this._disableLayerEdit, this);\r\n\t\tL.Handler.prototype.disable.call(this);\r\n\t\tthis._map.fire(L.Draw.Event.EDITSTOP, {handler: this.type});\r\n\t\tthis.fire('disabled', {handler: this.type});\r\n\t},\r\n\r\n\t// @method addHooks(): void\r\n\t// Add listener hooks for this handler\r\n\taddHooks: function () {\r\n\t\tvar map = this._map;\r\n\r\n\t\tif (map) {\r\n\t\t\tmap.getContainer().focus();\r\n\r\n\t\t\tthis._featureGroup.eachLayer(this._enableLayerEdit, this);\r\n\r\n\t\t\tthis._tooltip = new L.Draw.Tooltip(this._map);\r\n\t\t\tthis._tooltip.updateContent({\r\n\t\t\t\ttext: L.drawLocal.edit.handlers.edit.tooltip.text,\r\n\t\t\t\tsubtext: L.drawLocal.edit.handlers.edit.tooltip.subtext\r\n\t\t\t});\r\n\r\n\t\t\t// Quickly access the tooltip to update for intersection checking\r\n\t\t\tmap._editTooltip = this._tooltip;\r\n\r\n\t\t\tthis._updateTooltip();\r\n\r\n\t\t\tthis._map\r\n\t\t\t\t.on('mousemove', this._onMouseMove, this)\r\n\t\t\t\t.on('touchmove', this._onMouseMove, this)\r\n\t\t\t\t.on('MSPointerMove', this._onMouseMove, this)\r\n\t\t\t\t.on(L.Draw.Event.EDITVERTEX, this._updateTooltip, this);\r\n\t\t}\r\n\t},\r\n\r\n\t// @method removeHooks(): void\r\n\t// Remove listener hooks for this handler\r\n\tremoveHooks: function () {\r\n\t\tif (this._map) {\r\n\t\t\t// Clean up selected layers.\r\n\t\t\tthis._featureGroup.eachLayer(this._disableLayerEdit, this);\r\n\t\t\tthis._map._editTooltip.dispose();\r\n\t\t\tthis._map._editTooltip = null;\r\n\t\t\t// Clear the backups of the original layers\r\n\t\t\tthis._uneditedLayerProps = {};\r\n\r\n\t\t\tthis._tooltip.dispose();\r\n\t\t\tthis._tooltip = null;\r\n\r\n\t\t\tthis._map\r\n\t\t\t\t.off('mousemove', this._onMouseMove, this)\r\n\t\t\t\t.off('touchmove', this._onMouseMove, this)\r\n\t\t\t\t.off('MSPointerMove', this._onMouseMove, this)\r\n\t\t\t\t.off(L.Draw.Event.EDITVERTEX, this._updateTooltip, this);\r\n\t\t}\r\n\t},\r\n\r\n\t// @method revertLayers(): void\r\n\t// Revert each layer's geometry changes\r\n\trevertLayers: function () {\r\n\t\tthis._featureGroup.eachLayer(function (layer) {\r\n\t\t\tthis._revertLayer(layer);\r\n\t\t}, this);\r\n\t},\r\n\r\n\t// @method save(): void\r\n\t// Save the layer geometries\r\n\tsave: function () {\r\n\t\tvar editedLayers = new L.LayerGroup();\r\n\t\tthis._featureGroup.eachLayer(function (layer) {\r\n\t\t\tif (layer.edited) {\r\n\t\t\t\teditedLayers.addLayer(layer);\r\n\t\t\t\tlayer.edited = false;\r\n\t\t\t}\r\n\t\t});\r\n\t\tthis._map.fire(L.Draw.Event.EDITED, {layers: editedLayers});\r\n\t},\r\n\r\n\t_backupLayer: function (layer) {\r\n\t\tvar id = L.Util.stamp(layer);\r\n\r\n\t\tif (!this._uneditedLayerProps[id]) {\r\n\t\t\t// Polyline, Polygon or Rectangle\r\n\t\t\tif (layer instanceof L.Polyline || layer instanceof L.Polygon || layer instanceof L.Rectangle) {\r\n\t\t\t\tthis._uneditedLayerProps[id] = {\r\n\t\t\t\t\tlatlngs: L.LatLngUtil.cloneLatLngs(layer.getLatLngs())\r\n\t\t\t\t};\r\n\t\t\t} else if (layer instanceof L.Circle) {\r\n\t\t\t\tthis._uneditedLayerProps[id] = {\r\n\t\t\t\t\tlatlng: L.LatLngUtil.cloneLatLng(layer.getLatLng()),\r\n\t\t\t\t\tradius: layer.getRadius()\r\n\t\t\t\t};\r\n\t\t\t} else if (layer instanceof L.Marker || layer instanceof L.CircleMarker) { // Marker\r\n\t\t\t\tthis._uneditedLayerProps[id] = {\r\n\t\t\t\t\tlatlng: L.LatLngUtil.cloneLatLng(layer.getLatLng())\r\n\t\t\t\t};\r\n\t\t\t}\r\n\t\t}\r\n\t},\r\n\r\n\t_getTooltipText: function () {\r\n\t\treturn ({\r\n\t\t\ttext: L.drawLocal.edit.handlers.edit.tooltip.text,\r\n\t\t\tsubtext: L.drawLocal.edit.handlers.edit.tooltip.subtext\r\n\t\t});\r\n\t},\r\n\r\n\t_updateTooltip: function () {\r\n\t\tthis._tooltip.updateContent(this._getTooltipText());\r\n\t},\r\n\r\n\t_revertLayer: function (layer) {\r\n\t\tvar id = L.Util.stamp(layer);\r\n\t\tlayer.edited = false;\r\n\t\tif (this._uneditedLayerProps.hasOwnProperty(id)) {\r\n\t\t\t// Polyline, Polygon or Rectangle\r\n\t\t\tif (layer instanceof L.Polyline || layer instanceof L.Polygon || layer instanceof L.Rectangle) {\r\n\t\t\t\tlayer.setLatLngs(this._uneditedLayerProps[id].latlngs);\r\n\t\t\t} else if (layer instanceof L.Circle) {\r\n\t\t\t\tlayer.setLatLng(this._uneditedLayerProps[id].latlng);\r\n\t\t\t\tlayer.setRadius(this._uneditedLayerProps[id].radius);\r\n\t\t\t} else if (layer instanceof L.Marker || layer instanceof L.CircleMarker) { // Marker or CircleMarker\r\n\t\t\t\tlayer.setLatLng(this._uneditedLayerProps[id].latlng);\r\n\t\t\t}\r\n\r\n\t\t\tlayer.fire('revert-edited', {layer: layer});\r\n\t\t}\r\n\t},\r\n\r\n\t_enableLayerEdit: function (e) {\r\n\t\tvar layer = e.layer || e.target || e,\r\n\t\t\tpathOptions, poly;\r\n\r\n\t\t// Back up this layer (if haven't before)\r\n\t\tthis._backupLayer(layer);\r\n\r\n\t\tif (this.options.poly) {\r\n\t\t\tpoly = L.Util.extend({}, this.options.poly);\r\n\t\t\tlayer.options.poly = poly;\r\n\t\t}\r\n\r\n\t\t// Set different style for editing mode\r\n\t\tif (this.options.selectedPathOptions) {\r\n\t\t\tpathOptions = L.Util.extend({}, this.options.selectedPathOptions);\r\n\r\n\t\t\t// Use the existing color of the layer\r\n\t\t\tif (pathOptions.maintainColor) {\r\n\t\t\t\tpathOptions.color = layer.options.color;\r\n\t\t\t\tpathOptions.fillColor = layer.options.fillColor;\r\n\t\t\t}\r\n\r\n\t\t\tlayer.options.original = L.extend({}, layer.options);\r\n\t\t\tlayer.options.editing = pathOptions;\r\n\r\n\t\t}\r\n\r\n\t\tif (layer instanceof L.Marker) {\r\n\t\t\tif (layer.editing) {\r\n\t\t\t\tlayer.editing.enable();\r\n\t\t\t}\r\n\t\t\tlayer.dragging.enable();\r\n\t\t\tlayer\r\n\t\t\t\t.on('dragend', this._onMarkerDragEnd)\r\n\t\t\t\t// #TODO: remove when leaflet finally fixes their draggable so it's touch friendly again.\r\n\t\t\t\t.on('touchmove', this._onTouchMove, this)\r\n\t\t\t\t.on('MSPointerMove', this._onTouchMove, this)\r\n\t\t\t\t.on('touchend', this._onMarkerDragEnd, this)\r\n\t\t\t\t.on('MSPointerUp', this._onMarkerDragEnd, this);\r\n\t\t} else {\r\n\t\t\tlayer.editing.enable();\r\n\t\t}\r\n\t},\r\n\r\n\t_disableLayerEdit: function (e) {\r\n\t\tvar layer = e.layer || e.target || e;\r\n\r\n\t\tlayer.edited = false;\r\n\t\tif (layer.editing) {\r\n\t\t\tlayer.editing.disable();\r\n\t\t}\r\n\r\n\t\tdelete layer.options.editing;\r\n\t\tdelete layer.options.original;\r\n\t\t// Reset layer styles to that of before select\r\n\t\tif (this._selectedPathOptions) {\r\n\t\t\tif (layer instanceof L.Marker) {\r\n\t\t\t\tthis._toggleMarkerHighlight(layer);\r\n\t\t\t} else {\r\n\t\t\t\t// reset the layer style to what is was before being selected\r\n\t\t\t\tlayer.setStyle(layer.options.previousOptions);\r\n\t\t\t\t// remove the cached options for the layer object\r\n\t\t\t\tdelete layer.options.previousOptions;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (layer instanceof L.Marker) {\r\n\t\t\tlayer.dragging.disable();\r\n\t\t\tlayer\r\n\t\t\t\t.off('dragend', this._onMarkerDragEnd, this)\r\n\t\t\t\t.off('touchmove', this._onTouchMove, this)\r\n\t\t\t\t.off('MSPointerMove', this._onTouchMove, this)\r\n\t\t\t\t.off('touchend', this._onMarkerDragEnd, this)\r\n\t\t\t\t.off('MSPointerUp', this._onMarkerDragEnd, this);\r\n\t\t} else {\r\n\t\t\tlayer.editing.disable();\r\n\t\t}\r\n\t},\r\n\r\n\t_onMouseMove: function (e) {\r\n\t\tthis._tooltip.updatePosition(e.latlng);\r\n\t},\r\n\r\n\t_onMarkerDragEnd: function (e) {\r\n\t\tvar layer = e.target;\r\n\t\tlayer.edited = true;\r\n\t\tthis._map.fire(L.Draw.Event.EDITMOVE, {layer: layer});\r\n\t},\r\n\r\n\t_onTouchMove: function (e) {\r\n\t\tvar touchEvent = e.originalEvent.changedTouches[0],\r\n\t\t\tlayerPoint = this._map.mouseEventToLayerPoint(touchEvent),\r\n\t\t\tlatlng = this._map.layerPointToLatLng(layerPoint);\r\n\t\te.target.setLatLng(latlng);\r\n\t},\r\n\r\n\t_hasAvailableLayers: function () {\r\n\t\treturn this._featureGroup.getLayers().length !== 0;\r\n\t}\r\n});\r\n","/**\r\n * @class L.EditToolbar.Delete\r\n * @aka EditToolbar.Delete\r\n */\r\nL.EditToolbar.Delete = L.Handler.extend({\r\n\tstatics: {\r\n\t\tTYPE: 'remove' // not delete as delete is reserved in js\r\n\t},\r\n\r\n\t// @method intialize(): void\r\n\tinitialize: function (map, options) {\r\n\t\tL.Handler.prototype.initialize.call(this, map);\r\n\r\n\t\tL.Util.setOptions(this, options);\r\n\r\n\t\t// Store the selectable layer group for ease of access\r\n\t\tthis._deletableLayers = this.options.featureGroup;\r\n\r\n\t\tif (!(this._deletableLayers instanceof L.FeatureGroup)) {\r\n\t\t\tthrow new Error('options.featureGroup must be a L.FeatureGroup');\r\n\t\t}\r\n\r\n\t\t// Save the type so super can fire, need to do this as cannot do this.TYPE :(\r\n\t\tthis.type = L.EditToolbar.Delete.TYPE;\r\n\r\n\t\tvar version = L.version.split('.');\r\n\t\t//If Version is >= 1.2.0\r\n\t\tif (parseInt(version[0], 10) === 1 && parseInt(version[1], 10) >= 2) {\r\n\t\t\tL.EditToolbar.Delete.include(L.Evented.prototype);\r\n\t\t} else {\r\n\t\t\tL.EditToolbar.Delete.include(L.Mixin.Events);\r\n\t\t}\r\n\r\n\t},\r\n\r\n\t// @method enable(): void\r\n\t// Enable the delete toolbar\r\n\tenable: function () {\r\n\t\tif (this._enabled || !this._hasAvailableLayers()) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tthis.fire('enabled', {handler: this.type});\r\n\r\n\t\tthis._map.fire(L.Draw.Event.DELETESTART, {handler: this.type});\r\n\r\n\t\tL.Handler.prototype.enable.call(this);\r\n\r\n\t\tthis._deletableLayers\r\n\t\t\t.on('layeradd', this._enableLayerDelete, this)\r\n\t\t\t.on('layerremove', this._disableLayerDelete, this);\r\n\t},\r\n\r\n\t// @method disable(): void\r\n\t// Disable the delete toolbar\r\n\tdisable: function () {\r\n\t\tif (!this._enabled) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tthis._deletableLayers\r\n\t\t\t.off('layeradd', this._enableLayerDelete, this)\r\n\t\t\t.off('layerremove', this._disableLayerDelete, this);\r\n\r\n\t\tL.Handler.prototype.disable.call(this);\r\n\r\n\t\tthis._map.fire(L.Draw.Event.DELETESTOP, {handler: this.type});\r\n\r\n\t\tthis.fire('disabled', {handler: this.type});\r\n\t},\r\n\r\n\t// @method addHooks(): void\r\n\t// Add listener hooks to this handler\r\n\taddHooks: function () {\r\n\t\tvar map = this._map;\r\n\r\n\t\tif (map) {\r\n\t\t\tmap.getContainer().focus();\r\n\r\n\t\t\tthis._deletableLayers.eachLayer(this._enableLayerDelete, this);\r\n\t\t\tthis._deletedLayers = new L.LayerGroup();\r\n\r\n\t\t\tthis._tooltip = new L.Draw.Tooltip(this._map);\r\n\t\t\tthis._tooltip.updateContent({text: L.drawLocal.edit.handlers.remove.tooltip.text});\r\n\r\n\t\t\tthis._map.on('mousemove', this._onMouseMove, this);\r\n\t\t}\r\n\t},\r\n\r\n\t// @method removeHooks(): void\r\n\t// Remove listener hooks from this handler\r\n\tremoveHooks: function () {\r\n\t\tif (this._map) {\r\n\t\t\tthis._deletableLayers.eachLayer(this._disableLayerDelete, this);\r\n\t\t\tthis._deletedLayers = null;\r\n\r\n\t\t\tthis._tooltip.dispose();\r\n\t\t\tthis._tooltip = null;\r\n\r\n\t\t\tthis._map.off('mousemove', this._onMouseMove, this);\r\n\t\t}\r\n\t},\r\n\r\n\t// @method revertLayers(): void\r\n\t// Revert the deleted layers back to their prior state.\r\n\trevertLayers: function () {\r\n\t\t// Iterate of the deleted layers and add them back into the featureGroup\r\n\t\tthis._deletedLayers.eachLayer(function (layer) {\r\n\t\t\tthis._deletableLayers.addLayer(layer);\r\n\t\t\tlayer.fire('revert-deleted', {layer: layer});\r\n\t\t}, this);\r\n\t},\r\n\r\n\t// @method save(): void\r\n\t// Save deleted layers\r\n\tsave: function () {\r\n\t\tthis._map.fire(L.Draw.Event.DELETED, {layers: this._deletedLayers});\r\n\t},\r\n\r\n\t// @method removeAllLayers(): void\r\n\t// Remove all delateable layers\r\n\tremoveAllLayers: function () {\r\n\t\t// Iterate of the delateable layers and add remove them\r\n\t\tthis._deletableLayers.eachLayer(function (layer) {\r\n\t\t\tthis._removeLayer({layer: layer});\r\n\t\t}, this);\r\n\t\tthis.save();\r\n\t},\r\n\r\n\t_enableLayerDelete: function (e) {\r\n\t\tvar layer = e.layer || e.target || e;\r\n\r\n\t\tlayer.on('click', this._removeLayer, this);\r\n\t},\r\n\r\n\t_disableLayerDelete: function (e) {\r\n\t\tvar layer = e.layer || e.target || e;\r\n\r\n\t\tlayer.off('click', this._removeLayer, this);\r\n\r\n\t\t// Remove from the deleted layers so we can't accidentally revert if the user presses cancel\r\n\t\tthis._deletedLayers.removeLayer(layer);\r\n\t},\r\n\r\n\t_removeLayer: function (e) {\r\n\t\tvar layer = e.layer || e.target || e;\r\n\r\n\t\tthis._deletableLayers.removeLayer(layer);\r\n\r\n\t\tthis._deletedLayers.addLayer(layer);\r\n\r\n\t\tlayer.fire('deleted');\r\n\t},\r\n\r\n\t_onMouseMove: function (e) {\r\n\t\tthis._tooltip.updatePosition(e.latlng);\r\n\t},\r\n\r\n\t_hasAvailableLayers: function () {\r\n\t\treturn this._deletableLayers.getLayers().length !== 0;\r\n\t}\r\n});\r\n"]} \ No newline at end of file +{"version":3,"sources":["src/Leaflet.draw.js","src/Leaflet.Draw.Event.js","src/draw/handler/Draw.Feature.js","src/draw/handler/Draw.Polyline.js","src/draw/handler/Draw.Polygon.js","src/draw/handler/Draw.SimpleShape.js","src/draw/handler/Draw.Rectangle.js","src/draw/handler/Draw.Marker.js","src/draw/handler/Draw.CircleMarker.js","src/draw/handler/Draw.Circle.js","src/edit/handler/Edit.Marker.js","src/edit/handler/Edit.Poly.js","src/edit/handler/Edit.SimpleShape.js","src/edit/handler/Edit.Rectangle.js","src/edit/handler/Edit.CircleMarker.js","src/edit/handler/Edit.Circle.js","src/ext/TouchEvents.js","src/ext/LatLngUtil.js","src/ext/GeometryUtil.js","src/ext/LineUtil.Intersect.js","src/ext/Polyline.Intersect.js","src/ext/Polygon.Intersect.js","src/Control.Draw.js","src/Toolbar.js","src/Tooltip.js","src/draw/DrawToolbar.js","src/edit/EditToolbar.js","src/edit/handler/EditToolbar.Edit.js","src/edit/handler/EditToolbar.Delete.js"],"names":[],"mappings":";;;;;;;yCAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC7LA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AChLA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACxGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AChlBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACjIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACvHA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AClGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC/HA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC1CA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACnFA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACpFA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACxgBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACrOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC7HA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACrDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC1DA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AChRA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC5BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACrKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACtBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC1GA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACjCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACtHA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC9UA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACtHA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC9GA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AClMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACnSA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","sourcesContent":["/**\r\n * Leaflet.draw assumes that you have already included the Leaflet library.\r\n */\r\nL.drawVersion = \"1.0.3+2538bd9\";\r\n/**\r\n * @class L.Draw\r\n * @aka Draw\r\n *\r\n *\r\n * To add the draw toolbar set the option drawControl: true in the map options.\r\n *\r\n * @example\r\n * ```js\r\n * var map = L.map('map', {drawControl: true}).setView([51.505, -0.09], 13);\r\n *\r\n * L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {\r\n * attribution: '© OpenStreetMap contributors'\r\n * }).addTo(map);\r\n * ```\r\n *\r\n * ### Adding the edit toolbar\r\n * To use the edit toolbar you must initialise the Leaflet.draw control and manually add it to the map.\r\n *\r\n * ```js\r\n * var map = L.map('map').setView([51.505, -0.09], 13);\r\n *\r\n * L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {\r\n * attribution: '© OpenStreetMap contributors'\r\n * }).addTo(map);\r\n *\r\n * // FeatureGroup is to store editable layers\r\n * var drawnItems = new L.FeatureGroup();\r\n * map.addLayer(drawnItems);\r\n *\r\n * var drawControl = new L.Control.Draw({\r\n * edit: {\r\n * featureGroup: drawnItems\r\n * }\r\n * });\r\n * map.addControl(drawControl);\r\n * ```\r\n *\r\n * The key here is the featureGroup option. This tells the plugin which FeatureGroup contains the layers that\r\n * should be editable. The featureGroup can contain 0 or more features with geometry types Point, LineString, and Polygon.\r\n * Leaflet.draw does not work with multigeometry features such as MultiPoint, MultiLineString, MultiPolygon,\r\n * or GeometryCollection. If you need to add multigeometry features to the draw plugin, convert them to a\r\n * FeatureCollection of non-multigeometries (Points, LineStrings, or Polygons).\r\n */\r\nL.Draw = {};\r\n\r\n/**\r\n * @class L.drawLocal\r\n * @aka L.drawLocal\r\n *\r\n * The core toolbar class of the API — it is used to create the toolbar ui\r\n *\r\n * @example\r\n * ```js\r\n * var modifiedDraw = L.drawLocal.extend({\r\n * draw: {\r\n * toolbar: {\r\n * buttons: {\r\n * polygon: 'Draw an awesome polygon'\r\n * }\r\n * }\r\n * }\r\n * });\r\n * ```\r\n *\r\n * The default state for the control is the draw toolbar just below the zoom control.\r\n * This will allow map users to draw vectors and markers.\r\n * **Please note the edit toolbar is not enabled by default.**\r\n */\r\nL.drawLocal = {\r\n\t// format: {\r\n\t// \tnumeric: {\r\n\t// \t\tdelimiters: {\r\n\t// \t\t\tthousands: ',',\r\n\t// \t\t\tdecimal: '.'\r\n\t// \t\t}\r\n\t// \t}\r\n\t// },\r\n\tdraw: {\r\n\t\ttoolbar: {\r\n\t\t\t// #TODO: this should be reorganized where actions are nested in actions\r\n\t\t\t// ex: actions.undo or actions.cancel\r\n\t\t\tactions: {\r\n\t\t\t\ttitle: 'Cancel drawing',\r\n\t\t\t\ttext: 'Cancel'\r\n\t\t\t},\r\n\t\t\tfinish: {\r\n\t\t\t\ttitle: 'Finish drawing',\r\n\t\t\t\ttext: 'Finish'\r\n\t\t\t},\r\n\t\t\tundo: {\r\n\t\t\t\ttitle: 'Delete last point drawn',\r\n\t\t\t\ttext: 'Delete last point'\r\n\t\t\t},\r\n\t\t\tbuttons: {\r\n\t\t\t\tpolyline: 'Draw a polyline',\r\n\t\t\t\tpolygon: 'Draw a polygon',\r\n\t\t\t\trectangle: 'Draw a rectangle',\r\n\t\t\t\tcircle: 'Draw a circle',\r\n\t\t\t\tmarker: 'Draw a marker',\r\n\t\t\t\tcirclemarker: 'Draw a circlemarker'\r\n\t\t\t}\r\n\t\t},\r\n\t\thandlers: {\r\n\t\t\tcircle: {\r\n\t\t\t\ttooltip: {\r\n\t\t\t\t\tstart: 'Click and drag to draw circle.'\r\n\t\t\t\t},\r\n\t\t\t\tradius: 'Radius'\r\n\t\t\t},\r\n\t\t\tcirclemarker: {\r\n\t\t\t\ttooltip: {\r\n\t\t\t\t\tstart: 'Click map to place circle marker.'\r\n\t\t\t\t}\r\n\t\t\t},\r\n\t\t\tmarker: {\r\n\t\t\t\ttooltip: {\r\n\t\t\t\t\tstart: 'Click map to place marker.'\r\n\t\t\t\t}\r\n\t\t\t},\r\n\t\t\tpolygon: {\r\n\t\t\t\ttooltip: {\r\n\t\t\t\t\tstart: 'Click to start drawing shape.',\r\n\t\t\t\t\tcont: 'Click to continue drawing shape.',\r\n\t\t\t\t\tend: 'Click first point to close this shape.'\r\n\t\t\t\t}\r\n\t\t\t},\r\n\t\t\tpolyline: {\r\n\t\t\t\terror: 'Error: shape edges cannot cross!',\r\n\t\t\t\ttooltip: {\r\n\t\t\t\t\tstart: 'Click to start drawing line.',\r\n\t\t\t\t\tcont: 'Click to continue drawing line.',\r\n\t\t\t\t\tend: 'Click last point to finish line.'\r\n\t\t\t\t}\r\n\t\t\t},\r\n\t\t\trectangle: {\r\n\t\t\t\ttooltip: {\r\n\t\t\t\t\tstart: 'Click and drag to draw rectangle.'\r\n\t\t\t\t}\r\n\t\t\t},\r\n\t\t\tsimpleshape: {\r\n\t\t\t\ttooltip: {\r\n\t\t\t\t\tend: 'Release mouse to finish drawing.'\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t},\r\n\tedit: {\r\n\t\ttoolbar: {\r\n\t\t\tactions: {\r\n\t\t\t\tsave: {\r\n\t\t\t\t\ttitle: 'Save changes',\r\n\t\t\t\t\ttext: 'Save'\r\n\t\t\t\t},\r\n\t\t\t\tcancel: {\r\n\t\t\t\t\ttitle: 'Cancel editing, discards all changes',\r\n\t\t\t\t\ttext: 'Cancel'\r\n\t\t\t\t},\r\n\t\t\t\tclearAll: {\r\n\t\t\t\t\ttitle: 'Clear all layers',\r\n\t\t\t\t\ttext: 'Clear All'\r\n\t\t\t\t}\r\n\t\t\t},\r\n\t\t\tbuttons: {\r\n\t\t\t\tedit: 'Edit layers',\r\n\t\t\t\teditDisabled: 'No layers to edit',\r\n\t\t\t\tremove: 'Delete layers',\r\n\t\t\t\tremoveDisabled: 'No layers to delete'\r\n\t\t\t}\r\n\t\t},\r\n\t\thandlers: {\r\n\t\t\tedit: {\r\n\t\t\t\ttooltip: {\r\n\t\t\t\t\ttext: 'Drag handles or markers to edit features.',\r\n\t\t\t\t\tsubtext: 'Click cancel to undo changes.'\r\n\t\t\t\t}\r\n\t\t\t},\r\n\t\t\tremove: {\r\n\t\t\t\ttooltip: {\r\n\t\t\t\t\ttext: 'Click on a feature to remove.'\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n};\r\n","/**\r\n * ### Events\r\n * Once you have successfully added the Leaflet.draw plugin to your map you will want to respond to the different\r\n * actions users can initiate. The following events will be triggered on the map:\r\n *\r\n * @class L.Draw.Event\r\n * @aka Draw.Event\r\n *\r\n * Use `L.Draw.Event.EVENTNAME` constants to ensure events are correct.\r\n *\r\n * @example\r\n * ```js\r\n * map.on(L.Draw.Event.CREATED; function (e) {\r\n * var type = e.layerType,\r\n * layer = e.layer;\r\n *\r\n * if (type === 'marker') {\r\n * // Do marker specific actions\r\n * }\r\n *\r\n * // Do whatever else you need to. (save to db; add to map etc)\r\n * map.addLayer(layer);\r\n *});\r\n * ```\r\n */\r\nL.Draw.Event = {};\r\n/**\r\n * @event draw:created: PolyLine; Polygon; Rectangle; Circle; Marker | String\r\n *\r\n * Layer that was just created.\r\n * The type of layer this is. One of: `polyline`; `polygon`; `rectangle`; `circle`; `marker`\r\n * Triggered when a new vector or marker has been created.\r\n *\r\n */\r\nL.Draw.Event.CREATED = 'draw:created';\r\n\r\n/**\r\n * @event draw:edited: LayerGroup\r\n *\r\n * List of all layers just edited on the map.\r\n *\r\n *\r\n * Triggered when layers in the FeatureGroup; initialised with the plugin; have been edited and saved.\r\n *\r\n * @example\r\n * ```js\r\n * map.on('draw:edited', function (e) {\r\n * var layers = e.layers;\r\n * layers.eachLayer(function (layer) {\r\n * //do whatever you want; most likely save back to db\r\n * });\r\n * });\r\n * ```\r\n */\r\nL.Draw.Event.EDITED = 'draw:edited';\r\n\r\n/**\r\n * @event draw:deleted: LayerGroup\r\n *\r\n * List of all layers just removed from the map.\r\n *\r\n * Triggered when layers have been removed (and saved) from the FeatureGroup.\r\n */\r\nL.Draw.Event.DELETED = 'draw:deleted';\r\n\r\n/**\r\n * @event draw:drawstart: String\r\n *\r\n * The type of layer this is. One of:`polyline`; `polygon`; `rectangle`; `circle`; `marker`\r\n *\r\n * Triggered when the user has chosen to draw a particular vector or marker.\r\n */\r\nL.Draw.Event.DRAWSTART = 'draw:drawstart';\r\n\r\n/**\r\n * @event draw:drawstop: String\r\n *\r\n * The type of layer this is. One of: `polyline`; `polygon`; `rectangle`; `circle`; `marker`\r\n *\r\n * Triggered when the user has finished a particular vector or marker.\r\n */\r\n\r\nL.Draw.Event.DRAWSTOP = 'draw:drawstop';\r\n\r\n/**\r\n * @event draw:drawvertex: LayerGroup\r\n *\r\n * List of all layers just being added from the map.\r\n *\r\n * Triggered when a vertex is created on a polyline or polygon.\r\n */\r\nL.Draw.Event.DRAWVERTEX = 'draw:drawvertex';\r\n\r\n/**\r\n * @event draw:editstart: String\r\n *\r\n * The type of edit this is. One of: `edit`\r\n *\r\n * Triggered when the user starts edit mode by clicking the edit tool button.\r\n */\r\n\r\nL.Draw.Event.EDITSTART = 'draw:editstart';\r\n\r\n/**\r\n * @event draw:editmove: ILayer\r\n *\r\n * Layer that was just moved.\r\n *\r\n * Triggered as the user moves a rectangle; circle or marker.\r\n */\r\nL.Draw.Event.EDITMOVE = 'draw:editmove';\r\n\r\n/**\r\n * @event draw:editresize: ILayer\r\n *\r\n * Layer that was just moved.\r\n *\r\n * Triggered as the user resizes a rectangle or circle.\r\n */\r\nL.Draw.Event.EDITRESIZE = 'draw:editresize';\r\n\r\n/**\r\n * @event draw:editvertex: LayerGroup\r\n *\r\n * List of all layers just being edited from the map.\r\n *\r\n * Triggered when a vertex is edited on a polyline or polygon.\r\n */\r\nL.Draw.Event.EDITVERTEX = 'draw:editvertex';\r\n\r\n/**\r\n * @event draw:editstop: String\r\n *\r\n * The type of edit this is. One of: `edit`\r\n *\r\n * Triggered when the user has finshed editing (edit mode) and saves edits.\r\n */\r\nL.Draw.Event.EDITSTOP = 'draw:editstop';\r\n\r\n/**\r\n * @event draw:deletestart: String\r\n *\r\n * The type of edit this is. One of: `remove`\r\n *\r\n * Triggered when the user starts remove mode by clicking the remove tool button.\r\n */\r\nL.Draw.Event.DELETESTART = 'draw:deletestart';\r\n\r\n/**\r\n * @event draw:deletestop: String\r\n *\r\n * The type of edit this is. One of: `remove`\r\n *\r\n * Triggered when the user has finished removing shapes (remove mode) and saves.\r\n */\r\nL.Draw.Event.DELETESTOP = 'draw:deletestop';\r\n\r\n/**\r\n * @event draw:toolbaropened: String\r\n *\r\n * Triggered when a toolbar is opened.\r\n */\r\nL.Draw.Event.TOOLBAROPENED = 'draw:toolbaropened';\r\n\r\n/**\r\n * @event draw:toolbarclosed: String\r\n *\r\n * Triggered when a toolbar is closed.\r\n */\r\nL.Draw.Event.TOOLBARCLOSED = 'draw:toolbarclosed';\r\n\r\n/**\r\n * @event draw:markercontext: String\r\n *\r\n * Triggered when a marker is right clicked.\r\n */\r\nL.Draw.Event.MARKERCONTEXT = 'draw:markercontext';","L.Draw = L.Draw || {};\r\n\r\n/**\r\n * @class L.Draw.Feature\r\n * @aka Draw.Feature\r\n */\r\nL.Draw.Feature = L.Handler.extend({\r\n\r\n\t// @method initialize(): void\r\n\tinitialize: function (map, options) {\r\n\t\tthis._map = map;\r\n\t\tthis._container = map._container;\r\n\t\tthis._overlayPane = map._panes.overlayPane;\r\n\t\tthis._popupPane = map._panes.popupPane;\r\n\r\n\t\t// Merge default shapeOptions options with custom shapeOptions\r\n\t\tif (options && options.shapeOptions) {\r\n\t\t\toptions.shapeOptions = L.Util.extend({}, this.options.shapeOptions, options.shapeOptions);\r\n\t\t}\r\n\t\tL.setOptions(this, options);\r\n\r\n\t\tvar version = L.version.split('.');\r\n\t\t//If Version is >= 1.2.0\r\n\t\tif (parseInt(version[0], 10) === 1 && parseInt(version[1], 10) >= 2) {\r\n\t\t\tL.Draw.Feature.include(L.Evented.prototype);\r\n\t\t} else {\r\n\t\t\tL.Draw.Feature.include(L.Mixin.Events);\r\n\t\t}\r\n\t},\r\n\r\n\t// @method enable(): void\r\n\t// Enables this handler\r\n\tenable: function () {\r\n\t\tif (this._enabled) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tL.Handler.prototype.enable.call(this);\r\n\r\n\t\tthis.fire('enabled', {handler: this.type});\r\n\r\n\t\tthis._map.fire(L.Draw.Event.DRAWSTART, {layerType: this.type});\r\n\t},\r\n\r\n\t// @method disable(): void\r\n\tdisable: function () {\r\n\t\tif (!this._enabled) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tL.Handler.prototype.disable.call(this);\r\n\r\n\t\tthis._map.fire(L.Draw.Event.DRAWSTOP, {layerType: this.type});\r\n\r\n\t\tthis.fire('disabled', {handler: this.type});\r\n\t},\r\n\r\n\t// @method addHooks(): void\r\n\t// Add's event listeners to this handler\r\n\taddHooks: function () {\r\n\t\tvar map = this._map;\r\n\r\n\t\tif (map) {\r\n\t\t\tL.DomUtil.disableTextSelection();\r\n\r\n\t\t\tmap.getContainer().focus();\r\n\r\n\t\t\tthis._tooltip = new L.Draw.Tooltip(this._map);\r\n\r\n\t\t\tL.DomEvent.on(this._container, 'keyup', this._cancelDrawing, this);\r\n\t\t}\r\n\t},\r\n\r\n\t// @method removeHooks(): void\r\n\t// Removes event listeners from this handler\r\n\tremoveHooks: function () {\r\n\t\tif (this._map) {\r\n\t\t\tL.DomUtil.enableTextSelection();\r\n\r\n\t\t\tthis._tooltip.dispose();\r\n\t\t\tthis._tooltip = null;\r\n\r\n\t\t\tL.DomEvent.off(this._container, 'keyup', this._cancelDrawing, this);\r\n\t\t}\r\n\t},\r\n\r\n\t// @method setOptions(object): void\r\n\t// Sets new options to this handler\r\n\tsetOptions: function (options) {\r\n\t\tL.setOptions(this, options);\r\n\t},\r\n\r\n\t_fireCreatedEvent: function (layer) {\r\n\t\tthis._map.fire(L.Draw.Event.CREATED, {layer: layer, layerType: this.type});\r\n\t},\r\n\r\n\t// Cancel drawing when the escape key is pressed\r\n\t_cancelDrawing: function (e) {\r\n\t\tif (e.keyCode === 27) {\r\n\t\t\tthis._map.fire('draw:canceled', {layerType: this.type});\r\n\t\t\tthis.disable();\r\n\t\t}\r\n\t}\r\n});\r\n","/**\r\n * @class L.Draw.Polyline\r\n * @aka Draw.Polyline\r\n * @inherits L.Draw.Feature\r\n */\r\nL.Draw.Polyline = L.Draw.Feature.extend({\r\n\tstatics: {\r\n\t\tTYPE: 'polyline'\r\n\t},\r\n\r\n\tPoly: L.Polyline,\r\n\r\n\toptions: {\r\n\t\tallowIntersection: true,\r\n\t\trepeatMode: false,\r\n\t\tdrawError: {\r\n\t\t\tcolor: '#b00b00',\r\n\t\t\ttimeout: 2500\r\n\t\t},\r\n\t\ticon: new L.DivIcon({\r\n\t\t\ticonSize: new L.Point(8, 8),\r\n\t\t\tclassName: 'leaflet-div-icon leaflet-editing-icon'\r\n\t\t}),\r\n\t\ttouchIcon: new L.DivIcon({\r\n\t\t\ticonSize: new L.Point(20, 20),\r\n\t\t\tclassName: 'leaflet-div-icon leaflet-editing-icon leaflet-touch-icon'\r\n\t\t}),\r\n\t\tguidelineDistance: 20,\r\n\t\tmaxGuideLineLength: 4000,\r\n\t\tshapeOptions: {\r\n\t\t\tstroke: true,\r\n\t\t\tcolor: '#3388ff',\r\n\t\t\tweight: 4,\r\n\t\t\topacity: 0.5,\r\n\t\t\tfill: false,\r\n\t\t\tclickable: true\r\n\t\t},\r\n\t\tmetric: true, // Whether to use the metric measurement system or imperial\r\n\t\tfeet: true, // When not metric, to use feet instead of yards for display.\r\n\t\tnautic: false, // When not metric, not feet use nautic mile for display\r\n\t\tshowLength: true, // Whether to display distance in the tooltip\r\n\t\tzIndexOffset: 2000, // This should be > than the highest z-index any map layers\r\n\t\tfactor: 1, // To change distance calculation\r\n\t\tmaxPoints: 0 // Once this number of points are placed, finish shape\r\n\t},\r\n\r\n\t// @method initialize(): void\r\n\tinitialize: function (map, options) {\r\n\t\t// if touch, switch to touch icon\r\n\t\tif (L.Browser.touch) {\r\n\t\t\tthis.options.icon = this.options.touchIcon;\r\n\t\t}\r\n\r\n\t\t// Need to set this here to ensure the correct message is used.\r\n\t\tthis.options.drawError.message = L.drawLocal.draw.handlers.polyline.error;\r\n\r\n\t\t// Merge default drawError options with custom options\r\n\t\tif (options && options.drawError) {\r\n\t\t\toptions.drawError = L.Util.extend({}, this.options.drawError, options.drawError);\r\n\t\t}\r\n\r\n\t\t// Save the type so super can fire, need to do this as cannot do this.TYPE :(\r\n\t\tthis.type = L.Draw.Polyline.TYPE;\r\n\r\n\t\tL.Draw.Feature.prototype.initialize.call(this, map, options);\r\n\t},\r\n\r\n\t// @method addHooks(): void\r\n\t// Add listener hooks to this handler\r\n\taddHooks: function () {\r\n\t\tL.Draw.Feature.prototype.addHooks.call(this);\r\n\t\tif (this._map) {\r\n\t\t\tthis._markers = [];\r\n\r\n\t\t\tthis._markerGroup = new L.LayerGroup();\r\n\t\t\tthis._map.addLayer(this._markerGroup);\r\n\r\n\t\t\tthis._poly = new L.Polyline([], this.options.shapeOptions);\r\n\r\n\t\t\tthis._tooltip.updateContent(this._getTooltipText());\r\n\r\n\t\t\t// Make a transparent marker that will used to catch click events. These click\r\n\t\t\t// events will create the vertices. We need to do this so we can ensure that\r\n\t\t\t// we can create vertices over other map layers (markers, vector layers). We\r\n\t\t\t// also do not want to trigger any click handlers of objects we are clicking on\r\n\t\t\t// while drawing.\r\n\t\t\tif (!this._mouseMarker) {\r\n\t\t\t\tthis._mouseMarker = L.marker(this._map.getCenter(), {\r\n\t\t\t\t\ticon: L.divIcon({\r\n\t\t\t\t\t\tclassName: 'leaflet-mouse-marker',\r\n\t\t\t\t\t\ticonAnchor: [20, 20],\r\n\t\t\t\t\t\ticonSize: [40, 40]\r\n\t\t\t\t\t}),\r\n\t\t\t\t\topacity: 0,\r\n\t\t\t\t\tzIndexOffset: this.options.zIndexOffset\r\n\t\t\t\t});\r\n\t\t\t}\r\n\r\n\t\t\tthis._mouseMarker\r\n\t\t\t\t.on('mouseout', this._onMouseOut, this)\r\n\t\t\t\t.on('mousemove', this._onMouseMove, this) // Necessary to prevent 0.8 stutter\r\n\t\t\t\t.on('mousedown', this._onMouseDown, this)\r\n\t\t\t\t.on('mouseup', this._onMouseUp, this) // Necessary for 0.8 compatibility\r\n\t\t\t\t.addTo(this._map);\r\n\r\n\t\t\tthis._map\r\n\t\t\t\t.on('mouseup', this._onMouseUp, this) // Necessary for 0.7 compatibility\r\n\t\t\t\t.on('mousemove', this._onMouseMove, this)\r\n\t\t\t\t.on('zoomlevelschange', this._onZoomEnd, this)\r\n\t\t\t\t.on('touchstart', this._onTouch, this)\r\n\t\t\t\t.on('zoomend', this._onZoomEnd, this);\r\n\r\n\t\t}\r\n\t},\r\n\r\n\t// @method removeHooks(): void\r\n\t// Remove listener hooks from this handler.\r\n\tremoveHooks: function () {\r\n\t\tL.Draw.Feature.prototype.removeHooks.call(this);\r\n\r\n\t\tthis._clearHideErrorTimeout();\r\n\r\n\t\tthis._cleanUpShape();\r\n\r\n\t\t// remove markers from map\r\n\t\tthis._map.removeLayer(this._markerGroup);\r\n\t\tdelete this._markerGroup;\r\n\t\tdelete this._markers;\r\n\r\n\t\tthis._map.removeLayer(this._poly);\r\n\t\tdelete this._poly;\r\n\r\n\t\tthis._mouseMarker\r\n\t\t\t.off('mousedown', this._onMouseDown, this)\r\n\t\t\t.off('mouseout', this._onMouseOut, this)\r\n\t\t\t.off('mouseup', this._onMouseUp, this)\r\n\t\t\t.off('mousemove', this._onMouseMove, this);\r\n\t\tthis._map.removeLayer(this._mouseMarker);\r\n\t\tdelete this._mouseMarker;\r\n\r\n\t\t// clean up DOM\r\n\t\tthis._clearGuides();\r\n\r\n\t\tthis._map\r\n\t\t\t.off('mouseup', this._onMouseUp, this)\r\n\t\t\t.off('mousemove', this._onMouseMove, this)\r\n\t\t\t.off('zoomlevelschange', this._onZoomEnd, this)\r\n\t\t\t.off('zoomend', this._onZoomEnd, this)\r\n\t\t\t.off('touchstart', this._onTouch, this)\r\n\t\t\t.off('click', this._onTouch, this);\r\n\t},\r\n\r\n\t// @method deleteLastVertex(): void\r\n\t// Remove the last vertex from the polyline, removes polyline from map if only one point exists.\r\n\tdeleteLastVertex: function () {\r\n\t\tif (this._markers.length <= 1) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tvar lastMarker = this._markers.pop(),\r\n\t\t\tpoly = this._poly,\r\n\t\t\t// Replaces .spliceLatLngs()\r\n\t\t\tlatlngs = poly.getLatLngs(),\r\n\t\t\tlatlng = latlngs.splice(-1, 1)[0];\r\n\t\tthis._poly.setLatLngs(latlngs);\r\n\r\n\t\tthis._markerGroup.removeLayer(lastMarker);\r\n\r\n\t\tif (poly.getLatLngs().length < 2) {\r\n\t\t\tthis._map.removeLayer(poly);\r\n\t\t}\r\n\r\n\t\tthis._vertexChanged(latlng, false);\r\n\t},\r\n\r\n\t// @method addVertex(): void\r\n\t// Add a vertex to the end of the polyline\r\n\taddVertex: function (latlng) {\r\n\t\tvar markersLength = this._markers.length;\r\n\t\t// markersLength must be greater than or equal to 2 before intersections can occur\r\n\t\tif (markersLength >= 2 && !this.options.allowIntersection && this._poly.newLatLngIntersects(latlng)) {\r\n\t\t\tthis._showErrorTooltip();\r\n\t\t\treturn;\r\n\t\t}\r\n\t\telse if (this._errorShown) {\r\n\t\t\tthis._hideErrorTooltip();\r\n\t\t}\r\n\r\n\t\tthis._markers.push(this._createMarker(latlng));\r\n\r\n\t\tthis._poly.addLatLng(latlng);\r\n\r\n\t\tif (this._poly.getLatLngs().length === 2) {\r\n\t\t\tthis._map.addLayer(this._poly);\r\n\t\t}\r\n\r\n\t\tthis._vertexChanged(latlng, true);\r\n\t},\r\n\r\n\t// @method completeShape(): void\r\n\t// Closes the polyline between the first and last points\r\n\tcompleteShape: function () {\r\n\t\tif (this._markers.length <= 1 || !this._shapeIsValid()) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tthis._fireCreatedEvent();\r\n\t\tthis.disable();\r\n\r\n\t\tif (this.options.repeatMode) {\r\n\t\t\tthis.enable();\r\n\t\t}\r\n\t},\r\n\r\n\t_finishShape: function () {\r\n\t\tvar latlngs = this._poly._defaultShape ? this._poly._defaultShape() : this._poly.getLatLngs();\r\n\t\tvar intersects = this._poly.newLatLngIntersects(latlngs[latlngs.length - 1]);\r\n\r\n\t\tif ((!this.options.allowIntersection && intersects) || !this._shapeIsValid()) {\r\n\t\t\tthis._showErrorTooltip();\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tthis._fireCreatedEvent();\r\n\t\tthis.disable();\r\n\t\tif (this.options.repeatMode) {\r\n\t\t\tthis.enable();\r\n\t\t}\r\n\t},\r\n\r\n\t// Called to verify the shape is valid when the user tries to finish it\r\n\t// Return false if the shape is not valid\r\n\t_shapeIsValid: function () {\r\n\t\treturn true;\r\n\t},\r\n\r\n\t_onZoomEnd: function () {\r\n\t\tif (this._markers !== null) {\r\n\t\t\tthis._updateGuide();\r\n\t\t}\r\n\t},\r\n\r\n\t_onMouseMove: function (e) {\r\n\t\tvar newPos = this._map.mouseEventToLayerPoint(e.originalEvent);\r\n\t\tvar latlng = this._map.layerPointToLatLng(newPos);\r\n\r\n\t\t// Save latlng\r\n\t\t// should this be moved to _updateGuide() ?\r\n\t\tthis._currentLatLng = latlng;\r\n\r\n\t\tthis._updateTooltip(latlng);\r\n\r\n\t\t// Update the guide line\r\n\t\tthis._updateGuide(newPos);\r\n\r\n\t\t// Update the mouse marker position\r\n\t\tthis._mouseMarker.setLatLng(latlng);\r\n\r\n\t\tL.DomEvent.preventDefault(e.originalEvent);\r\n\t},\r\n\r\n\t_vertexChanged: function (latlng, added) {\r\n\t\tthis._map.fire(L.Draw.Event.DRAWVERTEX, {layers: this._markerGroup});\r\n\t\tthis._updateFinishHandler();\r\n\r\n\t\tthis._updateRunningMeasure(latlng, added);\r\n\r\n\t\tthis._clearGuides();\r\n\r\n\t\tthis._updateTooltip();\r\n\t},\r\n\r\n\t_onMouseDown: function (e) {\r\n\t\tif (!this._clickHandled && !this._touchHandled && !this._disableMarkers) {\r\n\t\t\tthis._onMouseMove(e);\r\n\t\t\tthis._clickHandled = true;\r\n\t\t\tthis._disableNewMarkers();\r\n\t\t\tvar originalEvent = e.originalEvent;\r\n\t\t\tvar clientX = originalEvent.clientX;\r\n\t\t\tvar clientY = originalEvent.clientY;\r\n\t\t\tthis._startPoint.call(this, clientX, clientY);\r\n\t\t}\r\n\t},\r\n\r\n\t_startPoint: function (clientX, clientY) {\r\n\t\tthis._mouseDownOrigin = L.point(clientX, clientY);\r\n\t},\r\n\r\n\t_onMouseUp: function (e) {\r\n\t\tvar originalEvent = e.originalEvent;\r\n\t\tvar clientX = originalEvent.clientX;\r\n\t\tvar clientY = originalEvent.clientY;\r\n\t\tthis._endPoint.call(this, clientX, clientY, e);\r\n\t\tthis._clickHandled = null;\r\n\t},\r\n\r\n\t_endPoint: function (clientX, clientY, e) {\r\n\t\tif (this._mouseDownOrigin) {\r\n\t\t\tvar dragCheckDistance = L.point(clientX, clientY)\r\n\t\t\t\t.distanceTo(this._mouseDownOrigin);\r\n\t\t\tvar lastPtDistance = this._calculateFinishDistance(e.latlng);\r\n\t\t\tif (this.options.maxPoints > 1 && this.options.maxPoints == this._markers.length + 1) {\r\n\t\t\t\tthis.addVertex(e.latlng);\r\n\t\t\t\tthis._finishShape();\r\n\t\t\t} else if (lastPtDistance < 10 && L.Browser.touch) {\r\n\t\t\t\tthis._finishShape();\r\n\t\t\t} else if (Math.abs(dragCheckDistance) < 9 * (window.devicePixelRatio || 1)) {\r\n\t\t\t\tthis.addVertex(e.latlng);\r\n\t\t\t}\r\n\t\t\tthis._enableNewMarkers(); // after a short pause, enable new markers\r\n\t\t}\r\n\t\tthis._mouseDownOrigin = null;\r\n\t},\r\n\r\n\t// ontouch prevented by clickHandled flag because some browsers fire both click/touch events,\r\n\t// causing unwanted behavior\r\n\t_onTouch: function (e) {\r\n\t\tvar originalEvent = e.originalEvent;\r\n\t\tvar clientX;\r\n\t\tvar clientY;\r\n\t\tif (originalEvent.touches && originalEvent.touches[0] && !this._clickHandled && !this._touchHandled && !this._disableMarkers) {\r\n\t\t\tclientX = originalEvent.touches[0].clientX;\r\n\t\t\tclientY = originalEvent.touches[0].clientY;\r\n\t\t\tthis._disableNewMarkers();\r\n\t\t\tthis._touchHandled = true;\r\n\t\t\tthis._startPoint.call(this, clientX, clientY);\r\n\t\t\tthis._endPoint.call(this, clientX, clientY, e);\r\n\t\t\tthis._touchHandled = null;\r\n\t\t}\r\n\t\tthis._clickHandled = null;\r\n\t},\r\n\r\n\t_onMouseOut: function () {\r\n\t\tif (this._tooltip) {\r\n\t\t\tthis._tooltip._onMouseOut.call(this._tooltip);\r\n\t\t}\r\n\t},\r\n\r\n\t// calculate if we are currently within close enough distance\r\n\t// of the closing point (first point for shapes, last point for lines)\r\n\t// this is semi-ugly code but the only reliable way i found to get the job done\r\n\t// note: calculating point.distanceTo between mouseDownOrigin and last marker did NOT work\r\n\t_calculateFinishDistance: function (potentialLatLng) {\r\n\t\tvar lastPtDistance;\r\n\t\tif (this._markers.length > 0) {\r\n\t\t\tvar finishMarker;\r\n\t\t\tif (this.type === L.Draw.Polyline.TYPE) {\r\n\t\t\t\tfinishMarker = this._markers[this._markers.length - 1];\r\n\t\t\t} else if (this.type === L.Draw.Polygon.TYPE) {\r\n\t\t\t\tfinishMarker = this._markers[0];\r\n\t\t\t} else {\r\n\t\t\t\treturn Infinity;\r\n\t\t\t}\r\n\t\t\tvar lastMarkerPoint = this._map.latLngToContainerPoint(finishMarker.getLatLng()),\r\n\t\t\t\tpotentialMarker = new L.Marker(potentialLatLng, {\r\n\t\t\t\t\ticon: this.options.icon,\r\n\t\t\t\t\tzIndexOffset: this.options.zIndexOffset * 2\r\n\t\t\t\t});\r\n\t\t\tvar potentialMarkerPint = this._map.latLngToContainerPoint(potentialMarker.getLatLng());\r\n\t\t\tlastPtDistance = lastMarkerPoint.distanceTo(potentialMarkerPint);\r\n\t\t} else {\r\n\t\t\tlastPtDistance = Infinity;\r\n\t\t}\r\n\t\treturn lastPtDistance;\r\n\t},\r\n\r\n\t_updateFinishHandler: function () {\r\n\t\tvar markerCount = this._markers.length;\r\n\t\t// The last marker should have a click handler to close the polyline\r\n\t\tif (markerCount > 1) {\r\n\t\t\tthis._markers[markerCount - 1].on('click', this._finishShape, this);\r\n\t\t}\r\n\r\n\t\t// Remove the old marker click handler (as only the last point should close the polyline)\r\n\t\tif (markerCount > 2) {\r\n\t\t\tthis._markers[markerCount - 2].off('click', this._finishShape, this);\r\n\t\t}\r\n\t},\r\n\r\n\t_createMarker: function (latlng) {\r\n\t\tvar marker = new L.Marker(latlng, {\r\n\t\t\ticon: this.options.icon,\r\n\t\t\tzIndexOffset: this.options.zIndexOffset * 2\r\n\t\t});\r\n\r\n\t\tthis._markerGroup.addLayer(marker);\r\n\r\n\t\treturn marker;\r\n\t},\r\n\r\n\t_updateGuide: function (newPos) {\r\n\t\tvar markerCount = this._markers ? this._markers.length : 0;\r\n\r\n\t\tif (markerCount > 0) {\r\n\t\t\tnewPos = newPos || this._map.latLngToLayerPoint(this._currentLatLng);\r\n\r\n\t\t\t// draw the guide line\r\n\t\t\tthis._clearGuides();\r\n\t\t\tthis._drawGuide(\r\n\t\t\t\tthis._map.latLngToLayerPoint(this._markers[markerCount - 1].getLatLng()),\r\n\t\t\t\tnewPos\r\n\t\t\t);\r\n\t\t}\r\n\t},\r\n\r\n\t_updateTooltip: function (latLng) {\r\n\t\tvar text = this._getTooltipText();\r\n\r\n\t\tif (latLng) {\r\n\t\t\tthis._tooltip.updatePosition(latLng);\r\n\t\t}\r\n\r\n\t\tif (!this._errorShown) {\r\n\t\t\tthis._tooltip.updateContent(text);\r\n\t\t}\r\n\t},\r\n\r\n\t_drawGuide: function (pointA, pointB) {\r\n\t\tvar length = Math.floor(Math.sqrt(Math.pow((pointB.x - pointA.x), 2) + Math.pow((pointB.y - pointA.y), 2))),\r\n\t\t\tguidelineDistance = this.options.guidelineDistance,\r\n\t\t\tmaxGuideLineLength = this.options.maxGuideLineLength,\r\n\t\t\t// Only draw a guideline with a max length\r\n\t\t\ti = length > maxGuideLineLength ? length - maxGuideLineLength : guidelineDistance,\r\n\t\t\tfraction,\r\n\t\t\tdashPoint,\r\n\t\t\tdash;\r\n\r\n\t\t//create the guides container if we haven't yet\r\n\t\tif (!this._guidesContainer) {\r\n\t\t\tthis._guidesContainer = L.DomUtil.create('div', 'leaflet-draw-guides', this._overlayPane);\r\n\t\t}\r\n\r\n\t\t//draw a dash every GuildeLineDistance\r\n\t\tfor (; i < length; i += this.options.guidelineDistance) {\r\n\t\t\t//work out fraction along line we are\r\n\t\t\tfraction = i / length;\r\n\r\n\t\t\t//calculate new x,y point\r\n\t\t\tdashPoint = {\r\n\t\t\t\tx: Math.floor((pointA.x * (1 - fraction)) + (fraction * pointB.x)),\r\n\t\t\t\ty: Math.floor((pointA.y * (1 - fraction)) + (fraction * pointB.y))\r\n\t\t\t};\r\n\r\n\t\t\t//add guide dash to guide container\r\n\t\t\tdash = L.DomUtil.create('div', 'leaflet-draw-guide-dash', this._guidesContainer);\r\n\t\t\tdash.style.backgroundColor =\r\n\t\t\t\t!this._errorShown ? this.options.shapeOptions.color : this.options.drawError.color;\r\n\r\n\t\t\tL.DomUtil.setPosition(dash, dashPoint);\r\n\t\t}\r\n\t},\r\n\r\n\t_updateGuideColor: function (color) {\r\n\t\tif (this._guidesContainer) {\r\n\t\t\tfor (var i = 0, l = this._guidesContainer.childNodes.length; i < l; i++) {\r\n\t\t\t\tthis._guidesContainer.childNodes[i].style.backgroundColor = color;\r\n\t\t\t}\r\n\t\t}\r\n\t},\r\n\r\n\t// removes all child elements (guide dashes) from the guides container\r\n\t_clearGuides: function () {\r\n\t\tif (this._guidesContainer) {\r\n\t\t\twhile (this._guidesContainer.firstChild) {\r\n\t\t\t\tthis._guidesContainer.removeChild(this._guidesContainer.firstChild);\r\n\t\t\t}\r\n\t\t}\r\n\t},\r\n\r\n\t_getTooltipText: function () {\r\n\t\tvar showLength = this.options.showLength,\r\n\t\t\tlabelText, distanceStr;\r\n\t\tif (this._markers.length === 0) {\r\n\t\t\tlabelText = {\r\n\t\t\t\ttext: L.drawLocal.draw.handlers.polyline.tooltip.start\r\n\t\t\t};\r\n\t\t} else {\r\n\t\t\tdistanceStr = showLength ? this._getMeasurementString() : '';\r\n\r\n\t\t\tif (this._markers.length === 1) {\r\n\t\t\t\tlabelText = {\r\n\t\t\t\t\ttext: L.drawLocal.draw.handlers.polyline.tooltip.cont,\r\n\t\t\t\t\tsubtext: distanceStr\r\n\t\t\t\t};\r\n\t\t\t} else {\r\n\t\t\t\tlabelText = {\r\n\t\t\t\t\ttext: L.drawLocal.draw.handlers.polyline.tooltip.end,\r\n\t\t\t\t\tsubtext: distanceStr\r\n\t\t\t\t};\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn labelText;\r\n\t},\r\n\r\n\t_updateRunningMeasure: function (latlng, added) {\r\n\t\tvar markersLength = this._markers.length,\r\n\t\t\tpreviousMarkerIndex, distance;\r\n\r\n\t\tif (this._markers.length === 1) {\r\n\t\t\tthis._measurementRunningTotal = 0;\r\n\t\t} else {\r\n\t\t\tpreviousMarkerIndex = markersLength - (added ? 2 : 1);\r\n\r\n\t\t\t// Calculate the distance based on the version\r\n\t\t\tif (L.GeometryUtil.isVersion07x()) {\r\n\t\t\t\tdistance = latlng.distanceTo(this._markers[previousMarkerIndex].getLatLng()) * (this.options.factor || 1);\r\n\t\t\t} else {\r\n\t\t\t\tdistance = this._map.distance(latlng, this._markers[previousMarkerIndex].getLatLng()) * (this.options.factor || 1);\r\n\t\t\t}\r\n\r\n\t\t\tthis._measurementRunningTotal += distance * (added ? 1 : -1);\r\n\t\t}\r\n\t},\r\n\r\n\t_getMeasurementString: function () {\r\n\t\tvar currentLatLng = this._currentLatLng,\r\n\t\t\tpreviousLatLng = this._markers[this._markers.length - 1].getLatLng(),\r\n\t\t\tdistance;\r\n\r\n\t\t// Calculate the distance from the last fixed point to the mouse position based on the version\r\n\t\tif (L.GeometryUtil.isVersion07x()) {\r\n\t\t\tdistance = previousLatLng && currentLatLng && currentLatLng.distanceTo ? this._measurementRunningTotal + currentLatLng.distanceTo(previousLatLng) * (this.options.factor || 1) : this._measurementRunningTotal || 0;\r\n\t\t} else {\r\n\t\t\tdistance = previousLatLng && currentLatLng ? this._measurementRunningTotal + this._map.distance(currentLatLng, previousLatLng) * (this.options.factor || 1) : this._measurementRunningTotal || 0;\r\n\t\t}\r\n\r\n\t\treturn L.GeometryUtil.readableDistance(distance, this.options.metric, this.options.feet, this.options.nautic, this.options.precision);\r\n\t},\r\n\r\n\t_showErrorTooltip: function () {\r\n\t\tthis._errorShown = true;\r\n\r\n\t\t// Update tooltip\r\n\t\tthis._tooltip\r\n\t\t\t.showAsError()\r\n\t\t\t.updateContent({text: this.options.drawError.message});\r\n\r\n\t\t// Update shape\r\n\t\tthis._updateGuideColor(this.options.drawError.color);\r\n\t\tthis._poly.setStyle({color: this.options.drawError.color});\r\n\r\n\t\t// Hide the error after 2 seconds\r\n\t\tthis._clearHideErrorTimeout();\r\n\t\tthis._hideErrorTimeout = setTimeout(L.Util.bind(this._hideErrorTooltip, this), this.options.drawError.timeout);\r\n\t},\r\n\r\n\t_hideErrorTooltip: function () {\r\n\t\tthis._errorShown = false;\r\n\r\n\t\tthis._clearHideErrorTimeout();\r\n\r\n\t\t// Revert tooltip\r\n\t\tthis._tooltip\r\n\t\t\t.removeError()\r\n\t\t\t.updateContent(this._getTooltipText());\r\n\r\n\t\t// Revert shape\r\n\t\tthis._updateGuideColor(this.options.shapeOptions.color);\r\n\t\tthis._poly.setStyle({color: this.options.shapeOptions.color});\r\n\t},\r\n\r\n\t_clearHideErrorTimeout: function () {\r\n\t\tif (this._hideErrorTimeout) {\r\n\t\t\tclearTimeout(this._hideErrorTimeout);\r\n\t\t\tthis._hideErrorTimeout = null;\r\n\t\t}\r\n\t},\r\n\r\n\t// disable new markers temporarily;\r\n\t// this is to prevent duplicated touch/click events in some browsers\r\n\t_disableNewMarkers: function () {\r\n\t\tthis._disableMarkers = true;\r\n\t},\r\n\r\n\t// see _disableNewMarkers\r\n\t_enableNewMarkers: function () {\r\n\t\tsetTimeout(function () {\r\n\t\t\tthis._disableMarkers = false;\r\n\t\t}.bind(this), 50);\r\n\t},\r\n\r\n\t_cleanUpShape: function () {\r\n\t\tif (this._markers.length > 1) {\r\n\t\t\tthis._markers[this._markers.length - 1].off('click', this._finishShape, this);\r\n\t\t}\r\n\t},\r\n\r\n\t_fireCreatedEvent: function () {\r\n\t\tvar poly = new this.Poly(this._poly.getLatLngs(), this.options.shapeOptions);\r\n\t\tL.Draw.Feature.prototype._fireCreatedEvent.call(this, poly);\r\n\t}\r\n});\r\n","/**\r\n * @class L.Draw.Polygon\r\n * @aka Draw.Polygon\r\n * @inherits L.Draw.Polyline\r\n */\r\nL.Draw.Polygon = L.Draw.Polyline.extend({\r\n\tstatics: {\r\n\t\tTYPE: 'polygon'\r\n\t},\r\n\r\n\tPoly: L.Polygon,\r\n\r\n\toptions: {\r\n\t\tshowArea: false,\r\n\t\tshowLength: false,\r\n\t\tshapeOptions: {\r\n\t\t\tstroke: true,\r\n\t\t\tcolor: '#3388ff',\r\n\t\t\tweight: 4,\r\n\t\t\topacity: 0.5,\r\n\t\t\tfill: true,\r\n\t\t\tfillColor: null, //same as color by default\r\n\t\t\tfillOpacity: 0.2,\r\n\t\t\tclickable: true\r\n\t\t},\r\n\t\t// Whether to use the metric measurement system (truthy) or not (falsy).\r\n\t\t// Also defines the units to use for the metric system as an array of\r\n\t\t// strings (e.g. `['ha', 'm']`).\r\n\t\tmetric: true,\r\n\t\tfeet: true, // When not metric, to use feet instead of yards for display.\r\n\t\tnautic: false, // When not metric, not feet use nautic mile for display\r\n\t\t// Defines the precision for each type of unit (e.g. {km: 2, ft: 0}\r\n\t\tprecision: {}\r\n\t},\r\n\r\n\t// @method initialize(): void\r\n\tinitialize: function (map, options) {\r\n\t\tL.Draw.Polyline.prototype.initialize.call(this, map, options);\r\n\r\n\t\t// Save the type so super can fire, need to do this as cannot do this.TYPE :(\r\n\t\tthis.type = L.Draw.Polygon.TYPE;\r\n\t},\r\n\r\n\t_updateFinishHandler: function () {\r\n\t\tvar markerCount = this._markers.length;\r\n\r\n\t\t// The first marker should have a click handler to close the polygon\r\n\t\tif (markerCount === 1) {\r\n\t\t\tthis._markers[0].on('click', this._finishShape, this);\r\n\t\t}\r\n\r\n\t\t// Add and update the double click handler\r\n\t\tif (markerCount > 2) {\r\n\t\t\tthis._markers[markerCount - 1].on('dblclick', this._finishShape, this);\r\n\t\t\t// Only need to remove handler if has been added before\r\n\t\t\tif (markerCount > 3) {\r\n\t\t\t\tthis._markers[markerCount - 2].off('dblclick', this._finishShape, this);\r\n\t\t\t}\r\n\t\t}\r\n\t},\r\n\r\n\t_getTooltipText: function () {\r\n\t\tvar text, subtext;\r\n\r\n\t\tif (this._markers.length === 0) {\r\n\t\t\ttext = L.drawLocal.draw.handlers.polygon.tooltip.start;\r\n\t\t} else if (this._markers.length < 3) {\r\n\t\t\ttext = L.drawLocal.draw.handlers.polygon.tooltip.cont;\r\n\t\t\tsubtext = this._getMeasurementString();\r\n\t\t} else {\r\n\t\t\ttext = L.drawLocal.draw.handlers.polygon.tooltip.end;\r\n\t\t\tsubtext = this._getMeasurementString();\r\n\t\t}\r\n\r\n\t\treturn {\r\n\t\t\ttext: text,\r\n\t\t\tsubtext: subtext\r\n\t\t};\r\n\t},\r\n\r\n\t_getMeasurementString: function () {\r\n\t\tvar area = this._area,\r\n\t\t\tmeasurementString = '';\r\n\r\n\r\n\t\tif (!area && !this.options.showLength) {\r\n\t\t\treturn null;\r\n\t\t}\r\n\r\n\t\tif (this.options.showLength) {\r\n\t\t\tmeasurementString = L.Draw.Polyline.prototype._getMeasurementString.call(this);\r\n\t\t}\r\n\r\n\t\tif (area) {\r\n\t\t\tmeasurementString += '
' + L.GeometryUtil.readableArea(area, this.options.metric, this.options.precision);\r\n\t\t}\r\n\r\n\t\treturn measurementString;\r\n\t},\r\n\r\n\t_shapeIsValid: function () {\r\n\t\treturn this._markers.length >= 3;\r\n\t},\r\n\r\n\t_vertexChanged: function (latlng, added) {\r\n\t\tvar latLngs;\r\n\r\n\t\t// Check to see if we should show the area\r\n\t\tif (!this.options.allowIntersection && this.options.showArea) {\r\n\t\t\tlatLngs = this._poly.getLatLngs();\r\n\r\n\t\t\tthis._area = L.GeometryUtil.geodesicArea(latLngs);\r\n\t\t}\r\n\r\n\t\tL.Draw.Polyline.prototype._vertexChanged.call(this, latlng, added);\r\n\t},\r\n\r\n\t_cleanUpShape: function () {\r\n\t\tvar markerCount = this._markers.length;\r\n\r\n\t\tif (markerCount > 0) {\r\n\t\t\tthis._markers[0].off('click', this._finishShape, this);\r\n\r\n\t\t\tif (markerCount > 2) {\r\n\t\t\t\tthis._markers[markerCount - 1].off('dblclick', this._finishShape, this);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n});\r\n","L.SimpleShape = {};\r\n/**\r\n * @class L.Draw.SimpleShape\r\n * @aka Draw.SimpleShape\r\n * @inherits L.Draw.Feature\r\n */\r\nL.Draw.SimpleShape = L.Draw.Feature.extend({\r\n\toptions: {\r\n\t\trepeatMode: false\r\n\t},\r\n\r\n\t// @method initialize(): void\r\n\tinitialize: function (map, options) {\r\n\t\tthis._endLabelText = L.drawLocal.draw.handlers.simpleshape.tooltip.end;\r\n\r\n\t\tL.Draw.Feature.prototype.initialize.call(this, map, options);\r\n\t},\r\n\r\n\t// @method addHooks(): void\r\n\t// Add listener hooks to this handler.\r\n\taddHooks: function () {\r\n\t\tL.Draw.Feature.prototype.addHooks.call(this);\r\n\t\tif (this._map) {\r\n\t\t\tthis._mapDraggable = this._map.dragging.enabled();\r\n\r\n\t\t\tif (this._mapDraggable) {\r\n\t\t\t\tthis._map.dragging.disable();\r\n\t\t\t}\r\n\r\n\t\t\t//TODO refactor: move cursor to styles\r\n\t\t\tthis._container.style.cursor = 'crosshair';\r\n\r\n\t\t\tthis._tooltip.updateContent({text: this._initialLabelText});\r\n\r\n\t\t\tthis._map\r\n\t\t\t\t.on('mousedown', this._onMouseDown, this)\r\n\t\t\t\t.on('mousemove', this._onMouseMove, this)\r\n\t\t\t\t.on('touchstart', this._onMouseDown, this)\r\n\t\t\t\t.on('touchmove', this._onMouseMove, this);\r\n\r\n\t\t\t// we should prevent default, otherwise default behavior (scrolling) will fire,\r\n\t\t\t// and that will cause document.touchend to fire and will stop the drawing\r\n\t\t\t// (circle, rectangle) in touch mode.\r\n\t\t\t// (update): we have to send passive now to prevent scroll, because by default it is {passive: true} now, which means,\r\n\t\t\t// handler can't event.preventDefault\r\n\t\t\t// check the news https://developers.google.com/web/updates/2016/06/passive-event-listeners\r\n\t\t\tdocument.addEventListener('touchstart', L.DomEvent.preventDefault, {passive: false});\r\n\t\t}\r\n\t},\r\n\r\n\t// @method removeHooks(): void\r\n\t// Remove listener hooks from this handler.\r\n\tremoveHooks: function () {\r\n\t\tL.Draw.Feature.prototype.removeHooks.call(this);\r\n\t\tif (this._map) {\r\n\t\t\tif (this._mapDraggable) {\r\n\t\t\t\tthis._map.dragging.enable();\r\n\t\t\t}\r\n\r\n\t\t\t//TODO refactor: move cursor to styles\r\n\t\t\tthis._container.style.cursor = '';\r\n\r\n\t\t\tthis._map\r\n\t\t\t\t.off('mousedown', this._onMouseDown, this)\r\n\t\t\t\t.off('mousemove', this._onMouseMove, this)\r\n\t\t\t\t.off('touchstart', this._onMouseDown, this)\r\n\t\t\t\t.off('touchmove', this._onMouseMove, this);\r\n\r\n\t\t\tL.DomEvent.off(document, 'mouseup', this._onMouseUp, this);\r\n\t\t\tL.DomEvent.off(document, 'touchend', this._onMouseUp, this);\r\n\r\n\t\t\tdocument.removeEventListener('touchstart', L.DomEvent.preventDefault);\r\n\r\n\t\t\t// If the box element doesn't exist they must not have moved the mouse, so don't need to destroy/return\r\n\t\t\tif (this._shape) {\r\n\t\t\t\tthis._map.removeLayer(this._shape);\r\n\t\t\t\tdelete this._shape;\r\n\t\t\t}\r\n\t\t}\r\n\t\tthis._isDrawing = false;\r\n\t},\r\n\r\n\t_getTooltipText: function () {\r\n\t\treturn {\r\n\t\t\ttext: this._endLabelText\r\n\t\t};\r\n\t},\r\n\r\n\t_onMouseDown: function (e) {\r\n\t\tthis._isDrawing = true;\r\n\t\tthis._startLatLng = e.latlng;\r\n\r\n\t\tL.DomEvent\r\n\t\t\t.on(document, 'mouseup', this._onMouseUp, this)\r\n\t\t\t.on(document, 'touchend', this._onMouseUp, this)\r\n\t\t\t.preventDefault(e.originalEvent);\r\n\t},\r\n\r\n\t_onMouseMove: function (e) {\r\n\t\tvar latlng = e.latlng;\r\n\r\n\t\tthis._tooltip.updatePosition(latlng);\r\n\t\tif (this._isDrawing) {\r\n\t\t\tthis._tooltip.updateContent(this._getTooltipText());\r\n\t\t\tthis._drawShape(latlng);\r\n\t\t}\r\n\t},\r\n\r\n\t_onMouseUp: function () {\r\n\t\tif (this._shape) {\r\n\t\t\tthis._fireCreatedEvent();\r\n\t\t}\r\n\r\n\t\tthis.disable();\r\n\t\tif (this.options.repeatMode) {\r\n\t\t\tthis.enable();\r\n\t\t}\r\n\t}\r\n});\r\n","/**\r\n * @class L.Draw.Rectangle\r\n * @aka Draw.Rectangle\r\n * @inherits L.Draw.SimpleShape\r\n */\r\nL.Draw.Rectangle = L.Draw.SimpleShape.extend({\r\n\tstatics: {\r\n\t\tTYPE: 'rectangle'\r\n\t},\r\n\r\n\toptions: {\r\n\t\tshapeOptions: {\r\n\t\t\tstroke: true,\r\n\t\t\tcolor: '#3388ff',\r\n\t\t\tweight: 4,\r\n\t\t\topacity: 0.5,\r\n\t\t\tfill: true,\r\n\t\t\tfillColor: null, //same as color by default\r\n\t\t\tfillOpacity: 0.2,\r\n\t\t\tclickable: true\r\n\t\t},\r\n\t\tshowArea: true, //Whether to show the area in the tooltip\r\n\t\tmetric: true // Whether to use the metric measurement system or imperial\r\n\t},\r\n\r\n\t// @method initialize(): void\r\n\tinitialize: function (map, options) {\r\n\t\t// Save the type so super can fire, need to do this as cannot do this.TYPE :(\r\n\t\tthis.type = L.Draw.Rectangle.TYPE;\r\n\r\n\t\tthis._initialLabelText = L.drawLocal.draw.handlers.rectangle.tooltip.start;\r\n\r\n\t\tL.Draw.SimpleShape.prototype.initialize.call(this, map, options);\r\n\t},\r\n\r\n\t// @method disable(): void\r\n\tdisable: function () {\r\n\t\tif (!this._enabled) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tthis._isCurrentlyTwoClickDrawing = false;\r\n\t\tL.Draw.SimpleShape.prototype.disable.call(this);\r\n\t},\r\n\r\n\t_onMouseUp: function (e) {\r\n\t\tif (!this._shape && !this._isCurrentlyTwoClickDrawing) {\r\n\t\t\tthis._isCurrentlyTwoClickDrawing = true;\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\t// Make sure closing click is on map\r\n\t\tif (this._isCurrentlyTwoClickDrawing && !_hasAncestor(e.target, 'leaflet-pane')) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tL.Draw.SimpleShape.prototype._onMouseUp.call(this);\r\n\t},\r\n\r\n\t_drawShape: function (latlng) {\r\n\t\tif (!this._shape) {\r\n\t\t\tthis._shape = new L.Rectangle(new L.LatLngBounds(this._startLatLng, latlng), this.options.shapeOptions);\r\n\t\t\tthis._map.addLayer(this._shape);\r\n\t\t} else {\r\n\t\t\tthis._shape.setBounds(new L.LatLngBounds(this._startLatLng, latlng));\r\n\t\t}\r\n\t},\r\n\r\n\t_fireCreatedEvent: function () {\r\n\t\tvar rectangle = new L.Rectangle(this._shape.getBounds(), this.options.shapeOptions);\r\n\t\tL.Draw.SimpleShape.prototype._fireCreatedEvent.call(this, rectangle);\r\n\t},\r\n\r\n\t_getTooltipText: function () {\r\n\t\tvar tooltipText = L.Draw.SimpleShape.prototype._getTooltipText.call(this),\r\n\t\t\tshape = this._shape,\r\n\t\t\tshowArea = this.options.showArea,\r\n\t\t\tlatLngs, area, subtext;\r\n\r\n\t\tif (shape) {\r\n\t\t\tlatLngs = this._shape._defaultShape ? this._shape._defaultShape() : this._shape.getLatLngs();\r\n\t\t\tarea = L.GeometryUtil.geodesicArea(latLngs);\r\n\t\t\tsubtext = showArea ? L.GeometryUtil.readableArea(area, this.options.metric) : '';\r\n\t\t}\r\n\r\n\t\treturn {\r\n\t\t\ttext: tooltipText.text,\r\n\t\t\tsubtext: subtext\r\n\t\t};\r\n\t}\r\n});\r\n\r\nfunction _hasAncestor(el, cls) {\r\n\twhile ((el = el.parentElement) && !el.classList.contains(cls)) {\r\n\t\t;\r\n\t}\r\n\treturn el;\r\n}\r\n","/**\r\n * @class L.Draw.Marker\r\n * @aka Draw.Marker\r\n * @inherits L.Draw.Feature\r\n */\r\nL.Draw.Marker = L.Draw.Feature.extend({\r\n\tstatics: {\r\n\t\tTYPE: 'marker'\r\n\t},\r\n\r\n\toptions: {\r\n\t\ticon: new L.Icon.Default(),\r\n\t\trepeatMode: false,\r\n\t\tzIndexOffset: 2000 // This should be > than the highest z-index any markers\r\n\t},\r\n\r\n\t// @method initialize(): void\r\n\tinitialize: function (map, options) {\r\n\t\t// Save the type so super can fire, need to do this as cannot do this.TYPE :(\r\n\t\tthis.type = L.Draw.Marker.TYPE;\r\n\r\n\t\tthis._initialLabelText = L.drawLocal.draw.handlers.marker.tooltip.start;\r\n\r\n\t\tL.Draw.Feature.prototype.initialize.call(this, map, options);\r\n\t},\r\n\r\n\t// @method addHooks(): void\r\n\t// Add listener hooks to this handler.\r\n\taddHooks: function () {\r\n\t\tL.Draw.Feature.prototype.addHooks.call(this);\r\n\r\n\t\tif (this._map) {\r\n\t\t\tthis._tooltip.updateContent({text: this._initialLabelText});\r\n\r\n\t\t\t// Same mouseMarker as in Draw.Polyline\r\n\t\t\tif (!this._mouseMarker) {\r\n\t\t\t\tthis._mouseMarker = L.marker(this._map.getCenter(), {\r\n\t\t\t\t\ticon: L.divIcon({\r\n\t\t\t\t\t\tclassName: 'leaflet-mouse-marker',\r\n\t\t\t\t\t\ticonAnchor: [20, 20],\r\n\t\t\t\t\t\ticonSize: [40, 40]\r\n\t\t\t\t\t}),\r\n\t\t\t\t\topacity: 0,\r\n\t\t\t\t\tzIndexOffset: this.options.zIndexOffset\r\n\t\t\t\t});\r\n\t\t\t}\r\n\r\n\t\t\tthis._mouseMarker\r\n\t\t\t\t.on('click', this._onClick, this)\r\n\t\t\t\t.addTo(this._map);\r\n\r\n\t\t\tthis._map.on('mousemove', this._onMouseMove, this);\r\n\t\t\tthis._map.on('click', this._onTouch, this);\r\n\t\t}\r\n\t},\r\n\r\n\t// @method removeHooks(): void\r\n\t// Remove listener hooks from this handler.\r\n\tremoveHooks: function () {\r\n\t\tL.Draw.Feature.prototype.removeHooks.call(this);\r\n\r\n\t\tif (this._map) {\r\n\t\t\tthis._map\r\n\t\t\t\t.off('click', this._onClick, this)\r\n\t\t\t\t.off('click', this._onTouch, this);\r\n\t\t\tif (this._marker) {\r\n\t\t\t\tthis._marker.off('click', this._onClick, this);\r\n\t\t\t\tthis._map\r\n\t\t\t\t\t.removeLayer(this._marker);\r\n\t\t\t\tdelete this._marker;\r\n\t\t\t}\r\n\r\n\t\t\tthis._mouseMarker.off('click', this._onClick, this);\r\n\t\t\tthis._map.removeLayer(this._mouseMarker);\r\n\t\t\tdelete this._mouseMarker;\r\n\r\n\t\t\tthis._map.off('mousemove', this._onMouseMove, this);\r\n\t\t}\r\n\t},\r\n\r\n\t_onMouseMove: function (e) {\r\n\t\tvar latlng = e.latlng;\r\n\r\n\t\tthis._tooltip.updatePosition(latlng);\r\n\t\tthis._mouseMarker.setLatLng(latlng);\r\n\r\n\t\tif (!this._marker) {\r\n\t\t\tthis._marker = this._createMarker(latlng);\r\n\t\t\t// Bind to both marker and map to make sure we get the click event.\r\n\t\t\tthis._marker.on('click', this._onClick, this);\r\n\t\t\tthis._map\r\n\t\t\t\t.on('click', this._onClick, this)\r\n\t\t\t\t.addLayer(this._marker);\r\n\t\t}\r\n\t\telse {\r\n\t\t\tlatlng = this._mouseMarker.getLatLng();\r\n\t\t\tthis._marker.setLatLng(latlng);\r\n\t\t}\r\n\t},\r\n\r\n\t_createMarker: function (latlng) {\r\n\t\treturn new L.Marker(latlng, {\r\n\t\t\ticon: this.options.icon,\r\n\t\t\tzIndexOffset: this.options.zIndexOffset\r\n\t\t});\r\n\t},\r\n\r\n\t_onClick: function () {\r\n\t\tthis._fireCreatedEvent();\r\n\r\n\t\tthis.disable();\r\n\t\tif (this.options.repeatMode) {\r\n\t\t\tthis.enable();\r\n\t\t}\r\n\t},\r\n\r\n\t_onTouch: function (e) {\r\n\t\t// called on click & tap, only really does any thing on tap\r\n\t\tthis._onMouseMove(e); // creates & places marker\r\n\t\tthis._onClick(); // permanently places marker & ends interaction\r\n\t},\r\n\r\n\t_fireCreatedEvent: function () {\r\n\t\tvar marker = new L.Marker.Touch(this._marker.getLatLng(), {icon: this.options.icon});\r\n\t\tL.Draw.Feature.prototype._fireCreatedEvent.call(this, marker);\r\n\t}\r\n});\r\n","/**\r\n * @class L.Draw.CircleMarker\r\n * @aka Draw.CircleMarker\r\n * @inherits L.Draw.Marker\r\n */\r\nL.Draw.CircleMarker = L.Draw.Marker.extend({\r\n\tstatics: {\r\n\t\tTYPE: 'circlemarker'\r\n\t},\r\n\r\n\toptions: {\r\n\t\tstroke: true,\r\n\t\tcolor: '#3388ff',\r\n\t\tweight: 4,\r\n\t\topacity: 0.5,\r\n\t\tfill: true,\r\n\t\tfillColor: null, //same as color by default\r\n\t\tfillOpacity: 0.2,\r\n\t\tclickable: true,\r\n\t\tzIndexOffset: 2000 // This should be > than the highest z-index any markers\r\n\t},\r\n\r\n\t// @method initialize(): void\r\n\tinitialize: function (map, options) {\r\n\t\t// Save the type so super can fire, need to do this as cannot do this.TYPE :(\r\n\t\tthis.type = L.Draw.CircleMarker.TYPE;\r\n\r\n\t\tthis._initialLabelText = L.drawLocal.draw.handlers.circlemarker.tooltip.start;\r\n\r\n\t\tL.Draw.Feature.prototype.initialize.call(this, map, options);\r\n\t},\r\n\r\n\r\n\t_fireCreatedEvent: function () {\r\n\t\tvar circleMarker = new L.CircleMarker(this._marker.getLatLng(), this.options);\r\n\t\tL.Draw.Feature.prototype._fireCreatedEvent.call(this, circleMarker);\r\n\t},\r\n\r\n\t_createMarker: function (latlng) {\r\n\t\treturn new L.CircleMarker(latlng, this.options);\r\n\t}\r\n});\r\n","/**\r\n * @class L.Draw.Circle\r\n * @aka Draw.Circle\r\n * @inherits L.Draw.SimpleShape\r\n */\r\nL.Draw.Circle = L.Draw.SimpleShape.extend({\r\n\tstatics: {\r\n\t\tTYPE: 'circle'\r\n\t},\r\n\r\n\toptions: {\r\n\t\tshapeOptions: {\r\n\t\t\tstroke: true,\r\n\t\t\tcolor: '#3388ff',\r\n\t\t\tweight: 4,\r\n\t\t\topacity: 0.5,\r\n\t\t\tfill: true,\r\n\t\t\tfillColor: null, //same as color by default\r\n\t\t\tfillOpacity: 0.2,\r\n\t\t\tclickable: true\r\n\t\t},\r\n\t\tshowRadius: true,\r\n\t\tmetric: true, // Whether to use the metric measurement system or imperial\r\n\t\tfeet: true, // When not metric, use feet instead of yards for display\r\n\t\tnautic: false // When not metric, not feet use nautic mile for display\r\n\t},\r\n\r\n\t// @method initialize(): void\r\n\tinitialize: function (map, options) {\r\n\t\t// Save the type so super can fire, need to do this as cannot do this.TYPE :(\r\n\t\tthis.type = L.Draw.Circle.TYPE;\r\n\r\n\t\tthis._initialLabelText = L.drawLocal.draw.handlers.circle.tooltip.start;\r\n\r\n\t\tL.Draw.SimpleShape.prototype.initialize.call(this, map, options);\r\n\t},\r\n\r\n\t_drawShape: function (latlng) {\r\n\t\t// Calculate the distance based on the version\r\n\t\tif (L.GeometryUtil.isVersion07x()) {\r\n\t\t\tvar distance = this._startLatLng.distanceTo(latlng);\r\n\t\t} else {\r\n\t\t\tvar distance = this._map.distance(this._startLatLng, latlng);\r\n\t\t}\r\n\r\n\t\tif (!this._shape) {\r\n\t\t\tthis._shape = new L.Circle(this._startLatLng, distance, this.options.shapeOptions);\r\n\t\t\tthis._map.addLayer(this._shape);\r\n\t\t} else {\r\n\t\t\tthis._shape.setRadius(distance);\r\n\t\t}\r\n\t},\r\n\r\n\t_fireCreatedEvent: function () {\r\n\t\tvar circle = new L.Circle(this._startLatLng, this._shape.getRadius(), this.options.shapeOptions);\r\n\t\tL.Draw.SimpleShape.prototype._fireCreatedEvent.call(this, circle);\r\n\t},\r\n\r\n\t_onMouseMove: function (e) {\r\n\t\tvar latlng = e.latlng,\r\n\t\t\tshowRadius = this.options.showRadius,\r\n\t\t\tuseMetric = this.options.metric,\r\n\t\t\tradius;\r\n\r\n\t\tthis._tooltip.updatePosition(latlng);\r\n\t\tif (this._isDrawing) {\r\n\t\t\tthis._drawShape(latlng);\r\n\r\n\t\t\t// Get the new radius (rounded to 1 dp)\r\n\t\t\tradius = this._shape.getRadius().toFixed(1);\r\n\r\n\t\t\tvar subtext = '';\r\n\t\t\tif (showRadius) {\r\n\t\t\t\tsubtext = L.drawLocal.draw.handlers.circle.radius + ': ' +\r\n\t\t\t\t\tL.GeometryUtil.readableDistance(radius, useMetric, this.options.feet, this.options.nautic);\r\n\t\t\t}\r\n\t\t\tthis._tooltip.updateContent({\r\n\t\t\t\ttext: this._endLabelText,\r\n\t\t\t\tsubtext: subtext\r\n\t\t\t});\r\n\t\t}\r\n\t}\r\n});\r\n","L.Edit = L.Edit || {};\r\n\r\n/**\r\n * @class L.Edit.Marker\r\n * @aka Edit.Marker\r\n */\r\nL.Edit.Marker = L.Handler.extend({\r\n\t// @method initialize(): void\r\n\tinitialize: function (marker, options) {\r\n\t\tthis._marker = marker;\r\n\t\tL.setOptions(this, options);\r\n\t},\r\n\r\n\t// @method addHooks(): void\r\n\t// Add listener hooks to this handler\r\n\taddHooks: function () {\r\n\t\tvar marker = this._marker;\r\n\r\n\t\tmarker.dragging.enable();\r\n\t\tmarker.on('dragend', this._onDragEnd, marker);\r\n\t\tthis._toggleMarkerHighlight();\r\n\t},\r\n\r\n\t// @method removeHooks(): void\r\n\t// Remove listener hooks from this handler\r\n\tremoveHooks: function () {\r\n\t\tvar marker = this._marker;\r\n\r\n\t\tmarker.dragging.disable();\r\n\t\tmarker.off('dragend', this._onDragEnd, marker);\r\n\t\tthis._toggleMarkerHighlight();\r\n\t},\r\n\r\n\t_onDragEnd: function (e) {\r\n\t\tvar layer = e.target;\r\n\t\tlayer.edited = true;\r\n\t\tthis._map.fire(L.Draw.Event.EDITMOVE, {layer: layer});\r\n\t},\r\n\r\n\t_toggleMarkerHighlight: function () {\r\n\t\tvar icon = this._marker._icon;\r\n\r\n\t\t// Don't do anything if this layer is a marker but doesn't have an icon. Markers\r\n\t\t// should usually have icons. If using Leaflet.draw with Leaflet.markercluster there\r\n\t\t// is a chance that a marker doesn't.\r\n\t\tif (!icon) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\t// This is quite naughty, but I don't see another way of doing it. (short of setting a new icon)\r\n\t\ticon.style.display = 'none';\r\n\r\n\t\tif (L.DomUtil.hasClass(icon, 'leaflet-edit-marker-selected')) {\r\n\t\t\tL.DomUtil.removeClass(icon, 'leaflet-edit-marker-selected');\r\n\t\t\t// Offset as the border will make the icon move.\r\n\t\t\tthis._offsetMarker(icon, -4);\r\n\r\n\t\t} else {\r\n\t\t\tL.DomUtil.addClass(icon, 'leaflet-edit-marker-selected');\r\n\t\t\t// Offset as the border will make the icon move.\r\n\t\t\tthis._offsetMarker(icon, 4);\r\n\t\t}\r\n\r\n\t\ticon.style.display = '';\r\n\t},\r\n\r\n\t_offsetMarker: function (icon, offset) {\r\n\t\tvar iconMarginTop = parseInt(icon.style.marginTop, 10) - offset,\r\n\t\t\ticonMarginLeft = parseInt(icon.style.marginLeft, 10) - offset;\r\n\r\n\t\ticon.style.marginTop = iconMarginTop + 'px';\r\n\t\ticon.style.marginLeft = iconMarginLeft + 'px';\r\n\t}\r\n});\r\n\r\nL.Marker.addInitHook(function () {\r\n\tif (L.Edit.Marker) {\r\n\t\tthis.editing = new L.Edit.Marker(this);\r\n\r\n\t\tif (this.options.editable) {\r\n\t\t\tthis.editing.enable();\r\n\t\t}\r\n\t}\r\n});\r\n","L.Edit = L.Edit || {};\r\n\r\n/**\r\n * @class L.Edit.Polyline\r\n * @aka L.Edit.Poly\r\n * @aka Edit.Poly\r\n */\r\nL.Edit.Poly = L.Handler.extend({\r\n\t// @method initialize(): void\r\n\tinitialize: function (poly) {\r\n\r\n\t\tthis.latlngs = [poly._latlngs];\r\n\t\tif (poly._holes) {\r\n\t\t\tthis.latlngs = this.latlngs.concat(poly._holes);\r\n\t\t}\r\n\r\n\t\tthis._poly = poly;\r\n\r\n\t\tthis._poly.on('revert-edited', this._updateLatLngs, this);\r\n\t},\r\n\r\n\t// Compatibility method to normalize Poly* objects\r\n\t// between 0.7.x and 1.0+\r\n\t_defaultShape: function () {\r\n\t\tif (!L.Polyline._flat) {\r\n\t\t\treturn this._poly._latlngs;\r\n\t\t}\r\n\t\treturn L.Polyline._flat(this._poly._latlngs) ? this._poly._latlngs : this._poly._latlngs[0];\r\n\t},\r\n\r\n\t_eachVertexHandler: function (callback) {\r\n\t\tfor (var i = 0; i < this._verticesHandlers.length; i++) {\r\n\t\t\tcallback(this._verticesHandlers[i]);\r\n\t\t}\r\n\t},\r\n\r\n\t// @method addHooks(): void\r\n\t// Add listener hooks to this handler\r\n\taddHooks: function () {\r\n\t\tthis._initHandlers();\r\n\t\tthis._eachVertexHandler(function (handler) {\r\n\t\t\thandler.addHooks();\r\n\t\t});\r\n\t},\r\n\r\n\t// @method removeHooks(): void\r\n\t// Remove listener hooks from this handler\r\n\tremoveHooks: function () {\r\n\t\tthis._eachVertexHandler(function (handler) {\r\n\t\t\thandler.removeHooks();\r\n\t\t});\r\n\t},\r\n\r\n\t// @method updateMarkers(): void\r\n\t// Fire an update for each vertex handler\r\n\tupdateMarkers: function () {\r\n\t\tthis._eachVertexHandler(function (handler) {\r\n\t\t\thandler.updateMarkers();\r\n\t\t});\r\n\t},\r\n\r\n\t_initHandlers: function () {\r\n\t\tthis._verticesHandlers = [];\r\n\t\tfor (var i = 0; i < this.latlngs.length; i++) {\r\n\t\t\tthis._verticesHandlers.push(new L.Edit.PolyVerticesEdit(this._poly, this.latlngs[i], this._poly.options.poly));\r\n\t\t}\r\n\t},\r\n\r\n\t_updateLatLngs: function (e) {\r\n\t\tthis.latlngs = [e.layer._latlngs];\r\n\t\tif (e.layer._holes) {\r\n\t\t\tthis.latlngs = this.latlngs.concat(e.layer._holes);\r\n\t\t}\r\n\t}\r\n\r\n});\r\n\r\n/**\r\n * @class L.Edit.PolyVerticesEdit\r\n * @aka Edit.PolyVerticesEdit\r\n */\r\nL.Edit.PolyVerticesEdit = L.Handler.extend({\r\n\toptions: {\r\n\t\ticon: new L.DivIcon({\r\n\t\t\ticonSize: new L.Point(8, 8),\r\n\t\t\tclassName: 'leaflet-div-icon leaflet-editing-icon'\r\n\t\t}),\r\n\t\ttouchIcon: new L.DivIcon({\r\n\t\t\ticonSize: new L.Point(20, 20),\r\n\t\t\tclassName: 'leaflet-div-icon leaflet-editing-icon leaflet-touch-icon'\r\n\t\t}),\r\n\t\tdrawError: {\r\n\t\t\tcolor: '#b00b00',\r\n\t\t\ttimeout: 1000\r\n\t\t}\r\n\r\n\r\n\t},\r\n\r\n\t// @method intialize(): void\r\n\tinitialize: function (poly, latlngs, options) {\r\n\t\t// if touch, switch to touch icon\r\n\t\tif (L.Browser.touch) {\r\n\t\t\tthis.options.icon = this.options.touchIcon;\r\n\t\t}\r\n\t\tthis._poly = poly;\r\n\r\n\t\tif (options && options.drawError) {\r\n\t\t\toptions.drawError = L.Util.extend({}, this.options.drawError, options.drawError);\r\n\t\t}\r\n\r\n\t\tthis._latlngs = latlngs;\r\n\r\n\t\tL.setOptions(this, options);\r\n\t},\r\n\r\n\t// Compatibility method to normalize Poly* objects\r\n\t// between 0.7.x and 1.0+\r\n\t_defaultShape: function () {\r\n\t\tif (!L.Polyline._flat) {\r\n\t\t\treturn this._latlngs;\r\n\t\t}\r\n\t\treturn L.Polyline._flat(this._latlngs) ? this._latlngs : this._latlngs[0];\r\n\t},\r\n\r\n\t// @method addHooks(): void\r\n\t// Add listener hooks to this handler.\r\n\taddHooks: function () {\r\n\t\tvar poly = this._poly;\r\n\t\tvar path = poly._path;\r\n\r\n\t\tif (!(poly instanceof L.Polygon)) {\r\n\t\t\tpoly.options.fill = false;\r\n\t\t\tif (poly.options.editing) {\r\n\t\t\t\tpoly.options.editing.fill = false;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (path) {\r\n\t\t\tif (poly.options.editing && poly.options.editing.className) {\r\n\t\t\t\tif (poly.options.original.className) {\r\n\t\t\t\t\tpoly.options.original.className.split(' ').forEach(function (className) {\r\n\t\t\t\t\t\tL.DomUtil.removeClass(path, className);\r\n\t\t\t\t\t});\r\n\t\t\t\t}\r\n\t\t\t\tpoly.options.editing.className.split(' ').forEach(function (className) {\r\n\t\t\t\t\tL.DomUtil.addClass(path, className);\r\n\t\t\t\t});\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tpoly.setStyle(poly.options.editing);\r\n\r\n\t\tif (this._poly._map) {\r\n\r\n\t\t\tthis._map = this._poly._map; // Set map\r\n\r\n\t\t\tif (!this._markerGroup) {\r\n\t\t\t\tthis._initMarkers();\r\n\t\t\t}\r\n\t\t\tthis._poly._map.addLayer(this._markerGroup);\r\n\t\t}\r\n\t},\r\n\r\n\t// @method removeHooks(): void\r\n\t// Remove listener hooks from this handler.\r\n\tremoveHooks: function () {\r\n\t\tvar poly = this._poly;\r\n\t\tvar path = poly._path;\r\n\r\n\t\tif (path) {\r\n\t\t\tif (poly.options.editing && poly.options.editing.className) {\r\n\t\t\t\tpoly.options.editing.className.split(' ').forEach(function (className) {\r\n\t\t\t\t\tL.DomUtil.removeClass(path, className);\r\n\t\t\t\t});\r\n\t\t\t\tif (poly.options.original.className) {\r\n\t\t\t\t\tpoly.options.original.className.split(' ').forEach(function (className) {\r\n\t\t\t\t\t\tL.DomUtil.addClass(path, className);\r\n\t\t\t\t\t});\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tpoly.setStyle(poly.options.original);\r\n\r\n\t\tif (poly._map) {\r\n\t\t\tpoly._map.removeLayer(this._markerGroup);\r\n\t\t\tdelete this._markerGroup;\r\n\t\t\tdelete this._markers;\r\n\t\t}\r\n\t},\r\n\r\n\t// @method updateMarkers(): void\r\n\t// Clear markers and update their location\r\n\tupdateMarkers: function () {\r\n\t\tthis._markerGroup.clearLayers();\r\n\t\tthis._initMarkers();\r\n\t},\r\n\r\n\t_initMarkers: function () {\r\n\t\tif (!this._markerGroup) {\r\n\t\t\tthis._markerGroup = new L.LayerGroup();\r\n\t\t}\r\n\t\tthis._markers = [];\r\n\r\n\t\tvar latlngs = this._defaultShape(),\r\n\t\t\ti, j, len, marker;\r\n\r\n\t\tfor (i = 0, len = latlngs.length; i < len; i++) {\r\n\r\n\t\t\tmarker = this._createMarker(latlngs[i], i);\r\n\t\t\tmarker.on('click', this._onMarkerClick, this);\r\n\t\t\tmarker.on('contextmenu', this._onContextMenu, this);\r\n\t\t\tthis._markers.push(marker);\r\n\t\t}\r\n\r\n\t\tvar markerLeft, markerRight;\r\n\r\n\t\tfor (i = 0, j = len - 1; i < len; j = i++) {\r\n\t\t\tif (i === 0 && !(L.Polygon && (this._poly instanceof L.Polygon))) {\r\n\t\t\t\tcontinue;\r\n\t\t\t}\r\n\r\n\t\t\tmarkerLeft = this._markers[j];\r\n\t\t\tmarkerRight = this._markers[i];\r\n\r\n\t\t\tthis._createMiddleMarker(markerLeft, markerRight);\r\n\t\t\tthis._updatePrevNext(markerLeft, markerRight);\r\n\t\t}\r\n\t},\r\n\r\n\t_createMarker: function (latlng, index) {\r\n\t\t// Extending L.Marker in TouchEvents.js to include touch.\r\n\t\tvar marker = new L.Marker.Touch(latlng, {\r\n\t\t\tdraggable: true,\r\n\t\t\ticon: this.options.icon,\r\n\t\t});\r\n\r\n\t\tmarker._origLatLng = latlng;\r\n\t\tmarker._index = index;\r\n\r\n\t\tmarker\r\n\t\t\t.on('dragstart', this._onMarkerDragStart, this)\r\n\t\t\t.on('drag', this._onMarkerDrag, this)\r\n\t\t\t.on('dragend', this._fireEdit, this)\r\n\t\t\t.on('touchmove', this._onTouchMove, this)\r\n\t\t\t.on('touchend', this._fireEdit, this)\r\n\t\t\t.on('MSPointerMove', this._onTouchMove, this)\r\n\t\t\t.on('MSPointerUp', this._fireEdit, this);\r\n\r\n\t\tthis._markerGroup.addLayer(marker);\r\n\r\n\t\treturn marker;\r\n\t},\r\n\r\n\t_onMarkerDragStart: function () {\r\n\t\tthis._poly.fire('editstart');\r\n\t},\r\n\r\n\t_spliceLatLngs: function () {\r\n\t\tvar latlngs = this._defaultShape();\r\n\t\tvar removed = [].splice.apply(latlngs, arguments);\r\n\t\tthis._poly._convertLatLngs(latlngs, true);\r\n\t\tthis._poly.redraw();\r\n\t\treturn removed;\r\n\t},\r\n\r\n\t_removeMarker: function (marker) {\r\n\t\tvar i = marker._index;\r\n\r\n\t\tthis._markerGroup.removeLayer(marker);\r\n\t\tthis._markers.splice(i, 1);\r\n\t\tthis._spliceLatLngs(i, 1);\r\n\t\tthis._updateIndexes(i, -1);\r\n\r\n\t\tmarker\r\n\t\t\t.off('dragstart', this._onMarkerDragStart, this)\r\n\t\t\t.off('drag', this._onMarkerDrag, this)\r\n\t\t\t.off('dragend', this._fireEdit, this)\r\n\t\t\t.off('touchmove', this._onMarkerDrag, this)\r\n\t\t\t.off('touchend', this._fireEdit, this)\r\n\t\t\t.off('click', this._onMarkerClick, this)\r\n\t\t\t.off('MSPointerMove', this._onTouchMove, this)\r\n\t\t\t.off('MSPointerUp', this._fireEdit, this);\r\n\t},\r\n\r\n\t_fireEdit: function () {\r\n\t\tthis._poly.edited = true;\r\n\t\tthis._poly.fire('edit');\r\n\t\tthis._poly._map.fire(L.Draw.Event.EDITVERTEX, {layers: this._markerGroup, poly: this._poly});\r\n\t},\r\n\r\n\t_onMarkerDrag: function (e) {\r\n\t\tvar marker = e.target;\r\n\t\tvar poly = this._poly;\r\n\r\n\t\tvar oldOrigLatLng = L.LatLngUtil.cloneLatLng(marker._origLatLng);\r\n\t\tL.extend(marker._origLatLng, marker._latlng);\r\n\t\tif (poly.options.poly) {\r\n\t\t\tvar tooltip = poly._map._editTooltip; // Access the tooltip\r\n\r\n\t\t\t// If we don't allow intersections and the polygon intersects\r\n\t\t\tif (!poly.options.poly.allowIntersection && poly.intersects()) {\r\n\t\t\t\tL.extend(marker._origLatLng, oldOrigLatLng);\r\n\t\t\t\tmarker.setLatLng(oldOrigLatLng);\r\n\t\t\t\tvar originalColor = poly.options.color;\r\n\t\t\t\tpoly.setStyle({color: this.options.drawError.color});\r\n\t\t\t\tif (tooltip) {\r\n\t\t\t\t\ttooltip.updateContent({\r\n\t\t\t\t\t\ttext: L.drawLocal.draw.handlers.polyline.error\r\n\t\t\t\t\t});\r\n\t\t\t\t}\r\n\r\n\t\t\t\t// Reset everything back to normal after a second\r\n\t\t\t\tsetTimeout(function () {\r\n\t\t\t\t\tpoly.setStyle({color: originalColor});\r\n\t\t\t\t\tif (tooltip) {\r\n\t\t\t\t\t\ttooltip.updateContent({\r\n\t\t\t\t\t\t\ttext: L.drawLocal.edit.handlers.edit.tooltip.text,\r\n\t\t\t\t\t\t\tsubtext: L.drawLocal.edit.handlers.edit.tooltip.subtext\r\n\t\t\t\t\t\t});\r\n\t\t\t\t\t}\r\n\t\t\t\t}, 1000);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (marker._middleLeft) {\r\n\t\t\tmarker._middleLeft.setLatLng(this._getMiddleLatLng(marker._prev, marker));\r\n\t\t}\r\n\t\tif (marker._middleRight) {\r\n\t\t\tmarker._middleRight.setLatLng(this._getMiddleLatLng(marker, marker._next));\r\n\t\t}\r\n\r\n\t\t//refresh the bounds when draging\r\n\t\tthis._poly._bounds._southWest = L.latLng(Infinity, Infinity);\r\n\t\tthis._poly._bounds._northEast = L.latLng(-Infinity, -Infinity);\r\n\t\tvar latlngs = this._poly.getLatLngs();\r\n\t\tthis._poly._convertLatLngs(latlngs, true);\r\n\t\tthis._poly.redraw();\r\n\t\tthis._poly.fire('editdrag');\r\n\t},\r\n\r\n\t_onMarkerClick: function (e) {\r\n\r\n\t\tvar minPoints = L.Polygon && (this._poly instanceof L.Polygon) ? 4 : 3,\r\n\t\t\tmarker = e.target;\r\n\r\n\t\t// If removing this point would create an invalid polyline/polygon don't remove\r\n\t\tif (this._defaultShape().length < minPoints) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\t// remove the marker\r\n\t\tthis._removeMarker(marker);\r\n\r\n\t\t// update prev/next links of adjacent markers\r\n\t\tthis._updatePrevNext(marker._prev, marker._next);\r\n\r\n\t\t// remove ghost markers near the removed marker\r\n\t\tif (marker._middleLeft) {\r\n\t\t\tthis._markerGroup.removeLayer(marker._middleLeft);\r\n\t\t}\r\n\t\tif (marker._middleRight) {\r\n\t\t\tthis._markerGroup.removeLayer(marker._middleRight);\r\n\t\t}\r\n\r\n\t\t// create a ghost marker in place of the removed one\r\n\t\tif (marker._prev && marker._next) {\r\n\t\t\tthis._createMiddleMarker(marker._prev, marker._next);\r\n\r\n\t\t} else if (!marker._prev) {\r\n\t\t\tmarker._next._middleLeft = null;\r\n\r\n\t\t} else if (!marker._next) {\r\n\t\t\tmarker._prev._middleRight = null;\r\n\t\t}\r\n\r\n\t\tthis._fireEdit();\r\n\t},\r\n\r\n\t_onContextMenu: function (e) {\r\n\t\tvar marker = e.target;\r\n\t\tvar poly = this._poly;\r\n\t\tthis._poly._map.fire(L.Draw.Event.MARKERCONTEXT, {marker: marker, layers: this._markerGroup, poly: this._poly});\r\n\t\tL.DomEvent.stopPropagation;\r\n\t},\r\n\r\n\t_onTouchMove: function (e) {\r\n\r\n\t\tvar layerPoint = this._map.mouseEventToLayerPoint(e.originalEvent.touches[0]),\r\n\t\t\tlatlng = this._map.layerPointToLatLng(layerPoint),\r\n\t\t\tmarker = e.target;\r\n\r\n\t\tL.extend(marker._origLatLng, latlng);\r\n\r\n\t\tif (marker._middleLeft) {\r\n\t\t\tmarker._middleLeft.setLatLng(this._getMiddleLatLng(marker._prev, marker));\r\n\t\t}\r\n\t\tif (marker._middleRight) {\r\n\t\t\tmarker._middleRight.setLatLng(this._getMiddleLatLng(marker, marker._next));\r\n\t\t}\r\n\r\n\t\tthis._poly.redraw();\r\n\t\tthis.updateMarkers();\r\n\t},\r\n\r\n\t_updateIndexes: function (index, delta) {\r\n\t\tthis._markerGroup.eachLayer(function (marker) {\r\n\t\t\tif (marker._index > index) {\r\n\t\t\t\tmarker._index += delta;\r\n\t\t\t}\r\n\t\t});\r\n\t},\r\n\r\n\t_createMiddleMarker: function (marker1, marker2) {\r\n\t\tvar latlng = this._getMiddleLatLng(marker1, marker2),\r\n\t\t\tmarker = this._createMarker(latlng),\r\n\t\t\tonClick,\r\n\t\t\tonDragStart,\r\n\t\t\tonDragEnd;\r\n\r\n\t\tmarker.setOpacity(0.6);\r\n\r\n\t\tmarker1._middleRight = marker2._middleLeft = marker;\r\n\r\n\t\tonDragStart = function () {\r\n\t\t\tmarker.off('touchmove', onDragStart, this);\r\n\t\t\tvar i = marker2._index;\r\n\r\n\t\t\tmarker._index = i;\r\n\r\n\t\t\tmarker\r\n\t\t\t\t.off('click', onClick, this)\r\n\t\t\t\t.on('click', this._onMarkerClick, this);\r\n\r\n\t\t\tlatlng.lat = marker.getLatLng().lat;\r\n\t\t\tlatlng.lng = marker.getLatLng().lng;\r\n\t\t\tthis._spliceLatLngs(i, 0, latlng);\r\n\t\t\tthis._markers.splice(i, 0, marker);\r\n\r\n\t\t\tmarker.setOpacity(1);\r\n\r\n\t\t\tthis._updateIndexes(i, 1);\r\n\t\t\tmarker2._index++;\r\n\t\t\tthis._updatePrevNext(marker1, marker);\r\n\t\t\tthis._updatePrevNext(marker, marker2);\r\n\r\n\t\t\tthis._poly.fire('editstart');\r\n\t\t};\r\n\r\n\t\tonDragEnd = function () {\r\n\t\t\tmarker.off('dragstart', onDragStart, this);\r\n\t\t\tmarker.off('dragend', onDragEnd, this);\r\n\t\t\tmarker.off('touchmove', onDragStart, this);\r\n\r\n\t\t\tthis._createMiddleMarker(marker1, marker);\r\n\t\t\tthis._createMiddleMarker(marker, marker2);\r\n\t\t};\r\n\r\n\t\tonClick = function () {\r\n\t\t\tonDragStart.call(this);\r\n\t\t\tonDragEnd.call(this);\r\n\t\t\tthis._fireEdit();\r\n\t\t};\r\n\r\n\t\tmarker\r\n\t\t\t.on('click', onClick, this)\r\n\t\t\t.on('dragstart', onDragStart, this)\r\n\t\t\t.on('dragend', onDragEnd, this)\r\n\t\t\t.on('touchmove', onDragStart, this);\r\n\r\n\t\tthis._markerGroup.addLayer(marker);\r\n\t},\r\n\r\n\t_updatePrevNext: function (marker1, marker2) {\r\n\t\tif (marker1) {\r\n\t\t\tmarker1._next = marker2;\r\n\t\t}\r\n\t\tif (marker2) {\r\n\t\t\tmarker2._prev = marker1;\r\n\t\t}\r\n\t},\r\n\r\n\t_getMiddleLatLng: function (marker1, marker2) {\r\n\t\tvar map = this._poly._map,\r\n\t\t\tp1 = map.project(marker1.getLatLng()),\r\n\t\t\tp2 = map.project(marker2.getLatLng());\r\n\r\n\t\treturn map.unproject(p1._add(p2)._divideBy(2));\r\n\t}\r\n});\r\n\r\nL.Polyline.addInitHook(function () {\r\n\r\n\t// Check to see if handler has already been initialized. This is to support versions of Leaflet that still have L.Handler.PolyEdit\r\n\tif (this.editing) {\r\n\t\treturn;\r\n\t}\r\n\r\n\tif (L.Edit.Poly) {\r\n\r\n\t\tthis.editing = new L.Edit.Poly(this);\r\n\r\n\t\tif (this.options.editable) {\r\n\t\t\tthis.editing.enable();\r\n\t\t}\r\n\t}\r\n\r\n\tthis.on('add', function () {\r\n\t\tif (this.editing && this.editing.enabled()) {\r\n\t\t\tthis.editing.addHooks();\r\n\t\t}\r\n\t});\r\n\r\n\tthis.on('remove', function () {\r\n\t\tif (this.editing && this.editing.enabled()) {\r\n\t\t\tthis.editing.removeHooks();\r\n\t\t}\r\n\t});\r\n});\r\n","L.Edit = L.Edit || {};\r\n/**\r\n * @class L.Edit.SimpleShape\r\n * @aka Edit.SimpleShape\r\n */\r\nL.Edit.SimpleShape = L.Handler.extend({\r\n\toptions: {\r\n\t\tmoveIcon: new L.DivIcon({\r\n\t\t\ticonSize: new L.Point(8, 8),\r\n\t\t\tclassName: 'leaflet-div-icon leaflet-editing-icon leaflet-edit-move'\r\n\t\t}),\r\n\t\tresizeIcon: new L.DivIcon({\r\n\t\t\ticonSize: new L.Point(8, 8),\r\n\t\t\tclassName: 'leaflet-div-icon leaflet-editing-icon leaflet-edit-resize'\r\n\t\t}),\r\n\t\ttouchMoveIcon: new L.DivIcon({\r\n\t\t\ticonSize: new L.Point(20, 20),\r\n\t\t\tclassName: 'leaflet-div-icon leaflet-editing-icon leaflet-edit-move leaflet-touch-icon'\r\n\t\t}),\r\n\t\ttouchResizeIcon: new L.DivIcon({\r\n\t\t\ticonSize: new L.Point(20, 20),\r\n\t\t\tclassName: 'leaflet-div-icon leaflet-editing-icon leaflet-edit-resize leaflet-touch-icon'\r\n\t\t}),\r\n\t},\r\n\r\n\t// @method intialize(): void\r\n\tinitialize: function (shape, options) {\r\n\t\t// if touch, switch to touch icon\r\n\t\tif (L.Browser.touch) {\r\n\t\t\tthis.options.moveIcon = this.options.touchMoveIcon;\r\n\t\t\tthis.options.resizeIcon = this.options.touchResizeIcon;\r\n\t\t}\r\n\r\n\t\tthis._shape = shape;\r\n\t\tL.Util.setOptions(this, options);\r\n\t},\r\n\r\n\t// @method addHooks(): void\r\n\t// Add listener hooks to this handler\r\n\taddHooks: function () {\r\n\t\tvar shape = this._shape;\r\n\t\tif (this._shape._map) {\r\n\t\t\tthis._map = this._shape._map;\r\n\t\t\tshape.setStyle(shape.options.editing);\r\n\r\n\t\t\tif (shape._map) {\r\n\t\t\t\tthis._map = shape._map;\r\n\t\t\t\tif (!this._markerGroup) {\r\n\t\t\t\t\tthis._initMarkers();\r\n\t\t\t\t}\r\n\t\t\t\tthis._map.addLayer(this._markerGroup);\r\n\t\t\t}\r\n\t\t}\r\n\t},\r\n\r\n\t// @method removeHooks(): void\r\n\t// Remove listener hooks from this handler\r\n\tremoveHooks: function () {\r\n\t\tvar shape = this._shape;\r\n\r\n\t\tshape.setStyle(shape.options.original);\r\n\r\n\t\tif (shape._map) {\r\n\t\t\tthis._unbindMarker(this._moveMarker);\r\n\r\n\t\t\tfor (var i = 0, l = this._resizeMarkers.length; i < l; i++) {\r\n\t\t\t\tthis._unbindMarker(this._resizeMarkers[i]);\r\n\t\t\t}\r\n\t\t\tthis._resizeMarkers = null;\r\n\r\n\t\t\tthis._map.removeLayer(this._markerGroup);\r\n\t\t\tdelete this._markerGroup;\r\n\t\t}\r\n\r\n\t\tthis._map = null;\r\n\t},\r\n\r\n\t// @method updateMarkers(): void\r\n\t// Remove the edit markers from this layer\r\n\tupdateMarkers: function () {\r\n\t\tthis._markerGroup.clearLayers();\r\n\t\tthis._initMarkers();\r\n\t},\r\n\r\n\t_initMarkers: function () {\r\n\t\tif (!this._markerGroup) {\r\n\t\t\tthis._markerGroup = new L.LayerGroup();\r\n\t\t}\r\n\r\n\t\t// Create center marker\r\n\t\tthis._createMoveMarker();\r\n\r\n\t\t// Create edge marker\r\n\t\tthis._createResizeMarker();\r\n\t},\r\n\r\n\t_createMoveMarker: function () {\r\n\t\t// Children override\r\n\t},\r\n\r\n\t_createResizeMarker: function () {\r\n\t\t// Children override\r\n\t},\r\n\r\n\t_createMarker: function (latlng, icon) {\r\n\t\t// Extending L.Marker in TouchEvents.js to include touch.\r\n\t\tvar marker = new L.Marker.Touch(latlng, {\r\n\t\t\tdraggable: true,\r\n\t\t\ticon: icon,\r\n\t\t\tzIndexOffset: 10\r\n\t\t});\r\n\r\n\t\tthis._bindMarker(marker);\r\n\r\n\t\tthis._markerGroup.addLayer(marker);\r\n\r\n\t\treturn marker;\r\n\t},\r\n\r\n\t_bindMarker: function (marker) {\r\n\t\tmarker\r\n\t\t\t.on('dragstart', this._onMarkerDragStart, this)\r\n\t\t\t.on('drag', this._onMarkerDrag, this)\r\n\t\t\t.on('dragend', this._onMarkerDragEnd, this)\r\n\t\t\t.on('touchstart', this._onTouchStart, this)\r\n\t\t\t.on('touchmove', this._onTouchMove, this)\r\n\t\t\t.on('MSPointerMove', this._onTouchMove, this)\r\n\t\t\t.on('touchend', this._onTouchEnd, this)\r\n\t\t\t.on('MSPointerUp', this._onTouchEnd, this);\r\n\t},\r\n\r\n\t_unbindMarker: function (marker) {\r\n\t\tmarker\r\n\t\t\t.off('dragstart', this._onMarkerDragStart, this)\r\n\t\t\t.off('drag', this._onMarkerDrag, this)\r\n\t\t\t.off('dragend', this._onMarkerDragEnd, this)\r\n\t\t\t.off('touchstart', this._onTouchStart, this)\r\n\t\t\t.off('touchmove', this._onTouchMove, this)\r\n\t\t\t.off('MSPointerMove', this._onTouchMove, this)\r\n\t\t\t.off('touchend', this._onTouchEnd, this)\r\n\t\t\t.off('MSPointerUp', this._onTouchEnd, this);\r\n\t},\r\n\r\n\t_onMarkerDragStart: function (e) {\r\n\t\tvar marker = e.target;\r\n\t\tmarker.setOpacity(0);\r\n\r\n\t\tthis._shape.fire('editstart');\r\n\t},\r\n\r\n\t_fireEdit: function () {\r\n\t\tthis._shape.edited = true;\r\n\t\tthis._shape.fire('edit');\r\n\t},\r\n\r\n\t_onMarkerDrag: function (e) {\r\n\t\tvar marker = e.target,\r\n\t\t\tlatlng = marker.getLatLng();\r\n\r\n\t\tif (marker === this._moveMarker) {\r\n\t\t\tthis._move(latlng);\r\n\t\t} else {\r\n\t\t\tthis._resize(latlng);\r\n\t\t}\r\n\r\n\t\tthis._shape.redraw();\r\n\t\tthis._shape.fire('editdrag');\r\n\t},\r\n\r\n\t_onMarkerDragEnd: function (e) {\r\n\t\tvar marker = e.target;\r\n\t\tmarker.setOpacity(1);\r\n\r\n\t\tthis._fireEdit();\r\n\t},\r\n\r\n\t_onTouchStart: function (e) {\r\n\t\tL.Edit.SimpleShape.prototype._onMarkerDragStart.call(this, e);\r\n\r\n\t\tif (typeof(this._getCorners) === 'function') {\r\n\t\t\t// Save a reference to the opposite point\r\n\t\t\tvar corners = this._getCorners(),\r\n\t\t\t\tmarker = e.target,\r\n\t\t\t\tcurrentCornerIndex = marker._cornerIndex;\r\n\r\n\t\t\tmarker.setOpacity(0);\r\n\r\n\t\t\t// Copyed from Edit.Rectangle.js line 23 _onMarkerDragStart()\r\n\t\t\t// Latlng is null otherwise.\r\n\t\t\tthis._oppositeCorner = corners[(currentCornerIndex + 2) % 4];\r\n\t\t\tthis._toggleCornerMarkers(0, currentCornerIndex);\r\n\t\t}\r\n\r\n\t\tthis._shape.fire('editstart');\r\n\t},\r\n\r\n\t_onTouchMove: function (e) {\r\n\t\tvar layerPoint = this._map.mouseEventToLayerPoint(e.originalEvent.touches[0]),\r\n\t\t\tlatlng = this._map.layerPointToLatLng(layerPoint),\r\n\t\t\tmarker = e.target;\r\n\r\n\t\tif (marker === this._moveMarker) {\r\n\t\t\tthis._move(latlng);\r\n\t\t} else {\r\n\t\t\tthis._resize(latlng);\r\n\t\t}\r\n\r\n\t\tthis._shape.redraw();\r\n\r\n\t\t// prevent touchcancel in IOS\r\n\t\t// e.preventDefault();\r\n\t\treturn false;\r\n\t},\r\n\r\n\t_onTouchEnd: function (e) {\r\n\t\tvar marker = e.target;\r\n\t\tmarker.setOpacity(1);\r\n\t\tthis.updateMarkers();\r\n\t\tthis._fireEdit();\r\n\t},\r\n\r\n\t_move: function () {\r\n\t\t// Children override\r\n\t},\r\n\r\n\t_resize: function () {\r\n\t\t// Children override\r\n\t}\r\n});\r\n","L.Edit = L.Edit || {};\r\n/**\r\n * @class L.Edit.Rectangle\r\n * @aka Edit.Rectangle\r\n * @inherits L.Edit.SimpleShape\r\n */\r\nL.Edit.Rectangle = L.Edit.SimpleShape.extend({\r\n\t_createMoveMarker: function () {\r\n\t\tvar bounds = this._shape.getBounds(),\r\n\t\t\tcenter = bounds.getCenter();\r\n\r\n\t\tthis._moveMarker = this._createMarker(center, this.options.moveIcon);\r\n\t},\r\n\r\n\t_createResizeMarker: function () {\r\n\t\tvar corners = this._getCorners();\r\n\r\n\t\tthis._resizeMarkers = [];\r\n\r\n\t\tfor (var i = 0, l = corners.length; i < l; i++) {\r\n\t\t\tthis._resizeMarkers.push(this._createMarker(corners[i], this.options.resizeIcon));\r\n\t\t\t// Monkey in the corner index as we will need to know this for dragging\r\n\t\t\tthis._resizeMarkers[i]._cornerIndex = i;\r\n\t\t}\r\n\t},\r\n\r\n\t_onMarkerDragStart: function (e) {\r\n\t\tL.Edit.SimpleShape.prototype._onMarkerDragStart.call(this, e);\r\n\r\n\t\t// Save a reference to the opposite point\r\n\t\tvar corners = this._getCorners(),\r\n\t\t\tmarker = e.target,\r\n\t\t\tcurrentCornerIndex = marker._cornerIndex;\r\n\r\n\t\tthis._oppositeCorner = corners[(currentCornerIndex + 2) % 4];\r\n\r\n\t\tthis._toggleCornerMarkers(0, currentCornerIndex);\r\n\t},\r\n\r\n\t_onMarkerDragEnd: function (e) {\r\n\t\tvar marker = e.target,\r\n\t\t\tbounds, center;\r\n\r\n\t\t// Reset move marker position to the center\r\n\t\tif (marker === this._moveMarker) {\r\n\t\t\tbounds = this._shape.getBounds();\r\n\t\t\tcenter = bounds.getCenter();\r\n\r\n\t\t\tmarker.setLatLng(center);\r\n\t\t}\r\n\r\n\t\tthis._toggleCornerMarkers(1);\r\n\r\n\t\tthis._repositionCornerMarkers();\r\n\r\n\t\tL.Edit.SimpleShape.prototype._onMarkerDragEnd.call(this, e);\r\n\t},\r\n\r\n\t_move: function (newCenter) {\r\n\t\tvar latlngs = this._shape._defaultShape ? this._shape._defaultShape() : this._shape.getLatLngs(),\r\n\t\t\tbounds = this._shape.getBounds(),\r\n\t\t\tcenter = bounds.getCenter(),\r\n\t\t\toffset, newLatLngs = [];\r\n\r\n\t\t// Offset the latlngs to the new center\r\n\t\tfor (var i = 0, l = latlngs.length; i < l; i++) {\r\n\t\t\toffset = [latlngs[i].lat - center.lat, latlngs[i].lng - center.lng];\r\n\t\t\tnewLatLngs.push([newCenter.lat + offset[0], newCenter.lng + offset[1]]);\r\n\t\t}\r\n\r\n\t\tthis._shape.setLatLngs(newLatLngs);\r\n\r\n\t\t// Reposition the resize markers\r\n\t\tthis._repositionCornerMarkers();\r\n\r\n\t\tthis._map.fire(L.Draw.Event.EDITMOVE, {layer: this._shape});\r\n\t},\r\n\r\n\t_resize: function (latlng) {\r\n\t\tvar bounds;\r\n\r\n\t\t// Update the shape based on the current position of this corner and the opposite point\r\n\t\tthis._shape.setBounds(L.latLngBounds(latlng, this._oppositeCorner));\r\n\r\n\t\t// Reposition the move marker\r\n\t\tbounds = this._shape.getBounds();\r\n\t\tthis._moveMarker.setLatLng(bounds.getCenter());\r\n\r\n\t\tthis._map.fire(L.Draw.Event.EDITRESIZE, {layer: this._shape});\r\n\t},\r\n\r\n\t_getCorners: function () {\r\n\t\tvar bounds = this._shape.getBounds(),\r\n\t\t\tnw = bounds.getNorthWest(),\r\n\t\t\tne = bounds.getNorthEast(),\r\n\t\t\tse = bounds.getSouthEast(),\r\n\t\t\tsw = bounds.getSouthWest();\r\n\r\n\t\treturn [nw, ne, se, sw];\r\n\t},\r\n\r\n\t_toggleCornerMarkers: function (opacity) {\r\n\t\tfor (var i = 0, l = this._resizeMarkers.length; i < l; i++) {\r\n\t\t\tthis._resizeMarkers[i].setOpacity(opacity);\r\n\t\t}\r\n\t},\r\n\r\n\t_repositionCornerMarkers: function () {\r\n\t\tvar corners = this._getCorners();\r\n\r\n\t\tfor (var i = 0, l = this._resizeMarkers.length; i < l; i++) {\r\n\t\t\tthis._resizeMarkers[i].setLatLng(corners[i]);\r\n\t\t}\r\n\t}\r\n});\r\n\r\nL.Rectangle.addInitHook(function () {\r\n\tif (L.Edit.Rectangle) {\r\n\t\tthis.editing = new L.Edit.Rectangle(this);\r\n\r\n\t\tif (this.options.editable) {\r\n\t\t\tthis.editing.enable();\r\n\t\t}\r\n\t}\r\n});\r\n","L.Edit = L.Edit || {};\r\n/**\r\n * @class L.Edit.CircleMarker\r\n * @aka Edit.Circle\r\n * @inherits L.Edit.SimpleShape\r\n */\r\nL.Edit.CircleMarker = L.Edit.SimpleShape.extend({\r\n\t_createMoveMarker: function () {\r\n\t\tvar center = this._shape.getLatLng();\r\n\t\tthis._map._editTooltip = new L.Draw.Tooltip(this._map);\r\n\t\tthis._moveMarker = this._createMarker(center, this.options.moveIcon);\r\n\t},\r\n\r\n\t_createResizeMarker: function () {\r\n\t\t// To avoid an undefined check in L.Edit.SimpleShape.removeHooks\r\n\t\tthis._resizeMarkers = [];\r\n\t},\r\n\r\n\t_move: function (latlng) {\r\n\t\tif (this._resizeMarkers.length) {\r\n\t\t\tvar resizemarkerPoint = this._getResizeMarkerPoint(latlng);\r\n\t\t\t// Move the resize marker\r\n\t\t\tthis._resizeMarkers[0].setLatLng(resizemarkerPoint);\r\n\t\t}\r\n\r\n\t\t// Move the circle\r\n\t\tthis._shape.setLatLng(latlng);\r\n\r\n\t\tthis._map.fire(L.Draw.Event.EDITMOVE, {layer: this._shape});\r\n\t},\r\n});\r\n\r\nL.CircleMarker.addInitHook(function () {\r\n\tif (L.Edit.CircleMarker) {\r\n\t\tthis.editing = new L.Edit.CircleMarker(this);\r\n\r\n\t\tif (this.options.editable) {\r\n\t\t\tthis.editing.enable();\r\n\t\t}\r\n\t}\r\n\r\n\tthis.on('add', function () {\r\n\t\tif (this.editing && this.editing.enabled()) {\r\n\t\t\tthis.editing.addHooks();\r\n\t\t}\r\n\t});\r\n\r\n\tthis.on('remove', function () {\r\n\t\tif (this.editing && this.editing.enabled()) {\r\n\t\t\tthis.editing.removeHooks();\r\n\t\t}\r\n\t});\r\n});\r\n","L.Edit = L.Edit || {};\r\n/**\r\n * @class L.Edit.Circle\r\n * @aka Edit.Circle\r\n * @inherits L.Edit.CircleMarker\r\n */\r\nL.Edit.Circle = L.Edit.CircleMarker.extend({\r\n\r\n\t_createResizeMarker: function () {\r\n\t\tvar center = this._shape.getLatLng(),\r\n\t\t\tresizemarkerPoint = this._getResizeMarkerPoint(center);\r\n\r\n\t\tthis._resizeMarkers = [];\r\n\t\tthis._resizeMarkers.push(this._createMarker(resizemarkerPoint, this.options.resizeIcon));\r\n\t},\r\n\r\n\t_getResizeMarkerPoint: function (latlng) {\r\n\t\t// From L.shape.getBounds()\r\n\t\tvar delta = this._shape._radius * Math.cos(Math.PI / 4),\r\n\t\t\tpoint = this._map.project(latlng);\r\n\t\treturn this._map.unproject([point.x + delta, point.y - delta]);\r\n\t},\r\n\r\n\t_resize: function (latlng) {\r\n\t\tvar moveLatLng = this._moveMarker.getLatLng();\r\n\r\n\t\t// Calculate the radius based on the version\r\n\t\tif (L.GeometryUtil.isVersion07x()) {\r\n\t\t\tradius = moveLatLng.distanceTo(latlng);\r\n\t\t} else {\r\n\t\t\tradius = this._map.distance(moveLatLng, latlng);\r\n\t\t}\r\n\t\tthis._shape.setRadius(radius);\r\n\r\n\t\tif (this._map._editTooltip) {\r\n\t\t\t this._map._editTooltip.updatePosition(latlng);\r\n\t\t\t this._map._editTooltip.updateContent({\r\n\t\t\t\ttext: L.drawLocal.edit.handlers.edit.tooltip.subtext + '
' + L.drawLocal.edit.handlers.edit.tooltip.text,\r\n\t\t\t\tsubtext: L.drawLocal.draw.handlers.circle.radius + ': ' +\r\n\t\t\t\tL.GeometryUtil.readableDistance(radius, true, this.options.feet, this.options.nautic)\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\tthis._shape.setRadius(radius);\r\n\r\n\t\tthis._map.fire(L.Draw.Event.EDITRESIZE, {layer: this._shape});\r\n\t}\r\n});\r\n\r\nL.Circle.addInitHook(function () {\r\n\tif (L.Edit.Circle) {\r\n\t\tthis.editing = new L.Edit.Circle(this);\r\n\r\n\t\tif (this.options.editable) {\r\n\t\t\tthis.editing.enable();\r\n\t\t}\r\n\t}\r\n});\r\n","L.Map.mergeOptions({\r\n\ttouchExtend: true\r\n});\r\n\r\n/**\r\n * @class L.Map.TouchExtend\r\n * @aka TouchExtend\r\n */\r\nL.Map.TouchExtend = L.Handler.extend({\r\n\r\n\t// @method initialize(): void\r\n\t// Sets TouchExtend private accessor variables\r\n\tinitialize: function (map) {\r\n\t\tthis._map = map;\r\n\t\tthis._container = map._container;\r\n\t\tthis._pane = map._panes.overlayPane;\r\n\t},\r\n\r\n\t// @method addHooks(): void\r\n\t// Adds dom listener events to the map container\r\n\taddHooks: function () {\r\n\t\tL.DomEvent.on(this._container, 'touchstart', this._onTouchStart, this);\r\n\t\tL.DomEvent.on(this._container, 'touchend', this._onTouchEnd, this);\r\n\t\tL.DomEvent.on(this._container, 'touchmove', this._onTouchMove, this);\r\n\t\tif (this._detectIE()) {\r\n\t\t\tL.DomEvent.on(this._container, 'MSPointerDown', this._onTouchStart, this);\r\n\t\t\tL.DomEvent.on(this._container, 'MSPointerUp', this._onTouchEnd, this);\r\n\t\t\tL.DomEvent.on(this._container, 'MSPointerMove', this._onTouchMove, this);\r\n\t\t\tL.DomEvent.on(this._container, 'MSPointerCancel', this._onTouchCancel, this);\r\n\r\n\t\t} else {\r\n\t\t\tL.DomEvent.on(this._container, 'touchcancel', this._onTouchCancel, this);\r\n\t\t\tL.DomEvent.on(this._container, 'touchleave', this._onTouchLeave, this);\r\n\t\t}\r\n\t},\r\n\r\n\t// @method removeHooks(): void\r\n\t// Removes dom listener events from the map container\r\n\tremoveHooks: function () {\r\n\t\tL.DomEvent.off(this._container, 'touchstart', this._onTouchStart, this);\r\n\t\tL.DomEvent.off(this._container, 'touchend', this._onTouchEnd, this);\r\n\t\tL.DomEvent.off(this._container, 'touchmove', this._onTouchMove, this);\r\n\t\tif (this._detectIE()) {\r\n\t\t\tL.DomEvent.off(this._container, 'MSPointerDown', this._onTouchStart, this);\r\n\t\t\tL.DomEvent.off(this._container, 'MSPointerUp', this._onTouchEnd, this);\r\n\t\t\tL.DomEvent.off(this._container, 'MSPointerMove', this._onTouchMove, this);\r\n\t\t\tL.DomEvent.off(this._container, 'MSPointerCancel', this._onTouchCancel, this);\r\n\t\t} else {\r\n\t\t\tL.DomEvent.off(this._container, 'touchcancel', this._onTouchCancel, this);\r\n\t\t\tL.DomEvent.off(this._container, 'touchleave', this._onTouchLeave, this);\r\n\t\t}\r\n\t},\r\n\r\n\t_touchEvent: function (e, type) {\r\n\t\t// #TODO: fix the pageX error that is do a bug in Android where a single touch triggers two click events\r\n\t\t// _filterClick is what leaflet uses as a workaround.\r\n\t\t// This is a problem with more things than just android. Another problem is touchEnd has no touches in\r\n\t\t// its touch list.\r\n\t\tvar touchEvent = {};\r\n\t\tif (typeof e.touches !== 'undefined') {\r\n\t\t\tif (!e.touches.length) {\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\t\t\ttouchEvent = e.touches[0];\r\n\t\t} else if (e.pointerType === 'touch') {\r\n\t\t\ttouchEvent = e;\r\n\t\t\tif (!this._filterClick(e)) {\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\t\t} else {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tvar containerPoint = this._map.mouseEventToContainerPoint(touchEvent),\r\n\t\t\tlayerPoint = this._map.mouseEventToLayerPoint(touchEvent),\r\n\t\t\tlatlng = this._map.layerPointToLatLng(layerPoint);\r\n\r\n\t\tthis._map.fire(type, {\r\n\t\t\tlatlng: latlng,\r\n\t\t\tlayerPoint: layerPoint,\r\n\t\t\tcontainerPoint: containerPoint,\r\n\t\t\tpageX: touchEvent.pageX,\r\n\t\t\tpageY: touchEvent.pageY,\r\n\t\t\toriginalEvent: e\r\n\t\t});\r\n\t},\r\n\r\n\t/** Borrowed from Leaflet and modified for bool ops **/\r\n\t_filterClick: function (e) {\r\n\t\tvar timeStamp = (e.timeStamp || e.originalEvent.timeStamp),\r\n\t\t\telapsed = L.DomEvent._lastClick && (timeStamp - L.DomEvent._lastClick);\r\n\r\n\t\t// are they closer together than 500ms yet more than 100ms?\r\n\t\t// Android typically triggers them ~300ms apart while multiple listeners\r\n\t\t// on the same event should be triggered far faster;\r\n\t\t// or check if click is simulated on the element, and if it is, reject any non-simulated events\r\n\t\tif ((elapsed && elapsed > 100 && elapsed < 500) || (e.target._simulatedClick && !e._simulated)) {\r\n\t\t\tL.DomEvent.stop(e);\r\n\t\t\treturn false;\r\n\t\t}\r\n\t\tL.DomEvent._lastClick = timeStamp;\r\n\t\treturn true;\r\n\t},\r\n\r\n\t_onTouchStart: function (e) {\r\n\t\tif (!this._map._loaded) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tvar type = 'touchstart';\r\n\t\tthis._touchEvent(e, type);\r\n\r\n\t},\r\n\r\n\t_onTouchEnd: function (e) {\r\n\t\tif (!this._map._loaded) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tvar type = 'touchend';\r\n\t\tthis._touchEvent(e, type);\r\n\t},\r\n\r\n\t_onTouchCancel: function (e) {\r\n\t\tif (!this._map._loaded) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tvar type = 'touchcancel';\r\n\t\tif (this._detectIE()) {\r\n\t\t\ttype = 'pointercancel';\r\n\t\t}\r\n\t\tthis._touchEvent(e, type);\r\n\t},\r\n\r\n\t_onTouchLeave: function (e) {\r\n\t\tif (!this._map._loaded) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tvar type = 'touchleave';\r\n\t\tthis._touchEvent(e, type);\r\n\t},\r\n\r\n\t_onTouchMove: function (e) {\r\n\t\tif (!this._map._loaded) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tvar type = 'touchmove';\r\n\t\tthis._touchEvent(e, type);\r\n\t},\r\n\r\n\t_detectIE: function () {\r\n\t\tvar ua = window.navigator.userAgent;\r\n\r\n\t\tvar msie = ua.indexOf('MSIE ');\r\n\t\tif (msie > 0) {\r\n\t\t\t// IE 10 or older => return version number\r\n\t\t\treturn parseInt(ua.substring(msie + 5, ua.indexOf('.', msie)), 10);\r\n\t\t}\r\n\r\n\t\tvar trident = ua.indexOf('Trident/');\r\n\t\tif (trident > 0) {\r\n\t\t\t// IE 11 => return version number\r\n\t\t\tvar rv = ua.indexOf('rv:');\r\n\t\t\treturn parseInt(ua.substring(rv + 3, ua.indexOf('.', rv)), 10);\r\n\t\t}\r\n\r\n\t\tvar edge = ua.indexOf('Edge/');\r\n\t\tif (edge > 0) {\r\n\t\t\t// IE 12 => return version number\r\n\t\t\treturn parseInt(ua.substring(edge + 5, ua.indexOf('.', edge)), 10);\r\n\t\t}\r\n\r\n\t\t// other browser\r\n\t\treturn false;\r\n\t}\r\n});\r\n\r\nL.Map.addInitHook('addHandler', 'touchExtend', L.Map.TouchExtend);\r\n\r\n\r\n/**\r\n * @class L.Marker.Touch\r\n * @aka Marker.Touch\r\n *\r\n * This isn't full Touch support. This is just to get markers to also support dom touch events after creation\r\n * #TODO: find a better way of getting markers to support touch.\r\n */\r\nL.Marker.Touch = L.Marker.extend({\r\n\r\n\t_initInteraction: function () {\r\n\t\tif (!this.addInteractiveTarget) {\r\n\t\t\t// 0.7.x support\r\n\t\t\treturn this._initInteractionLegacy();\r\n\t\t}\r\n\t\t// TODO this may need be updated to re-add touch events for 1.0+\r\n\t\treturn L.Marker.prototype._initInteraction.apply(this);\r\n\t},\r\n\r\n\t// This is an exact copy of https://github.com/Leaflet/Leaflet/blob/v0.7/src/layer/marker/Marker.js\r\n\t// with the addition of the touch events\r\n\t_initInteractionLegacy: function () {\r\n\r\n\t\tif (!this.options.clickable) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\t// TODO refactor into something shared with Map/Path/etc. to DRY it up\r\n\r\n\t\tvar icon = this._icon,\r\n\t\t\tevents = ['dblclick',\r\n\t\t\t\t'mousedown',\r\n\t\t\t\t'mouseover',\r\n\t\t\t\t'mouseout',\r\n\t\t\t\t'contextmenu',\r\n\t\t\t\t'touchstart',\r\n\t\t\t\t'touchend',\r\n\t\t\t\t'touchmove'];\r\n\t\tif (this._detectIE) {\r\n\t\t\tevents.concat(['MSPointerDown',\r\n\t\t\t\t'MSPointerUp',\r\n\t\t\t\t'MSPointerMove',\r\n\t\t\t\t'MSPointerCancel']);\r\n\t\t} else {\r\n\t\t\tevents.concat(['touchcancel']);\r\n\t\t}\r\n\r\n\t\tL.DomUtil.addClass(icon, 'leaflet-clickable');\r\n\t\tL.DomEvent.on(icon, 'click', this._onMouseClick, this);\r\n\t\tL.DomEvent.on(icon, 'keypress', this._onKeyPress, this);\r\n\r\n\t\tfor (var i = 0; i < events.length; i++) {\r\n\t\t\tL.DomEvent.on(icon, events[i], this._fireMouseEvent, this);\r\n\t\t}\r\n\r\n\t\tif (L.Handler.MarkerDrag) {\r\n\t\t\tthis.dragging = new L.Handler.MarkerDrag(this);\r\n\r\n\t\t\tif (this.options.draggable) {\r\n\t\t\t\tthis.dragging.enable();\r\n\t\t\t}\r\n\t\t}\r\n\t},\r\n\r\n\t_detectIE: function () {\r\n\t\tvar ua = window.navigator.userAgent;\r\n\r\n\t\tvar msie = ua.indexOf('MSIE ');\r\n\t\tif (msie > 0) {\r\n\t\t\t// IE 10 or older => return version number\r\n\t\t\treturn parseInt(ua.substring(msie + 5, ua.indexOf('.', msie)), 10);\r\n\t\t}\r\n\r\n\t\tvar trident = ua.indexOf('Trident/');\r\n\t\tif (trident > 0) {\r\n\t\t\t// IE 11 => return version number\r\n\t\t\tvar rv = ua.indexOf('rv:');\r\n\t\t\treturn parseInt(ua.substring(rv + 3, ua.indexOf('.', rv)), 10);\r\n\t\t}\r\n\r\n\t\tvar edge = ua.indexOf('Edge/');\r\n\t\tif (edge > 0) {\r\n\t\t\t// IE 12 => return version number\r\n\t\t\treturn parseInt(ua.substring(edge + 5, ua.indexOf('.', edge)), 10);\r\n\t\t}\r\n\r\n\t\t// other browser\r\n\t\treturn false;\r\n\t}\r\n});\r\n","/**\r\n * @class L.LatLngUtil\r\n * @aka LatLngUtil\r\n */\r\nL.LatLngUtil = {\r\n\t// Clones a LatLngs[], returns [][]\r\n\r\n\t// @method cloneLatLngs(LatLngs[]): L.LatLngs[]\r\n\t// Clone the latLng point or points or nested points and return an array with those points\r\n\tcloneLatLngs: function (latlngs) {\r\n\t\tvar clone = [];\r\n\t\tfor (var i = 0, l = latlngs.length; i < l; i++) {\r\n\t\t\t// Check for nested array (Polyline/Polygon)\r\n\t\t\tif (Array.isArray(latlngs[i])) {\r\n\t\t\t\tclone.push(L.LatLngUtil.cloneLatLngs(latlngs[i]));\r\n\t\t\t} else {\r\n\t\t\t\tclone.push(this.cloneLatLng(latlngs[i]));\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn clone;\r\n\t},\r\n\r\n\t// @method cloneLatLng(LatLng): L.LatLng\r\n\t// Clone the latLng and return a new LatLng object.\r\n\tcloneLatLng: function (latlng) {\r\n\t\treturn L.latLng(latlng.lat, latlng.lng);\r\n\t}\r\n};\r\n","(function () {\r\n\r\n\tvar defaultPrecision = {\r\n\t\tkm: 2,\r\n\t\tha: 2,\r\n\t\tm: 0,\r\n\t\tmi: 2,\r\n\t\tac: 2,\r\n\t\tyd: 0,\r\n\t\tft: 0,\r\n\t\tnm: 2\r\n\t};\r\n\r\n\r\n\t/**\r\n\t * @class L.GeometryUtil\r\n\t * @aka GeometryUtil\r\n\t */\r\n\tL.GeometryUtil = L.extend(L.GeometryUtil || {}, {\r\n\t\t// Ported from the OpenLayers implementation. See https://github.com/openlayers/openlayers/blob/master/lib/OpenLayers/Geometry/LinearRing.js#L270\r\n\r\n\t\t// @method geodesicArea(): number\r\n\t\tgeodesicArea: function (latLngs) {\r\n\t\t\tvar pointsCount = latLngs.length,\r\n\t\t\t\tarea = 0.0,\r\n\t\t\t\td2r = Math.PI / 180,\r\n\t\t\t\tp1, p2;\r\n\r\n\t\t\tif (pointsCount > 2) {\r\n\t\t\t\tfor (var i = 0; i < pointsCount; i++) {\r\n\t\t\t\t\tp1 = latLngs[i];\r\n\t\t\t\t\tp2 = latLngs[(i + 1) % pointsCount];\r\n\t\t\t\t\tarea += ((p2.lng - p1.lng) * d2r) *\r\n\t\t\t\t\t\t(2 + Math.sin(p1.lat * d2r) + Math.sin(p2.lat * d2r));\r\n\t\t\t\t}\r\n\t\t\t\tarea = area * 6378137.0 * 6378137.0 / 2.0;\r\n\t\t\t}\r\n\r\n\t\t\treturn Math.abs(area);\r\n\t\t},\r\n\r\n\t\t// @method formattedNumber(n, precision): string\r\n\t\t// Returns n in specified number format (if defined) and precision\r\n\t\tformattedNumber: function (n, precision) {\r\n\t\t\tvar formatted = parseFloat(n).toFixed(precision),\r\n\t\t\t\tformat = L.drawLocal.format && L.drawLocal.format.numeric,\r\n\t\t\t\tdelimiters = format && format.delimiters,\r\n\t\t\t\tthousands = delimiters && delimiters.thousands,\r\n\t\t\t\tdecimal = delimiters && delimiters.decimal;\r\n\r\n\t\t\tif (thousands || decimal) {\r\n\t\t\t\tvar splitValue = formatted.split('.');\r\n\t\t\t\tformatted = thousands ? splitValue[0].replace(/(\\d)(?=(\\d{3})+(?!\\d))/g, '$1' + thousands) : splitValue[0];\r\n\t\t\t\tdecimal = decimal || '.';\r\n\t\t\t\tif (splitValue.length > 1) {\r\n\t\t\t\t\tformatted = formatted + decimal + splitValue[1];\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\treturn formatted;\r\n\t\t},\r\n\r\n\t\t// @method readableArea(area, isMetric, precision): string\r\n\t\t// Returns a readable area string in yards or metric.\r\n\t\t// The value will be rounded as defined by the precision option object.\r\n\t\treadableArea: function (area, isMetric, precision) {\r\n\t\t\tvar areaStr,\r\n\t\t\t\tunits,\r\n\t\t\t\tprecision = L.Util.extend({}, defaultPrecision, precision);\r\n\r\n\t\t\tif (isMetric) {\r\n\t\t\t\tunits = ['ha', 'm'];\r\n\t\t\t\ttype = typeof isMetric;\r\n\t\t\t\tif (type === 'string') {\r\n\t\t\t\t\tunits = [isMetric];\r\n\t\t\t\t} else if (type !== 'boolean') {\r\n\t\t\t\t\tunits = isMetric;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif (area >= 1000000 && units.indexOf('km') !== -1) {\r\n\t\t\t\t\tareaStr = L.GeometryUtil.formattedNumber(area * 0.000001, precision['km']) + ' km²';\r\n\t\t\t\t} else if (area >= 10000 && units.indexOf('ha') !== -1) {\r\n\t\t\t\t\tareaStr = L.GeometryUtil.formattedNumber(area * 0.0001, precision['ha']) + ' ha';\r\n\t\t\t\t} else {\r\n\t\t\t\t\tareaStr = L.GeometryUtil.formattedNumber(area, precision['m']) + ' m²';\r\n\t\t\t\t}\r\n\t\t\t} else {\r\n\t\t\t\tarea /= 0.836127; // Square yards in 1 meter\r\n\r\n\t\t\t\tif (area >= 3097600) { //3097600 square yards in 1 square mile\r\n\t\t\t\t\tareaStr = L.GeometryUtil.formattedNumber(area / 3097600, precision['mi']) + ' mi²';\r\n\t\t\t\t} else if (area >= 4840) { //4840 square yards in 1 acre\r\n\t\t\t\t\tareaStr = L.GeometryUtil.formattedNumber(area / 4840, precision['ac']) + ' acres';\r\n\t\t\t\t} else {\r\n\t\t\t\t\tareaStr = L.GeometryUtil.formattedNumber(area, precision['yd']) + ' yd²';\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\treturn areaStr;\r\n\t\t},\r\n\r\n\t\t// @method readableDistance(distance, units): string\r\n\t\t// Converts a metric distance to one of [ feet, nauticalMile, metric or yards ] string\r\n\t\t//\r\n\t\t// @alternative\r\n\t\t// @method readableDistance(distance, isMetric, useFeet, isNauticalMile, precision): string\r\n\t\t// Converts metric distance to distance string.\r\n\t\t// The value will be rounded as defined by the precision option object.\r\n\t\treadableDistance: function (distance, isMetric, isFeet, isNauticalMile, precision) {\r\n\t\t\tvar distanceStr,\r\n\t\t\t\tunits,\r\n\t\t\t\tprecision = L.Util.extend({}, defaultPrecision, precision);\r\n\r\n\t\t\tif (isMetric) {\r\n\t\t\t\tunits = typeof isMetric == 'string' ? isMetric : 'metric';\r\n\t\t\t} else if (isFeet) {\r\n\t\t\t\tunits = 'feet';\r\n\t\t\t} else if (isNauticalMile) {\r\n\t\t\t\tunits = 'nauticalMile';\r\n\t\t\t} else {\r\n\t\t\t\tunits = 'yards';\r\n\t\t\t}\r\n\r\n\t\t\tswitch (units) {\r\n\t\t\t\tcase 'metric':\r\n\t\t\t\t\t// show metres when distance is < 1km, then show km\r\n\t\t\t\t\tif (distance > 1000) {\r\n\t\t\t\t\t\tdistanceStr = L.GeometryUtil.formattedNumber(distance / 1000, precision['km']) + ' km';\r\n\t\t\t\t\t} else {\r\n\t\t\t\t\t\tdistanceStr = L.GeometryUtil.formattedNumber(distance, precision['m']) + ' m';\r\n\t\t\t\t\t}\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase 'feet':\r\n\t\t\t\t\tdistance *= 1.09361 * 3;\r\n\t\t\t\t\tdistanceStr = L.GeometryUtil.formattedNumber(distance, precision['ft']) + ' ft';\r\n\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase 'nauticalMile':\r\n\t\t\t\t\tdistance *= 0.53996;\r\n\t\t\t\t\tdistanceStr = L.GeometryUtil.formattedNumber(distance / 1000, precision['nm']) + ' nm';\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase 'yards':\r\n\t\t\t\tdefault:\r\n\t\t\t\t\tdistance *= 1.09361;\r\n\r\n\t\t\t\t\tif (distance > 1760) {\r\n\t\t\t\t\t\tdistanceStr = L.GeometryUtil.formattedNumber(distance / 1760, precision['mi']) + ' miles';\r\n\t\t\t\t\t} else {\r\n\t\t\t\t\t\tdistanceStr = L.GeometryUtil.formattedNumber(distance, precision['yd']) + ' yd';\r\n\t\t\t\t\t}\r\n\t\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t\treturn distanceStr;\r\n\t\t},\r\n\r\n\t\t// @method isVersion07x(): boolean\r\n\t\t// Returns true if the Leaflet version is 0.7.x, false otherwise.\r\n\t\tisVersion07x: function () {\r\n\t\t\tvar version = L.version.split('.');\r\n\t\t\t//If Version is == 0.7.*\r\n\t\t\treturn parseInt(version[0], 10) === 0 && parseInt(version[1], 10) === 7;\r\n\t\t},\r\n\t});\r\n\r\n})();\r\n","/**\r\n * @class L.LineUtil\r\n * @aka Util\r\n * @aka L.Utils\r\n */\r\nL.Util.extend(L.LineUtil, {\r\n\r\n\t// @method segmentsIntersect(): boolean\r\n\t// Checks to see if two line segments intersect. Does not handle degenerate cases.\r\n\t// http://compgeom.cs.uiuc.edu/~jeffe/teaching/373/notes/x06-sweepline.pdf\r\n\tsegmentsIntersect: function (/*Point*/ p, /*Point*/ p1, /*Point*/ p2, /*Point*/ p3) {\r\n\t\treturn this._checkCounterclockwise(p, p2, p3) !==\r\n\t\t\tthis._checkCounterclockwise(p1, p2, p3) &&\r\n\t\t\tthis._checkCounterclockwise(p, p1, p2) !==\r\n\t\t\tthis._checkCounterclockwise(p, p1, p3);\r\n\t},\r\n\r\n\t// check to see if points are in counterclockwise order\r\n\t_checkCounterclockwise: function (/*Point*/ p, /*Point*/ p1, /*Point*/ p2) {\r\n\t\treturn (p2.y - p.y) * (p1.x - p.x) > (p1.y - p.y) * (p2.x - p.x);\r\n\t}\r\n});\r\n","/**\r\n * @class L.Polyline\r\n * @aka Polyline\r\n */\r\nL.Polyline.include({\r\n\r\n\t// @method intersects(): boolean\r\n\t// Check to see if this polyline has any linesegments that intersect.\r\n\t// NOTE: does not support detecting intersection for degenerate cases.\r\n\tintersects: function () {\r\n\t\tvar points = this._getProjectedPoints(),\r\n\t\t\tlen = points ? points.length : 0,\r\n\t\t\ti, p, p1;\r\n\r\n\t\tif (this._tooFewPointsForIntersection()) {\r\n\t\t\treturn false;\r\n\t\t}\r\n\r\n\t\tfor (i = len - 1; i >= 3; i--) {\r\n\t\t\tp = points[i - 1];\r\n\t\t\tp1 = points[i];\r\n\r\n\r\n\t\t\tif (this._lineSegmentsIntersectsRange(p, p1, i - 2)) {\r\n\t\t\t\treturn true;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn false;\r\n\t},\r\n\r\n\t// @method newLatLngIntersects(): boolean\r\n\t// Check for intersection if new latlng was added to this polyline.\r\n\t// NOTE: does not support detecting intersection for degenerate cases.\r\n\tnewLatLngIntersects: function (latlng, skipFirst) {\r\n\t\t// Cannot check a polyline for intersecting lats/lngs when not added to the map\r\n\t\tif (!this._map) {\r\n\t\t\treturn false;\r\n\t\t}\r\n\r\n\t\treturn this.newPointIntersects(this._map.latLngToLayerPoint(latlng), skipFirst);\r\n\t},\r\n\r\n\t// @method newPointIntersects(): boolean\r\n\t// Check for intersection if new point was added to this polyline.\r\n\t// newPoint must be a layer point.\r\n\t// NOTE: does not support detecting intersection for degenerate cases.\r\n\tnewPointIntersects: function (newPoint, skipFirst) {\r\n\t\tvar points = this._getProjectedPoints(),\r\n\t\t\tlen = points ? points.length : 0,\r\n\t\t\tlastPoint = points ? points[len - 1] : null,\r\n\t\t\t// The previous previous line segment. Previous line segment doesn't need testing.\r\n\t\t\tmaxIndex = len - 2;\r\n\r\n\t\tif (this._tooFewPointsForIntersection(1)) {\r\n\t\t\treturn false;\r\n\t\t}\r\n\r\n\t\treturn this._lineSegmentsIntersectsRange(lastPoint, newPoint, maxIndex, skipFirst ? 1 : 0);\r\n\t},\r\n\r\n\t// Polylines with 2 sides can only intersect in cases where points are collinear (we don't support detecting these).\r\n\t// Cannot have intersection when < 3 line segments (< 4 points)\r\n\t_tooFewPointsForIntersection: function (extraPoints) {\r\n\t\tvar points = this._getProjectedPoints(),\r\n\t\t\tlen = points ? points.length : 0;\r\n\t\t// Increment length by extraPoints if present\r\n\t\tlen += extraPoints || 0;\r\n\r\n\t\treturn !points || len <= 3;\r\n\t},\r\n\r\n\t// Checks a line segment intersections with any line segments before its predecessor.\r\n\t// Don't need to check the predecessor as will never intersect.\r\n\t_lineSegmentsIntersectsRange: function (p, p1, maxIndex, minIndex) {\r\n\t\tvar points = this._getProjectedPoints(),\r\n\t\t\tp2, p3;\r\n\r\n\t\tminIndex = minIndex || 0;\r\n\r\n\t\t// Check all previous line segments (beside the immediately previous) for intersections\r\n\t\tfor (var j = maxIndex; j > minIndex; j--) {\r\n\t\t\tp2 = points[j - 1];\r\n\t\t\tp3 = points[j];\r\n\r\n\t\t\tif (L.LineUtil.segmentsIntersect(p, p1, p2, p3)) {\r\n\t\t\t\treturn true;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn false;\r\n\t},\r\n\r\n\t_getProjectedPoints: function () {\r\n\t\tif (!this._defaultShape) {\r\n\t\t\treturn this._originalPoints;\r\n\t\t}\r\n\t\tvar points = [],\r\n\t\t\t_shape = this._defaultShape();\r\n\r\n\t\tfor (var i = 0; i < _shape.length; i++) {\r\n\t\t\tpoints.push(this._map.latLngToLayerPoint(_shape[i]));\r\n\t\t}\r\n\t\treturn points;\r\n\t}\r\n});\r\n","/**\r\n * @class L.Polygon\r\n * @aka Polygon\r\n */\r\nL.Polygon.include({\r\n\r\n\t// @method intersects(): boolean\r\n\t// Checks a polygon for any intersecting line segments. Ignores holes.\r\n\tintersects: function () {\r\n\t\tvar polylineIntersects,\r\n\t\t\tpoints = this._getProjectedPoints(),\r\n\t\t\tlen, firstPoint, lastPoint, maxIndex;\r\n\r\n\t\tif (this._tooFewPointsForIntersection()) {\r\n\t\t\treturn false;\r\n\t\t}\r\n\r\n\t\tpolylineIntersects = L.Polyline.prototype.intersects.call(this);\r\n\r\n\t\t// If already found an intersection don't need to check for any more.\r\n\t\tif (polylineIntersects) {\r\n\t\t\treturn true;\r\n\t\t}\r\n\r\n\t\tlen = points.length;\r\n\t\tfirstPoint = points[0];\r\n\t\tlastPoint = points[len - 1];\r\n\t\tmaxIndex = len - 2;\r\n\r\n\t\t// Check the line segment between last and first point. Don't need to check the first line segment (minIndex = 1)\r\n\t\treturn this._lineSegmentsIntersectsRange(lastPoint, firstPoint, maxIndex, 1);\r\n\t}\r\n});\r\n","/**\r\n * @class L.Control.Draw\r\n * @aka L.Draw\r\n */\r\nL.Control.Draw = L.Control.extend({\r\n\r\n\t// Options\r\n\toptions: {\r\n\t\tposition: 'topleft',\r\n\t\tdraw: {},\r\n\t\tedit: false\r\n\t},\r\n\r\n\t// @method initialize(): void\r\n\t// Initializes draw control, toolbars from the options\r\n\tinitialize: function (options) {\r\n\t\tif (L.version < '0.7') {\r\n\t\t\tthrow new Error('Leaflet.draw 0.2.3+ requires Leaflet 0.7.0+. Download latest from https://github.com/Leaflet/Leaflet/');\r\n\t\t}\r\n\r\n\t\tL.Control.prototype.initialize.call(this, options);\r\n\r\n\t\tvar toolbar;\r\n\r\n\t\tthis._toolbars = {};\r\n\r\n\t\t// Initialize toolbars\r\n\t\tif (L.DrawToolbar && this.options.draw) {\r\n\t\t\ttoolbar = new L.DrawToolbar(this.options.draw);\r\n\r\n\t\t\tthis._toolbars[L.DrawToolbar.TYPE] = toolbar;\r\n\r\n\t\t\t// Listen for when toolbar is enabled\r\n\t\t\tthis._toolbars[L.DrawToolbar.TYPE].on('enable', this._toolbarEnabled, this);\r\n\t\t}\r\n\r\n\t\tif (L.EditToolbar && this.options.edit) {\r\n\t\t\ttoolbar = new L.EditToolbar(this.options.edit);\r\n\r\n\t\t\tthis._toolbars[L.EditToolbar.TYPE] = toolbar;\r\n\r\n\t\t\t// Listen for when toolbar is enabled\r\n\t\t\tthis._toolbars[L.EditToolbar.TYPE].on('enable', this._toolbarEnabled, this);\r\n\t\t}\r\n\t\tL.toolbar = this; //set global var for editing the toolbar\r\n\t},\r\n\r\n\t// @method onAdd(): container\r\n\t// Adds the toolbar container to the map\r\n\tonAdd: function (map) {\r\n\t\tvar container = L.DomUtil.create('div', 'leaflet-draw'),\r\n\t\t\taddedTopClass = false,\r\n\t\t\ttopClassName = 'leaflet-draw-toolbar-top',\r\n\t\t\ttoolbarContainer;\r\n\r\n\t\tfor (var toolbarId in this._toolbars) {\r\n\t\t\tif (this._toolbars.hasOwnProperty(toolbarId)) {\r\n\t\t\t\ttoolbarContainer = this._toolbars[toolbarId].addToolbar(map);\r\n\r\n\t\t\t\tif (toolbarContainer) {\r\n\t\t\t\t\t// Add class to the first toolbar to remove the margin\r\n\t\t\t\t\tif (!addedTopClass) {\r\n\t\t\t\t\t\tif (!L.DomUtil.hasClass(toolbarContainer, topClassName)) {\r\n\t\t\t\t\t\t\tL.DomUtil.addClass(toolbarContainer.childNodes[0], topClassName);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\taddedTopClass = true;\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tcontainer.appendChild(toolbarContainer);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn container;\r\n\t},\r\n\r\n\t// @method onRemove(): void\r\n\t// Removes the toolbars from the map toolbar container\r\n\tonRemove: function () {\r\n\t\tfor (var toolbarId in this._toolbars) {\r\n\t\t\tif (this._toolbars.hasOwnProperty(toolbarId)) {\r\n\t\t\t\tthis._toolbars[toolbarId].removeToolbar();\r\n\t\t\t}\r\n\t\t}\r\n\t},\r\n\r\n\t// @method setDrawingOptions(options): void\r\n\t// Sets options to all toolbar instances\r\n\tsetDrawingOptions: function (options) {\r\n\t\tfor (var toolbarId in this._toolbars) {\r\n\t\t\tif (this._toolbars[toolbarId] instanceof L.DrawToolbar) {\r\n\t\t\t\tthis._toolbars[toolbarId].setOptions(options);\r\n\t\t\t}\r\n\t\t}\r\n\t},\r\n\r\n\t_toolbarEnabled: function (e) {\r\n\t\tvar enabledToolbar = e.target;\r\n\r\n\t\tfor (var toolbarId in this._toolbars) {\r\n\t\t\tif (this._toolbars[toolbarId] !== enabledToolbar) {\r\n\t\t\t\tthis._toolbars[toolbarId].disable();\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n});\r\n\r\nL.Map.mergeOptions({\r\n\tdrawControlTooltips: true,\r\n\tdrawControl: false\r\n});\r\n\r\nL.Map.addInitHook(function () {\r\n\tif (this.options.drawControl) {\r\n\t\tthis.drawControl = new L.Control.Draw();\r\n\t\tthis.addControl(this.drawControl);\r\n\t}\r\n});\r\n","/**\r\n * @class L.Draw.Toolbar\r\n * @aka Toolbar\r\n *\r\n * The toolbar class of the API — it is used to create the ui\r\n * This will be depreciated\r\n *\r\n * @example\r\n *\r\n * ```js\r\n * var toolbar = L.Toolbar();\r\n * toolbar.addToolbar(map);\r\n * ```\r\n *\r\n * ### Disabling a toolbar\r\n *\r\n * If you do not want a particular toolbar in your app you can turn it off by setting the toolbar to false.\r\n *\r\n * ```js\r\n * var drawControl = new L.Control.Draw({\r\n * draw: false,\r\n * edit: {\r\n * featureGroup: editableLayers\r\n * }\r\n * });\r\n * ```\r\n *\r\n * ### Disabling a toolbar item\r\n *\r\n * If you want to turn off a particular toolbar item, set it to false. The following disables drawing polygons and\r\n * markers. It also turns off the ability to edit layers.\r\n *\r\n * ```js\r\n * var drawControl = new L.Control.Draw({\r\n * draw: {\r\n * polygon: false,\r\n * marker: false\r\n * },\r\n * edit: {\r\n * featureGroup: editableLayers,\r\n * edit: false\r\n * }\r\n * });\r\n * ```\r\n */\r\nL.Toolbar = L.Class.extend({\r\n\t// @section Methods for modifying the toolbar\r\n\r\n\t// @method initialize(options): void\r\n\t// Toolbar constructor\r\n\tinitialize: function (options) {\r\n\t\tL.setOptions(this, options);\r\n\r\n\t\tthis._modes = {};\r\n\t\tthis._actionButtons = [];\r\n\t\tthis._activeMode = null;\r\n\r\n\t\tvar version = L.version.split('.');\r\n\t\t//If Version is >= 1.2.0\r\n\t\tif (parseInt(version[0], 10) === 1 && parseInt(version[1], 10) >= 2) {\r\n\t\t\tL.Toolbar.include(L.Evented.prototype);\r\n\t\t} else {\r\n\t\t\tL.Toolbar.include(L.Mixin.Events);\r\n\t\t}\r\n\t},\r\n\r\n\t// @method enabled(): boolean\r\n\t// Gets a true/false of whether the toolbar is enabled\r\n\tenabled: function () {\r\n\t\treturn this._activeMode !== null;\r\n\t},\r\n\r\n\t// @method disable(): void\r\n\t// Disables the toolbar\r\n\tdisable: function () {\r\n\t\tif (!this.enabled()) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tthis._activeMode.handler.disable();\r\n\t},\r\n\r\n\t// @method addToolbar(map): L.DomUtil\r\n\t// Adds the toolbar to the map and returns the toolbar dom element\r\n\taddToolbar: function (map) {\r\n\t\tvar container = L.DomUtil.create('div', 'leaflet-draw-section'),\r\n\t\t\tbuttonIndex = 0,\r\n\t\t\tbuttonClassPrefix = this._toolbarClass || '',\r\n\t\t\tmodeHandlers = this.getModeHandlers(map),\r\n\t\t\ti;\r\n\r\n\t\tthis._toolbarContainer = L.DomUtil.create('div', 'leaflet-draw-toolbar leaflet-bar');\r\n\t\tthis._map = map;\r\n\r\n\t\tfor (i = 0; i < modeHandlers.length; i++) {\r\n\t\t\tif (modeHandlers[i].enabled) {\r\n\t\t\t\tthis._initModeHandler(\r\n\t\t\t\t\tmodeHandlers[i].handler,\r\n\t\t\t\t\tthis._toolbarContainer,\r\n\t\t\t\t\tbuttonIndex++,\r\n\t\t\t\t\tbuttonClassPrefix,\r\n\t\t\t\t\tmodeHandlers[i].title\r\n\t\t\t\t);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// if no buttons were added, do not add the toolbar\r\n\t\tif (!buttonIndex) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\t// Save button index of the last button, -1 as we would have ++ after the last button\r\n\t\tthis._lastButtonIndex = --buttonIndex;\r\n\r\n\t\t// Create empty actions part of the toolbar\r\n\t\tthis._actionsContainer = L.DomUtil.create('ul', 'leaflet-draw-actions');\r\n\r\n\t\t// Add draw and cancel containers to the control container\r\n\t\tcontainer.appendChild(this._toolbarContainer);\r\n\t\tcontainer.appendChild(this._actionsContainer);\r\n\r\n\t\treturn container;\r\n\t},\r\n\r\n\t// @method removeToolbar(): void\r\n\t// Removes the toolbar and drops the handler event listeners\r\n\tremoveToolbar: function () {\r\n\t\t// Dispose each handler\r\n\t\tfor (var handlerId in this._modes) {\r\n\t\t\tif (this._modes.hasOwnProperty(handlerId)) {\r\n\t\t\t\t// Unbind handler button\r\n\t\t\t\tthis._disposeButton(\r\n\t\t\t\t\tthis._modes[handlerId].button,\r\n\t\t\t\t\tthis._modes[handlerId].handler.enable,\r\n\t\t\t\t\tthis._modes[handlerId].handler\r\n\t\t\t\t);\r\n\r\n\t\t\t\t// Make sure is disabled\r\n\t\t\t\tthis._modes[handlerId].handler.disable();\r\n\r\n\t\t\t\t// Unbind handler\r\n\t\t\t\tthis._modes[handlerId].handler\r\n\t\t\t\t\t.off('enabled', this._handlerActivated, this)\r\n\t\t\t\t\t.off('disabled', this._handlerDeactivated, this);\r\n\t\t\t}\r\n\t\t}\r\n\t\tthis._modes = {};\r\n\r\n\t\t// Dispose the actions toolbar\r\n\t\tfor (var i = 0, l = this._actionButtons.length; i < l; i++) {\r\n\t\t\tthis._disposeButton(\r\n\t\t\t\tthis._actionButtons[i].button,\r\n\t\t\t\tthis._actionButtons[i].callback,\r\n\t\t\t\tthis\r\n\t\t\t);\r\n\t\t}\r\n\t\tthis._actionButtons = [];\r\n\t\tthis._actionsContainer = null;\r\n\t},\r\n\r\n\t_initModeHandler: function (handler, container, buttonIndex, classNamePredix, buttonTitle) {\r\n\t\tvar type = handler.type;\r\n\r\n\t\tthis._modes[type] = {};\r\n\r\n\t\tthis._modes[type].handler = handler;\r\n\r\n\t\tthis._modes[type].button = this._createButton({\r\n\t\t\ttype: type,\r\n\t\t\ttitle: buttonTitle,\r\n\t\t\tclassName: classNamePredix + '-' + type,\r\n\t\t\tcontainer: container,\r\n\t\t\tcallback: this._modes[type].handler.enable,\r\n\t\t\tcontext: this._modes[type].handler\r\n\t\t});\r\n\r\n\t\tthis._modes[type].buttonIndex = buttonIndex;\r\n\r\n\t\tthis._modes[type].handler\r\n\t\t\t.on('enabled', this._handlerActivated, this)\r\n\t\t\t.on('disabled', this._handlerDeactivated, this);\r\n\t},\r\n\r\n\t/* Detect iOS based on browser User Agent, based on:\r\n\t * http://stackoverflow.com/a/9039885 */\r\n\t_detectIOS: function () {\r\n\t\tvar iOS = (/iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream);\r\n\t\treturn iOS;\r\n\t},\r\n\r\n\t_createButton: function (options) {\r\n\r\n\t\tvar link = L.DomUtil.create('a', options.className || '', options.container);\r\n\t\t// Screen reader tag\r\n\t\tvar sr = L.DomUtil.create('span', 'sr-only', options.container);\r\n\r\n\t\tlink.href = '#';\r\n\t\tlink.appendChild(sr);\r\n\r\n\t\tif (options.title) {\r\n\t\t\tlink.title = options.title;\r\n\t\t\tsr.innerHTML = options.title;\r\n\t\t}\r\n\r\n\t\tif (options.text) {\r\n\t\t\tlink.innerHTML = options.text;\r\n\t\t\tsr.innerHTML = options.text;\r\n\t\t}\r\n\r\n\t\t/* iOS does not use click events */\r\n\t\tvar buttonEvent = this._detectIOS() ? 'touchstart' : 'click';\r\n\r\n\t\tL.DomEvent\r\n\t\t\t.on(link, 'click', L.DomEvent.stopPropagation)\r\n\t\t\t.on(link, 'mousedown', L.DomEvent.stopPropagation)\r\n\t\t\t.on(link, 'dblclick', L.DomEvent.stopPropagation)\r\n\t\t\t.on(link, 'touchstart', L.DomEvent.stopPropagation)\r\n\t\t\t.on(link, 'click', L.DomEvent.preventDefault)\r\n\t\t\t.on(link, buttonEvent, options.callback, options.context);\r\n\r\n\t\treturn link;\r\n\t},\r\n\r\n\t_disposeButton: function (button, callback) {\r\n\t\t/* iOS does not use click events */\r\n\t\tvar buttonEvent = this._detectIOS() ? 'touchstart' : 'click';\r\n\r\n\t\tL.DomEvent\r\n\t\t\t.off(button, 'click', L.DomEvent.stopPropagation)\r\n\t\t\t.off(button, 'mousedown', L.DomEvent.stopPropagation)\r\n\t\t\t.off(button, 'dblclick', L.DomEvent.stopPropagation)\r\n\t\t\t.off(button, 'touchstart', L.DomEvent.stopPropagation)\r\n\t\t\t.off(button, 'click', L.DomEvent.preventDefault)\r\n\t\t\t.off(button, buttonEvent, callback);\r\n\t},\r\n\r\n\t_handlerActivated: function (e) {\r\n\t\t// Disable active mode (if present)\r\n\t\tthis.disable();\r\n\r\n\t\t// Cache new active feature\r\n\t\tthis._activeMode = this._modes[e.handler];\r\n\r\n\t\tL.DomUtil.addClass(this._activeMode.button, 'leaflet-draw-toolbar-button-enabled');\r\n\r\n\t\tthis._showActionsToolbar();\r\n\r\n\t\tthis.fire('enable');\r\n\t},\r\n\r\n\t_handlerDeactivated: function () {\r\n\t\tthis._hideActionsToolbar();\r\n\r\n\t\tL.DomUtil.removeClass(this._activeMode.button, 'leaflet-draw-toolbar-button-enabled');\r\n\r\n\t\tthis._activeMode = null;\r\n\r\n\t\tthis.fire('disable');\r\n\t},\r\n\r\n\t_createActions: function (handler) {\r\n\t\tvar container = this._actionsContainer,\r\n\t\t\tbuttons = this.getActions(handler),\r\n\t\t\tl = buttons.length,\r\n\t\t\tli, di, dl, button;\r\n\r\n\t\t// Dispose the actions toolbar (todo: dispose only not used buttons)\r\n\t\tfor (di = 0, dl = this._actionButtons.length; di < dl; di++) {\r\n\t\t\tthis._disposeButton(this._actionButtons[di].button, this._actionButtons[di].callback);\r\n\t\t}\r\n\t\tthis._actionButtons = [];\r\n\r\n\t\t// Remove all old buttons\r\n\t\twhile (container.firstChild) {\r\n\t\t\tcontainer.removeChild(container.firstChild);\r\n\t\t}\r\n\r\n\t\tfor (var i = 0; i < l; i++) {\r\n\t\t\tif ('enabled' in buttons[i] && !buttons[i].enabled) {\r\n\t\t\t\tcontinue;\r\n\t\t\t}\r\n\r\n\t\t\tli = L.DomUtil.create('li', '', container);\r\n\r\n\t\t\tbutton = this._createButton({\r\n\t\t\t\ttitle: buttons[i].title,\r\n\t\t\t\ttext: buttons[i].text,\r\n\t\t\t\tcontainer: li,\r\n\t\t\t\tcallback: buttons[i].callback,\r\n\t\t\t\tcontext: buttons[i].context\r\n\t\t\t});\r\n\r\n\t\t\tthis._actionButtons.push({\r\n\t\t\t\tbutton: button,\r\n\t\t\t\tcallback: buttons[i].callback\r\n\t\t\t});\r\n\t\t}\r\n\t},\r\n\r\n\t_showActionsToolbar: function () {\r\n\t\tvar buttonIndex = this._activeMode.buttonIndex,\r\n\t\t\tlastButtonIndex = this._lastButtonIndex,\r\n\t\t\ttoolbarPosition = this._activeMode.button.offsetTop - 1;\r\n\r\n\t\t// Recreate action buttons on every click\r\n\t\tthis._createActions(this._activeMode.handler);\r\n\r\n\t\t// Correctly position the cancel button\r\n\t\tthis._actionsContainer.style.top = toolbarPosition + 'px';\r\n\r\n\t\tif (buttonIndex === 0) {\r\n\t\t\tL.DomUtil.addClass(this._toolbarContainer, 'leaflet-draw-toolbar-notop');\r\n\t\t\tL.DomUtil.addClass(this._actionsContainer, 'leaflet-draw-actions-top');\r\n\t\t}\r\n\r\n\t\tif (buttonIndex === lastButtonIndex) {\r\n\t\t\tL.DomUtil.addClass(this._toolbarContainer, 'leaflet-draw-toolbar-nobottom');\r\n\t\t\tL.DomUtil.addClass(this._actionsContainer, 'leaflet-draw-actions-bottom');\r\n\t\t}\r\n\r\n\t\tthis._actionsContainer.style.display = 'block';\r\n\t\tthis._map.fire(L.Draw.Event.TOOLBAROPENED);\r\n\t},\r\n\r\n\t_hideActionsToolbar: function () {\r\n\t\tthis._actionsContainer.style.display = 'none';\r\n\r\n\t\tL.DomUtil.removeClass(this._toolbarContainer, 'leaflet-draw-toolbar-notop');\r\n\t\tL.DomUtil.removeClass(this._toolbarContainer, 'leaflet-draw-toolbar-nobottom');\r\n\t\tL.DomUtil.removeClass(this._actionsContainer, 'leaflet-draw-actions-top');\r\n\t\tL.DomUtil.removeClass(this._actionsContainer, 'leaflet-draw-actions-bottom');\r\n\t\tthis._map.fire(L.Draw.Event.TOOLBARCLOSED);\r\n\t}\r\n});\r\n","L.Draw = L.Draw || {};\r\n/**\r\n * @class L.Draw.Tooltip\r\n * @aka Tooltip\r\n *\r\n * The tooltip class — it is used to display the tooltip while drawing\r\n * This will be depreciated\r\n *\r\n * @example\r\n *\r\n * ```js\r\n * var tooltip = L.Draw.Tooltip();\r\n * ```\r\n *\r\n */\r\nL.Draw.Tooltip = L.Class.extend({\r\n\r\n\t// @section Methods for modifying draw state\r\n\r\n\t// @method initialize(map): void\r\n\t// Tooltip constructor\r\n\tinitialize: function (map) {\r\n\t\tthis._map = map;\r\n\t\tthis._popupPane = map._panes.popupPane;\r\n\t\tthis._visible = false;\r\n\r\n\t\tthis._container = map.options.drawControlTooltips ?\r\n\t\t\tL.DomUtil.create('div', 'leaflet-draw-tooltip', this._popupPane) : null;\r\n\t\tthis._singleLineLabel = false;\r\n\r\n\t\tthis._map.on('mouseout', this._onMouseOut, this);\r\n\t},\r\n\r\n\t// @method dispose(): void\r\n\t// Remove Tooltip DOM and unbind events\r\n\tdispose: function () {\r\n\t\tthis._map.off('mouseout', this._onMouseOut, this);\r\n\r\n\t\tif (this._container) {\r\n\t\t\tthis._popupPane.removeChild(this._container);\r\n\t\t\tthis._container = null;\r\n\t\t}\r\n\t},\r\n\r\n\t// @method updateContent(labelText): this\r\n\t// Changes the tooltip text to string in function call\r\n\tupdateContent: function (labelText) {\r\n\t\tif (!this._container) {\r\n\t\t\treturn this;\r\n\t\t}\r\n\t\tlabelText.subtext = labelText.subtext || '';\r\n\r\n\t\t// update the vertical position (only if changed)\r\n\t\tif (labelText.subtext.length === 0 && !this._singleLineLabel) {\r\n\t\t\tL.DomUtil.addClass(this._container, 'leaflet-draw-tooltip-single');\r\n\t\t\tthis._singleLineLabel = true;\r\n\t\t}\r\n\t\telse if (labelText.subtext.length > 0 && this._singleLineLabel) {\r\n\t\t\tL.DomUtil.removeClass(this._container, 'leaflet-draw-tooltip-single');\r\n\t\t\tthis._singleLineLabel = false;\r\n\t\t}\r\n\r\n\t\tthis._container.innerHTML =\r\n\t\t\t(labelText.subtext.length > 0 ?\r\n\t\t\t\t'' + labelText.subtext + '' + '
' : '') +\r\n\t\t\t'' + labelText.text + '';\r\n\r\n\t\tif (!labelText.text && !labelText.subtext) {\r\n\t\t\tthis._visible = false;\r\n\t\t\tthis._container.style.visibility = 'hidden';\r\n\t\t} else {\r\n\t\t\tthis._visible = true;\r\n\t\t\tthis._container.style.visibility = 'inherit';\r\n\t\t}\r\n\r\n\t\treturn this;\r\n\t},\r\n\r\n\t// @method updatePosition(latlng): this\r\n\t// Changes the location of the tooltip\r\n\tupdatePosition: function (latlng) {\r\n\t\tvar pos = this._map.latLngToLayerPoint(latlng),\r\n\t\t\ttooltipContainer = this._container;\r\n\r\n\t\tif (this._container) {\r\n\t\t\tif (this._visible) {\r\n\t\t\t\ttooltipContainer.style.visibility = 'inherit';\r\n\t\t\t}\r\n\t\t\tL.DomUtil.setPosition(tooltipContainer, pos);\r\n\t\t}\r\n\r\n\t\treturn this;\r\n\t},\r\n\r\n\t// @method showAsError(): this\r\n\t// Applies error class to tooltip\r\n\tshowAsError: function () {\r\n\t\tif (this._container) {\r\n\t\t\tL.DomUtil.addClass(this._container, 'leaflet-error-draw-tooltip');\r\n\t\t}\r\n\t\treturn this;\r\n\t},\r\n\r\n\t// @method removeError(): this\r\n\t// Removes the error class from the tooltip\r\n\tremoveError: function () {\r\n\t\tif (this._container) {\r\n\t\t\tL.DomUtil.removeClass(this._container, 'leaflet-error-draw-tooltip');\r\n\t\t}\r\n\t\treturn this;\r\n\t},\r\n\r\n\t_onMouseOut: function () {\r\n\t\tif (this._container) {\r\n\t\t\tthis._container.style.visibility = 'hidden';\r\n\t\t}\r\n\t}\r\n});\r\n","/**\r\n * @class L.DrawToolbar\r\n * @aka Toolbar\r\n */\r\nL.DrawToolbar = L.Toolbar.extend({\r\n\r\n\tstatics: {\r\n\t\tTYPE: 'draw'\r\n\t},\r\n\r\n\toptions: {\r\n\t\tpolyline: {},\r\n\t\tpolygon: {},\r\n\t\trectangle: {},\r\n\t\tcircle: {},\r\n\t\tmarker: {},\r\n\t\tcirclemarker: {}\r\n\t},\r\n\r\n\t// @method initialize(): void\r\n\tinitialize: function (options) {\r\n\t\t// Ensure that the options are merged correctly since L.extend is only shallow\r\n\t\tfor (var type in this.options) {\r\n\t\t\tif (this.options.hasOwnProperty(type)) {\r\n\t\t\t\tif (options[type]) {\r\n\t\t\t\t\toptions[type] = L.extend({}, this.options[type], options[type]);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tthis._toolbarClass = 'leaflet-draw-draw';\r\n\t\tL.Toolbar.prototype.initialize.call(this, options);\r\n\t},\r\n\r\n\t// @method getModeHandlers(): object\r\n\t// Get mode handlers information\r\n\tgetModeHandlers: function (map) {\r\n\t\treturn [\r\n\t\t\t{\r\n\t\t\t\tenabled: this.options.polyline,\r\n\t\t\t\thandler: new L.Draw.Polyline(map, this.options.polyline),\r\n\t\t\t\ttitle: L.drawLocal.draw.toolbar.buttons.polyline\r\n\t\t\t},\r\n\t\t\t{\r\n\t\t\t\tenabled: this.options.polygon,\r\n\t\t\t\thandler: new L.Draw.Polygon(map, this.options.polygon),\r\n\t\t\t\ttitle: L.drawLocal.draw.toolbar.buttons.polygon\r\n\t\t\t},\r\n\t\t\t{\r\n\t\t\t\tenabled: this.options.rectangle,\r\n\t\t\t\thandler: new L.Draw.Rectangle(map, this.options.rectangle),\r\n\t\t\t\ttitle: L.drawLocal.draw.toolbar.buttons.rectangle\r\n\t\t\t},\r\n\t\t\t{\r\n\t\t\t\tenabled: this.options.circle,\r\n\t\t\t\thandler: new L.Draw.Circle(map, this.options.circle),\r\n\t\t\t\ttitle: L.drawLocal.draw.toolbar.buttons.circle\r\n\t\t\t},\r\n\t\t\t{\r\n\t\t\t\tenabled: this.options.marker,\r\n\t\t\t\thandler: new L.Draw.Marker(map, this.options.marker),\r\n\t\t\t\ttitle: L.drawLocal.draw.toolbar.buttons.marker\r\n\t\t\t},\r\n\t\t\t{\r\n\t\t\t\tenabled: this.options.circlemarker,\r\n\t\t\t\thandler: new L.Draw.CircleMarker(map, this.options.circlemarker),\r\n\t\t\t\ttitle: L.drawLocal.draw.toolbar.buttons.circlemarker\r\n\t\t\t}\r\n\t\t];\r\n\t},\r\n\r\n\t// @method getActions(): object\r\n\t// Get action information\r\n\tgetActions: function (handler) {\r\n\t\treturn [\r\n\t\t\t{\r\n\t\t\t\tenabled: handler.completeShape,\r\n\t\t\t\ttitle: L.drawLocal.draw.toolbar.finish.title,\r\n\t\t\t\ttext: L.drawLocal.draw.toolbar.finish.text,\r\n\t\t\t\tcallback: handler.completeShape,\r\n\t\t\t\tcontext: handler\r\n\t\t\t},\r\n\t\t\t{\r\n\t\t\t\tenabled: handler.deleteLastVertex,\r\n\t\t\t\ttitle: L.drawLocal.draw.toolbar.undo.title,\r\n\t\t\t\ttext: L.drawLocal.draw.toolbar.undo.text,\r\n\t\t\t\tcallback: handler.deleteLastVertex,\r\n\t\t\t\tcontext: handler\r\n\t\t\t},\r\n\t\t\t{\r\n\t\t\t\ttitle: L.drawLocal.draw.toolbar.actions.title,\r\n\t\t\t\ttext: L.drawLocal.draw.toolbar.actions.text,\r\n\t\t\t\tcallback: this.disable,\r\n\t\t\t\tcontext: this\r\n\t\t\t}\r\n\t\t];\r\n\t},\r\n\r\n\t// @method setOptions(): void\r\n\t// Sets the options to the toolbar\r\n\tsetOptions: function (options) {\r\n\t\tL.setOptions(this, options);\r\n\r\n\t\tfor (var type in this._modes) {\r\n\t\t\tif (this._modes.hasOwnProperty(type) && options.hasOwnProperty(type)) {\r\n\t\t\t\tthis._modes[type].handler.setOptions(options[type]);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n});\r\n","/*L.Map.mergeOptions({\r\n editControl: true\r\n });*/\r\n/**\r\n * @class L.EditToolbar\r\n * @aka EditToolbar\r\n */\r\nL.EditToolbar = L.Toolbar.extend({\r\n\tstatics: {\r\n\t\tTYPE: 'edit'\r\n\t},\r\n\r\n\toptions: {\r\n\t\tedit: {\r\n\t\t\tselectedPathOptions: {\r\n\t\t\t\tdashArray: '10, 10',\r\n\r\n\t\t\t\tfill: true,\r\n\t\t\t\tfillColor: '#fe57a1',\r\n\t\t\t\tfillOpacity: 0.1,\r\n\r\n\t\t\t\t// Whether to user the existing layers color\r\n\t\t\t\tmaintainColor: false\r\n\t\t\t}\r\n\t\t},\r\n\t\tremove: {},\r\n\t\tpoly: null,\r\n\t\tfeatureGroup: null /* REQUIRED! TODO: perhaps if not set then all layers on the map are selectable? */\r\n\t},\r\n\r\n\t// @method intialize(): void\r\n\tinitialize: function (options) {\r\n\t\t// Need to set this manually since null is an acceptable value here\r\n\t\tif (options.edit) {\r\n\t\t\tif (typeof options.edit.selectedPathOptions === 'undefined') {\r\n\t\t\t\toptions.edit.selectedPathOptions = this.options.edit.selectedPathOptions;\r\n\t\t\t}\r\n\t\t\toptions.edit.selectedPathOptions = L.extend({}, this.options.edit.selectedPathOptions, options.edit.selectedPathOptions);\r\n\t\t}\r\n\r\n\t\tif (options.remove) {\r\n\t\t\toptions.remove = L.extend({}, this.options.remove, options.remove);\r\n\t\t}\r\n\r\n\t\tif (options.poly) {\r\n\t\t\toptions.poly = L.extend({}, this.options.poly, options.poly);\r\n\t\t}\r\n\r\n\t\tthis._toolbarClass = 'leaflet-draw-edit';\r\n\t\tL.Toolbar.prototype.initialize.call(this, options);\r\n\r\n\t\tthis._selectedFeatureCount = 0;\r\n\t},\r\n\r\n\t// @method getModeHandlers(): object\r\n\t// Get mode handlers information\r\n\tgetModeHandlers: function (map) {\r\n\t\tvar featureGroup = this.options.featureGroup;\r\n\t\treturn [\r\n\t\t\t{\r\n\t\t\t\tenabled: this.options.edit,\r\n\t\t\t\thandler: new L.EditToolbar.Edit(map, {\r\n\t\t\t\t\tfeatureGroup: featureGroup,\r\n\t\t\t\t\tselectedPathOptions: this.options.edit.selectedPathOptions,\r\n\t\t\t\t\tpoly: this.options.poly\r\n\t\t\t\t}),\r\n\t\t\t\ttitle: L.drawLocal.edit.toolbar.buttons.edit\r\n\t\t\t},\r\n\t\t\t{\r\n\t\t\t\tenabled: this.options.remove,\r\n\t\t\t\thandler: new L.EditToolbar.Delete(map, {\r\n\t\t\t\t\tfeatureGroup: featureGroup\r\n\t\t\t\t}),\r\n\t\t\t\ttitle: L.drawLocal.edit.toolbar.buttons.remove\r\n\t\t\t}\r\n\t\t];\r\n\t},\r\n\r\n\t// @method getActions(): object\r\n\t// Get actions information\r\n\tgetActions: function (handler) {\r\n\t\tvar actions = [\r\n\t\t\t{\r\n\t\t\t\ttitle: L.drawLocal.edit.toolbar.actions.save.title,\r\n\t\t\t\ttext: L.drawLocal.edit.toolbar.actions.save.text,\r\n\t\t\t\tcallback: this._save,\r\n\t\t\t\tcontext: this\r\n\t\t\t},\r\n\t\t\t{\r\n\t\t\t\ttitle: L.drawLocal.edit.toolbar.actions.cancel.title,\r\n\t\t\t\ttext: L.drawLocal.edit.toolbar.actions.cancel.text,\r\n\t\t\t\tcallback: this.disable,\r\n\t\t\t\tcontext: this\r\n\t\t\t}\r\n\t\t];\r\n\r\n\t\tif (handler.removeAllLayers) {\r\n\t\t\tactions.push({\r\n\t\t\t\ttitle: L.drawLocal.edit.toolbar.actions.clearAll.title,\r\n\t\t\t\ttext: L.drawLocal.edit.toolbar.actions.clearAll.text,\r\n\t\t\t\tcallback: this._clearAllLayers,\r\n\t\t\t\tcontext: this\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\treturn actions;\r\n\t},\r\n\r\n\t// @method addToolbar(map): L.DomUtil\r\n\t// Adds the toolbar to the map\r\n\taddToolbar: function (map) {\r\n\t\tvar container = L.Toolbar.prototype.addToolbar.call(this, map);\r\n\r\n\t\tthis._checkDisabled();\r\n\r\n\t\tthis.options.featureGroup.on('layeradd layerremove', this._checkDisabled, this);\r\n\r\n\t\treturn container;\r\n\t},\r\n\r\n\t// @method removeToolbar(): void\r\n\t// Removes the toolbar from the map\r\n\tremoveToolbar: function () {\r\n\t\tthis.options.featureGroup.off('layeradd layerremove', this._checkDisabled, this);\r\n\r\n\t\tL.Toolbar.prototype.removeToolbar.call(this);\r\n\t},\r\n\r\n\t// @method disable(): void\r\n\t// Disables the toolbar\r\n\tdisable: function () {\r\n\t\tif (!this.enabled()) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tthis._activeMode.handler.revertLayers();\r\n\r\n\t\tL.Toolbar.prototype.disable.call(this);\r\n\t},\r\n\r\n\t_save: function () {\r\n\t\tthis._activeMode.handler.save();\r\n\t\tif (this._activeMode) {\r\n\t\t\tthis._activeMode.handler.disable();\r\n\t\t}\r\n\t},\r\n\r\n\t_clearAllLayers: function () {\r\n\t\tthis._activeMode.handler.removeAllLayers();\r\n\t\tif (this._activeMode) {\r\n\t\t\tthis._activeMode.handler.disable();\r\n\t\t}\r\n\t},\r\n\r\n\t_checkDisabled: function () {\r\n\t\tvar featureGroup = this.options.featureGroup,\r\n\t\t\thasLayers = featureGroup.getLayers().length !== 0,\r\n\t\t\tbutton;\r\n\r\n\t\tif (this.options.edit) {\r\n\t\t\tbutton = this._modes[L.EditToolbar.Edit.TYPE].button;\r\n\r\n\t\t\tif (hasLayers) {\r\n\t\t\t\tL.DomUtil.removeClass(button, 'leaflet-disabled');\r\n\t\t\t} else {\r\n\t\t\t\tL.DomUtil.addClass(button, 'leaflet-disabled');\r\n\t\t\t}\r\n\r\n\t\t\tbutton.setAttribute(\r\n\t\t\t\t'title',\r\n\t\t\t\thasLayers ?\r\n\t\t\t\t\tL.drawLocal.edit.toolbar.buttons.edit\r\n\t\t\t\t\t: L.drawLocal.edit.toolbar.buttons.editDisabled\r\n\t\t\t);\r\n\t\t}\r\n\r\n\t\tif (this.options.remove) {\r\n\t\t\tbutton = this._modes[L.EditToolbar.Delete.TYPE].button;\r\n\r\n\t\t\tif (hasLayers) {\r\n\t\t\t\tL.DomUtil.removeClass(button, 'leaflet-disabled');\r\n\t\t\t} else {\r\n\t\t\t\tL.DomUtil.addClass(button, 'leaflet-disabled');\r\n\t\t\t}\r\n\r\n\t\t\tbutton.setAttribute(\r\n\t\t\t\t'title',\r\n\t\t\t\thasLayers ?\r\n\t\t\t\t\tL.drawLocal.edit.toolbar.buttons.remove\r\n\t\t\t\t\t: L.drawLocal.edit.toolbar.buttons.removeDisabled\r\n\t\t\t);\r\n\t\t}\r\n\t}\r\n});\r\n","/**\r\n * @class L.EditToolbar.Edit\r\n * @aka EditToolbar.Edit\r\n */\r\nL.EditToolbar.Edit = L.Handler.extend({\r\n\tstatics: {\r\n\t\tTYPE: 'edit'\r\n\t},\r\n\r\n\t// @method intialize(): void\r\n\tinitialize: function (map, options) {\r\n\t\tL.Handler.prototype.initialize.call(this, map);\r\n\r\n\t\tL.setOptions(this, options);\r\n\r\n\t\t// Store the selectable layer group for ease of access\r\n\t\tthis._featureGroup = options.featureGroup;\r\n\r\n\t\tif (!(this._featureGroup instanceof L.FeatureGroup)) {\r\n\t\t\tthrow new Error('options.featureGroup must be a L.FeatureGroup');\r\n\t\t}\r\n\r\n\t\tthis._uneditedLayerProps = {};\r\n\r\n\t\t// Save the type so super can fire, need to do this as cannot do this.TYPE :(\r\n\t\tthis.type = L.EditToolbar.Edit.TYPE;\r\n\r\n\t\tvar version = L.version.split('.');\r\n\t\t//If Version is >= 1.2.0\r\n\t\tif (parseInt(version[0], 10) === 1 && parseInt(version[1], 10) >= 2) {\r\n\t\t\tL.EditToolbar.Edit.include(L.Evented.prototype);\r\n\t\t} else {\r\n\t\t\tL.EditToolbar.Edit.include(L.Mixin.Events);\r\n\t\t}\r\n\t},\r\n\r\n\t// @method enable(): void\r\n\t// Enable the edit toolbar\r\n\tenable: function () {\r\n\t\tif (this._enabled || !this._hasAvailableLayers()) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tthis.fire('enabled', {handler: this.type});\r\n\t\t//this disable other handlers\r\n\r\n\t\tthis._map.fire(L.Draw.Event.EDITSTART, {handler: this.type});\r\n\t\t//allow drawLayer to be updated before beginning edition.\r\n\r\n\t\tL.Handler.prototype.enable.call(this);\r\n\t\tthis._featureGroup\r\n\t\t\t.on('layeradd', this._enableLayerEdit, this)\r\n\t\t\t.on('layerremove', this._disableLayerEdit, this);\r\n\t},\r\n\r\n\t// @method disable(): void\r\n\t// Disable the edit toolbar\r\n\tdisable: function () {\r\n\t\tif (!this._enabled) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tthis._featureGroup\r\n\t\t\t.off('layeradd', this._enableLayerEdit, this)\r\n\t\t\t.off('layerremove', this._disableLayerEdit, this);\r\n\t\tL.Handler.prototype.disable.call(this);\r\n\t\tthis._map.fire(L.Draw.Event.EDITSTOP, {handler: this.type});\r\n\t\tthis.fire('disabled', {handler: this.type});\r\n\t},\r\n\r\n\t// @method addHooks(): void\r\n\t// Add listener hooks for this handler\r\n\taddHooks: function () {\r\n\t\tvar map = this._map;\r\n\r\n\t\tif (map) {\r\n\t\t\tmap.getContainer().focus();\r\n\r\n\t\t\tthis._featureGroup.eachLayer(this._enableLayerEdit, this);\r\n\r\n\t\t\tthis._tooltip = new L.Draw.Tooltip(this._map);\r\n\t\t\tthis._tooltip.updateContent({\r\n\t\t\t\ttext: L.drawLocal.edit.handlers.edit.tooltip.text,\r\n\t\t\t\tsubtext: L.drawLocal.edit.handlers.edit.tooltip.subtext\r\n\t\t\t});\r\n\r\n\t\t\t// Quickly access the tooltip to update for intersection checking\r\n\t\t\tmap._editTooltip = this._tooltip;\r\n\r\n\t\t\tthis._updateTooltip();\r\n\r\n\t\t\tthis._map\r\n\t\t\t\t.on('mousemove', this._onMouseMove, this)\r\n\t\t\t\t.on('touchmove', this._onMouseMove, this)\r\n\t\t\t\t.on('MSPointerMove', this._onMouseMove, this)\r\n\t\t\t\t.on(L.Draw.Event.EDITVERTEX, this._updateTooltip, this);\r\n\t\t}\r\n\t},\r\n\r\n\t// @method removeHooks(): void\r\n\t// Remove listener hooks for this handler\r\n\tremoveHooks: function () {\r\n\t\tif (this._map) {\r\n\t\t\t// Clean up selected layers.\r\n\t\t\tthis._featureGroup.eachLayer(this._disableLayerEdit, this);\r\n\t\t\tthis._map._editTooltip.dispose();\r\n\t\t\tthis._map._editTooltip = null;\r\n\t\t\t// Clear the backups of the original layers\r\n\t\t\tthis._uneditedLayerProps = {};\r\n\r\n\t\t\tthis._tooltip.dispose();\r\n\t\t\tthis._tooltip = null;\r\n\r\n\t\t\tthis._map\r\n\t\t\t\t.off('mousemove', this._onMouseMove, this)\r\n\t\t\t\t.off('touchmove', this._onMouseMove, this)\r\n\t\t\t\t.off('MSPointerMove', this._onMouseMove, this)\r\n\t\t\t\t.off(L.Draw.Event.EDITVERTEX, this._updateTooltip, this);\r\n\t\t}\r\n\t},\r\n\r\n\t// @method revertLayers(): void\r\n\t// Revert each layer's geometry changes\r\n\trevertLayers: function () {\r\n\t\tthis._featureGroup.eachLayer(function (layer) {\r\n\t\t\tthis._revertLayer(layer);\r\n\t\t}, this);\r\n\t},\r\n\r\n\t// @method save(): void\r\n\t// Save the layer geometries\r\n\tsave: function () {\r\n\t\tvar editedLayers = new L.LayerGroup();\r\n\t\tthis._featureGroup.eachLayer(function (layer) {\r\n\t\t\tif (layer.edited) {\r\n\t\t\t\teditedLayers.addLayer(layer);\r\n\t\t\t\tlayer.edited = false;\r\n\t\t\t}\r\n\t\t});\r\n\t\tthis._map.fire(L.Draw.Event.EDITED, {layers: editedLayers});\r\n\t},\r\n\r\n\t_backupLayer: function (layer) {\r\n\t\tvar id = L.Util.stamp(layer);\r\n\r\n\t\tif (!this._uneditedLayerProps[id]) {\r\n\t\t\t// Polyline, Polygon or Rectangle\r\n\t\t\tif (layer instanceof L.Polyline || layer instanceof L.Polygon || layer instanceof L.Rectangle) {\r\n\t\t\t\tthis._uneditedLayerProps[id] = {\r\n\t\t\t\t\tlatlngs: L.LatLngUtil.cloneLatLngs(layer.getLatLngs())\r\n\t\t\t\t};\r\n\t\t\t} else if (layer instanceof L.Circle) {\r\n\t\t\t\tthis._uneditedLayerProps[id] = {\r\n\t\t\t\t\tlatlng: L.LatLngUtil.cloneLatLng(layer.getLatLng()),\r\n\t\t\t\t\tradius: layer.getRadius()\r\n\t\t\t\t};\r\n\t\t\t} else if (layer instanceof L.Marker || layer instanceof L.CircleMarker) { // Marker\r\n\t\t\t\tthis._uneditedLayerProps[id] = {\r\n\t\t\t\t\tlatlng: L.LatLngUtil.cloneLatLng(layer.getLatLng())\r\n\t\t\t\t};\r\n\t\t\t}\r\n\t\t}\r\n\t},\r\n\r\n\t_getTooltipText: function () {\r\n\t\treturn ({\r\n\t\t\ttext: L.drawLocal.edit.handlers.edit.tooltip.text,\r\n\t\t\tsubtext: L.drawLocal.edit.handlers.edit.tooltip.subtext\r\n\t\t});\r\n\t},\r\n\r\n\t_updateTooltip: function () {\r\n\t\tthis._tooltip.updateContent(this._getTooltipText());\r\n\t},\r\n\r\n\t_revertLayer: function (layer) {\r\n\t\tvar id = L.Util.stamp(layer);\r\n\t\tlayer.edited = false;\r\n\t\tif (this._uneditedLayerProps.hasOwnProperty(id)) {\r\n\t\t\t// Polyline, Polygon or Rectangle\r\n\t\t\tif (layer instanceof L.Polyline || layer instanceof L.Polygon || layer instanceof L.Rectangle) {\r\n\t\t\t\tlayer.setLatLngs(this._uneditedLayerProps[id].latlngs);\r\n\t\t\t} else if (layer instanceof L.Circle) {\r\n\t\t\t\tlayer.setLatLng(this._uneditedLayerProps[id].latlng);\r\n\t\t\t\tlayer.setRadius(this._uneditedLayerProps[id].radius);\r\n\t\t\t} else if (layer instanceof L.Marker || layer instanceof L.CircleMarker) { // Marker or CircleMarker\r\n\t\t\t\tlayer.setLatLng(this._uneditedLayerProps[id].latlng);\r\n\t\t\t}\r\n\r\n\t\t\tlayer.fire('revert-edited', {layer: layer});\r\n\t\t}\r\n\t},\r\n\r\n\t_enableLayerEdit: function (e) {\r\n\t\tvar layer = e.layer || e.target || e,\r\n\t\t\tpathOptions, poly;\r\n\r\n\t\t// Back up this layer (if haven't before)\r\n\t\tthis._backupLayer(layer);\r\n\r\n\t\tif (this.options.poly) {\r\n\t\t\tpoly = L.Util.extend({}, this.options.poly);\r\n\t\t\tlayer.options.poly = poly;\r\n\t\t}\r\n\r\n\t\t// Set different style for editing mode\r\n\t\tif (this.options.selectedPathOptions) {\r\n\t\t\tpathOptions = L.Util.extend({}, this.options.selectedPathOptions);\r\n\r\n\t\t\t// Use the existing color of the layer\r\n\t\t\tif (pathOptions.maintainColor) {\r\n\t\t\t\tpathOptions.color = layer.options.color;\r\n\t\t\t\tpathOptions.fillColor = layer.options.fillColor;\r\n\t\t\t}\r\n\r\n\t\t\tlayer.options.original = L.extend({}, layer.options);\r\n\t\t\tlayer.options.editing = pathOptions;\r\n\r\n\t\t}\r\n\r\n\t\tif (layer instanceof L.Marker) {\r\n\t\t\tif (layer.editing) {\r\n\t\t\t\tlayer.editing.enable();\r\n\t\t\t}\r\n\t\t\tlayer.dragging.enable();\r\n\t\t\tlayer\r\n\t\t\t\t.on('dragend', this._onMarkerDragEnd)\r\n\t\t\t\t// #TODO: remove when leaflet finally fixes their draggable so it's touch friendly again.\r\n\t\t\t\t.on('touchmove', this._onTouchMove, this)\r\n\t\t\t\t.on('MSPointerMove', this._onTouchMove, this)\r\n\t\t\t\t.on('touchend', this._onMarkerDragEnd, this)\r\n\t\t\t\t.on('MSPointerUp', this._onMarkerDragEnd, this);\r\n\t\t} else {\r\n\t\t\tlayer.editing.enable();\r\n\t\t}\r\n\t},\r\n\r\n\t_disableLayerEdit: function (e) {\r\n\t\tvar layer = e.layer || e.target || e;\r\n\r\n\t\tlayer.edited = false;\r\n\t\tif (layer.editing) {\r\n\t\t\tlayer.editing.disable();\r\n\t\t}\r\n\r\n\t\tdelete layer.options.editing;\r\n\t\tdelete layer.options.original;\r\n\t\t// Reset layer styles to that of before select\r\n\t\tif (this._selectedPathOptions) {\r\n\t\t\tif (layer instanceof L.Marker) {\r\n\t\t\t\tthis._toggleMarkerHighlight(layer);\r\n\t\t\t} else {\r\n\t\t\t\t// reset the layer style to what is was before being selected\r\n\t\t\t\tlayer.setStyle(layer.options.previousOptions);\r\n\t\t\t\t// remove the cached options for the layer object\r\n\t\t\t\tdelete layer.options.previousOptions;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (layer instanceof L.Marker) {\r\n\t\t\tlayer.dragging.disable();\r\n\t\t\tlayer\r\n\t\t\t\t.off('dragend', this._onMarkerDragEnd, this)\r\n\t\t\t\t.off('touchmove', this._onTouchMove, this)\r\n\t\t\t\t.off('MSPointerMove', this._onTouchMove, this)\r\n\t\t\t\t.off('touchend', this._onMarkerDragEnd, this)\r\n\t\t\t\t.off('MSPointerUp', this._onMarkerDragEnd, this);\r\n\t\t} else {\r\n\t\t\tlayer.editing.disable();\r\n\t\t}\r\n\t},\r\n\r\n\t_onMouseMove: function (e) {\r\n\t\tthis._tooltip.updatePosition(e.latlng);\r\n\t},\r\n\r\n\t_onMarkerDragEnd: function (e) {\r\n\t\tvar layer = e.target;\r\n\t\tlayer.edited = true;\r\n\t\tthis._map.fire(L.Draw.Event.EDITMOVE, {layer: layer});\r\n\t},\r\n\r\n\t_onTouchMove: function (e) {\r\n\t\tvar touchEvent = e.originalEvent.changedTouches[0],\r\n\t\t\tlayerPoint = this._map.mouseEventToLayerPoint(touchEvent),\r\n\t\t\tlatlng = this._map.layerPointToLatLng(layerPoint);\r\n\t\te.target.setLatLng(latlng);\r\n\t},\r\n\r\n\t_hasAvailableLayers: function () {\r\n\t\treturn this._featureGroup.getLayers().length !== 0;\r\n\t}\r\n});\r\n","/**\r\n * @class L.EditToolbar.Delete\r\n * @aka EditToolbar.Delete\r\n */\r\nL.EditToolbar.Delete = L.Handler.extend({\r\n\tstatics: {\r\n\t\tTYPE: 'remove' // not delete as delete is reserved in js\r\n\t},\r\n\r\n\t// @method intialize(): void\r\n\tinitialize: function (map, options) {\r\n\t\tL.Handler.prototype.initialize.call(this, map);\r\n\r\n\t\tL.Util.setOptions(this, options);\r\n\r\n\t\t// Store the selectable layer group for ease of access\r\n\t\tthis._deletableLayers = this.options.featureGroup;\r\n\r\n\t\tif (!(this._deletableLayers instanceof L.FeatureGroup)) {\r\n\t\t\tthrow new Error('options.featureGroup must be a L.FeatureGroup');\r\n\t\t}\r\n\r\n\t\t// Save the type so super can fire, need to do this as cannot do this.TYPE :(\r\n\t\tthis.type = L.EditToolbar.Delete.TYPE;\r\n\r\n\t\tvar version = L.version.split('.');\r\n\t\t//If Version is >= 1.2.0\r\n\t\tif (parseInt(version[0], 10) === 1 && parseInt(version[1], 10) >= 2) {\r\n\t\t\tL.EditToolbar.Delete.include(L.Evented.prototype);\r\n\t\t} else {\r\n\t\t\tL.EditToolbar.Delete.include(L.Mixin.Events);\r\n\t\t}\r\n\r\n\t},\r\n\r\n\t// @method enable(): void\r\n\t// Enable the delete toolbar\r\n\tenable: function () {\r\n\t\tif (this._enabled || !this._hasAvailableLayers()) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tthis.fire('enabled', {handler: this.type});\r\n\r\n\t\tthis._map.fire(L.Draw.Event.DELETESTART, {handler: this.type});\r\n\r\n\t\tL.Handler.prototype.enable.call(this);\r\n\r\n\t\tthis._deletableLayers\r\n\t\t\t.on('layeradd', this._enableLayerDelete, this)\r\n\t\t\t.on('layerremove', this._disableLayerDelete, this);\r\n\t},\r\n\r\n\t// @method disable(): void\r\n\t// Disable the delete toolbar\r\n\tdisable: function () {\r\n\t\tif (!this._enabled) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tthis._deletableLayers\r\n\t\t\t.off('layeradd', this._enableLayerDelete, this)\r\n\t\t\t.off('layerremove', this._disableLayerDelete, this);\r\n\r\n\t\tL.Handler.prototype.disable.call(this);\r\n\r\n\t\tthis._map.fire(L.Draw.Event.DELETESTOP, {handler: this.type});\r\n\r\n\t\tthis.fire('disabled', {handler: this.type});\r\n\t},\r\n\r\n\t// @method addHooks(): void\r\n\t// Add listener hooks to this handler\r\n\taddHooks: function () {\r\n\t\tvar map = this._map;\r\n\r\n\t\tif (map) {\r\n\t\t\tmap.getContainer().focus();\r\n\r\n\t\t\tthis._deletableLayers.eachLayer(this._enableLayerDelete, this);\r\n\t\t\tthis._deletedLayers = new L.LayerGroup();\r\n\r\n\t\t\tthis._tooltip = new L.Draw.Tooltip(this._map);\r\n\t\t\tthis._tooltip.updateContent({text: L.drawLocal.edit.handlers.remove.tooltip.text});\r\n\r\n\t\t\tthis._map.on('mousemove', this._onMouseMove, this);\r\n\t\t}\r\n\t},\r\n\r\n\t// @method removeHooks(): void\r\n\t// Remove listener hooks from this handler\r\n\tremoveHooks: function () {\r\n\t\tif (this._map) {\r\n\t\t\tthis._deletableLayers.eachLayer(this._disableLayerDelete, this);\r\n\t\t\tthis._deletedLayers = null;\r\n\r\n\t\t\tthis._tooltip.dispose();\r\n\t\t\tthis._tooltip = null;\r\n\r\n\t\t\tthis._map.off('mousemove', this._onMouseMove, this);\r\n\t\t}\r\n\t},\r\n\r\n\t// @method revertLayers(): void\r\n\t// Revert the deleted layers back to their prior state.\r\n\trevertLayers: function () {\r\n\t\t// Iterate of the deleted layers and add them back into the featureGroup\r\n\t\tthis._deletedLayers.eachLayer(function (layer) {\r\n\t\t\tthis._deletableLayers.addLayer(layer);\r\n\t\t\tlayer.fire('revert-deleted', {layer: layer});\r\n\t\t}, this);\r\n\t},\r\n\r\n\t// @method save(): void\r\n\t// Save deleted layers\r\n\tsave: function () {\r\n\t\tthis._map.fire(L.Draw.Event.DELETED, {layers: this._deletedLayers});\r\n\t},\r\n\r\n\t// @method removeAllLayers(): void\r\n\t// Remove all delateable layers\r\n\tremoveAllLayers: function () {\r\n\t\t// Iterate of the delateable layers and add remove them\r\n\t\tthis._deletableLayers.eachLayer(function (layer) {\r\n\t\t\tthis._removeLayer({layer: layer});\r\n\t\t}, this);\r\n\t\tthis.save();\r\n\t},\r\n\r\n\t_enableLayerDelete: function (e) {\r\n\t\tvar layer = e.layer || e.target || e;\r\n\r\n\t\tlayer.on('click', this._removeLayer, this);\r\n\t},\r\n\r\n\t_disableLayerDelete: function (e) {\r\n\t\tvar layer = e.layer || e.target || e;\r\n\r\n\t\tlayer.off('click', this._removeLayer, this);\r\n\r\n\t\t// Remove from the deleted layers so we can't accidentally revert if the user presses cancel\r\n\t\tthis._deletedLayers.removeLayer(layer);\r\n\t},\r\n\r\n\t_removeLayer: function (e) {\r\n\t\tvar layer = e.layer || e.target || e;\r\n\r\n\t\tthis._deletableLayers.removeLayer(layer);\r\n\r\n\t\tthis._deletedLayers.addLayer(layer);\r\n\r\n\t\tlayer.fire('deleted');\r\n\t},\r\n\r\n\t_onMouseMove: function (e) {\r\n\t\tthis._tooltip.updatePosition(e.latlng);\r\n\t},\r\n\r\n\t_hasAvailableLayers: function () {\r\n\t\treturn this._deletableLayers.getLayers().length !== 0;\r\n\t}\r\n});\r\n"]} \ No newline at end of file diff --git a/dist/leaflet.draw.js b/dist/leaflet.draw.js index 39bc85e73..74456640a 100644 --- a/dist/leaflet.draw.js +++ b/dist/leaflet.draw.js @@ -1,10 +1,10 @@ /* - Leaflet.draw 1.0.3+638b962, a plugin that adds drawing and editing tools to Leaflet powered maps. + Leaflet.draw 1.0.3+2538bd9, a plugin that adds drawing and editing tools to Leaflet powered maps. (c) 2012-2017, Jacob Toye, Jon West, Smartrak, Leaflet https://github.com/Leaflet/Leaflet.draw http://leafletjs.com */ -!function(t,e,i){function o(t,e){for(;(t=t.parentElement)&&!t.classList.contains(e););return t}L.drawVersion="1.0.3+638b962",L.Draw={},L.drawLocal={draw:{toolbar:{actions:{title:"Cancel drawing",text:"Cancel"},finish:{title:"Finish drawing",text:"Finish"},undo:{title:"Delete last point drawn",text:"Delete last point"},buttons:{polyline:"Draw a polyline",polygon:"Draw a polygon",rectangle:"Draw a rectangle",circle:"Draw a circle",marker:"Draw a marker",circlemarker:"Draw a circlemarker"}},handlers:{circle:{tooltip:{start:"Click and drag to draw circle."},radius:"Radius"},circlemarker:{tooltip:{start:"Click map to place circle marker."}},marker:{tooltip:{start:"Click map to place marker."}},polygon:{tooltip:{start:"Click to start drawing shape.",cont:"Click to continue drawing shape.",end:"Click first point to close this shape."}},polyline:{error:"Error: shape edges cannot cross!",tooltip:{start:"Click to start drawing line.",cont:"Click to continue drawing line.",end:"Click last point to finish line."}},rectangle:{tooltip:{start:"Click and drag to draw rectangle."}},simpleshape:{tooltip:{end:"Release mouse to finish drawing."}}}},edit:{toolbar:{actions:{save:{title:"Save changes",text:"Save"},cancel:{title:"Cancel editing, discards all changes",text:"Cancel"},clearAll:{title:"Clear all layers",text:"Clear All"}},buttons:{edit:"Edit layers",editDisabled:"No layers to edit",remove:"Delete layers",removeDisabled:"No layers to delete"}},handlers:{edit:{tooltip:{text:"Drag handles or markers to edit features.",subtext:"Click cancel to undo changes."}},remove:{tooltip:{text:"Click on a feature to remove."}}}}},L.Draw.Event={},L.Draw.Event.CREATED="draw:created",L.Draw.Event.EDITED="draw:edited",L.Draw.Event.DELETED="draw:deleted",L.Draw.Event.DRAWSTART="draw:drawstart",L.Draw.Event.DRAWSTOP="draw:drawstop",L.Draw.Event.DRAWVERTEX="draw:drawvertex",L.Draw.Event.EDITSTART="draw:editstart",L.Draw.Event.EDITMOVE="draw:editmove",L.Draw.Event.EDITRESIZE="draw:editresize",L.Draw.Event.EDITVERTEX="draw:editvertex",L.Draw.Event.EDITSTOP="draw:editstop",L.Draw.Event.DELETESTART="draw:deletestart",L.Draw.Event.DELETESTOP="draw:deletestop",L.Draw.Event.TOOLBAROPENED="draw:toolbaropened",L.Draw.Event.TOOLBARCLOSED="draw:toolbarclosed",L.Draw.Event.MARKERCONTEXT="draw:markercontext",L.Draw=L.Draw||{},L.Draw.Feature=L.Handler.extend({initialize:function(t,e){this._map=t,this._container=t._container,this._overlayPane=t._panes.overlayPane,this._popupPane=t._panes.popupPane,e&&e.shapeOptions&&(e.shapeOptions=L.Util.extend({},this.options.shapeOptions,e.shapeOptions)),L.setOptions(this,e);var i=L.version.split(".");1===parseInt(i[0],10)&&parseInt(i[1],10)>=2?L.Draw.Feature.include(L.Evented.prototype):L.Draw.Feature.include(L.Mixin.Events)},enable:function(){this._enabled||(L.Handler.prototype.enable.call(this),this.fire("enabled",{handler:this.type}),this._map.fire(L.Draw.Event.DRAWSTART,{layerType:this.type}))},disable:function(){this._enabled&&(L.Handler.prototype.disable.call(this),this._map.fire(L.Draw.Event.DRAWSTOP,{layerType:this.type}),this.fire("disabled",{handler:this.type}))},addHooks:function(){var t=this._map;t&&(L.DomUtil.disableTextSelection(),t.getContainer().focus(),this._tooltip=new L.Draw.Tooltip(this._map),L.DomEvent.on(this._container,"keyup",this._cancelDrawing,this))},removeHooks:function(){this._map&&(L.DomUtil.enableTextSelection(),this._tooltip.dispose(),this._tooltip=null,L.DomEvent.off(this._container,"keyup",this._cancelDrawing,this))},setOptions:function(t){L.setOptions(this,t)},_fireCreatedEvent:function(t){this._map.fire(L.Draw.Event.CREATED,{layer:t,layerType:this.type})},_cancelDrawing:function(t){27===t.keyCode&&(this._map.fire("draw:canceled",{layerType:this.type}),this.disable())}}),L.Draw.Polyline=L.Draw.Feature.extend({statics:{TYPE:"polyline"},Poly:L.Polyline,options:{allowIntersection:!0,repeatMode:!1,drawError:{color:"#b00b00",timeout:2500},icon:new L.DivIcon({iconSize:new L.Point(8,8),className:"leaflet-div-icon leaflet-editing-icon"}),touchIcon:new L.DivIcon({iconSize:new L.Point(20,20),className:"leaflet-div-icon leaflet-editing-icon leaflet-touch-icon"}),guidelineDistance:20,maxGuideLineLength:4e3,shapeOptions:{stroke:!0,color:"#3388ff",weight:4,opacity:.5,fill:!1,clickable:!0},metric:!0,feet:!0,nautic:!1,showLength:!0,zIndexOffset:2e3,factor:1,maxPoints:0},initialize:function(t,e){L.Browser.touch&&(this.options.icon=this.options.touchIcon),this.options.drawError.message=L.drawLocal.draw.handlers.polyline.error,e&&e.drawError&&(e.drawError=L.Util.extend({},this.options.drawError,e.drawError)),this.type=L.Draw.Polyline.TYPE,L.Draw.Feature.prototype.initialize.call(this,t,e)},addHooks:function(){L.Draw.Feature.prototype.addHooks.call(this),this._map&&(this._markers=[],this._markerGroup=new L.LayerGroup,this._map.addLayer(this._markerGroup),this._poly=new L.Polyline([],this.options.shapeOptions),this._tooltip.updateContent(this._getTooltipText()),this._mouseMarker||(this._mouseMarker=L.marker(this._map.getCenter(),{icon:L.divIcon({className:"leaflet-mouse-marker",iconAnchor:[20,20],iconSize:[40,40]}),opacity:0,zIndexOffset:this.options.zIndexOffset})),this._mouseMarker.on("mouseout",this._onMouseOut,this).on("mousemove",this._onMouseMove,this).on("mousedown",this._onMouseDown,this).on("mouseup",this._onMouseUp,this).addTo(this._map),this._map.on("mouseup",this._onMouseUp,this).on("mousemove",this._onMouseMove,this).on("zoomlevelschange",this._onZoomEnd,this).on("touchstart",this._onTouch,this).on("zoomend",this._onZoomEnd,this))},removeHooks:function(){L.Draw.Feature.prototype.removeHooks.call(this),this._clearHideErrorTimeout(),this._cleanUpShape(),this._map.removeLayer(this._markerGroup),delete this._markerGroup,delete this._markers,this._map.removeLayer(this._poly),delete this._poly,this._mouseMarker.off("mousedown",this._onMouseDown,this).off("mouseout",this._onMouseOut,this).off("mouseup",this._onMouseUp,this).off("mousemove",this._onMouseMove,this),this._map.removeLayer(this._mouseMarker),delete this._mouseMarker,this._clearGuides(),this._map.off("mouseup",this._onMouseUp,this).off("mousemove",this._onMouseMove,this).off("zoomlevelschange",this._onZoomEnd,this).off("zoomend",this._onZoomEnd,this).off("touchstart",this._onTouch,this).off("click",this._onTouch,this)},deleteLastVertex:function(){if(!(this._markers.length<=1)){var t=this._markers.pop(),e=this._poly,i=e.getLatLngs(),o=i.splice(-1,1)[0];this._poly.setLatLngs(i),this._markerGroup.removeLayer(t),e.getLatLngs().length<2&&this._map.removeLayer(e),this._vertexChanged(o,!1)}},addVertex:function(t){if(this._markers.length>=2&&!this.options.allowIntersection&&this._poly.newLatLngIntersects(t))return void this._showErrorTooltip();this._errorShown&&this._hideErrorTooltip(),this._markers.push(this._createMarker(t)),this._poly.addLatLng(t),2===this._poly.getLatLngs().length&&this._map.addLayer(this._poly),this._vertexChanged(t,!0)},completeShape:function(){this._markers.length<=1||!this._shapeIsValid()||(this._fireCreatedEvent(),this.disable(),this.options.repeatMode&&this.enable())},_finishShape:function(){var t=this._poly._defaultShape?this._poly._defaultShape():this._poly.getLatLngs(),e=this._poly.newLatLngIntersects(t[t.length-1]);if(!this.options.allowIntersection&&e||!this._shapeIsValid())return void this._showErrorTooltip();this._fireCreatedEvent(),this.disable(),this.options.repeatMode&&this.enable()},_shapeIsValid:function(){return!0},_onZoomEnd:function(){null!==this._markers&&this._updateGuide()},_onMouseMove:function(t){var e=this._map.mouseEventToLayerPoint(t.originalEvent),i=this._map.layerPointToLatLng(e);this._currentLatLng=i,this._updateTooltip(i),this._updateGuide(e),this._mouseMarker.setLatLng(i),L.DomEvent.preventDefault(t.originalEvent)},_vertexChanged:function(t,e){this._map.fire(L.Draw.Event.DRAWVERTEX,{layers:this._markerGroup}),this._updateFinishHandler(),this._updateRunningMeasure(t,e),this._clearGuides(),this._updateTooltip()},_onMouseDown:function(t){if(!this._clickHandled&&!this._touchHandled&&!this._disableMarkers){this._onMouseMove(t),this._clickHandled=!0,this._disableNewMarkers();var e=t.originalEvent,i=e.clientX,o=e.clientY;this._startPoint.call(this,i,o)}},_startPoint:function(t,e){this._mouseDownOrigin=L.point(t,e)},_onMouseUp:function(t){var e=t.originalEvent,i=e.clientX,o=e.clientY;this._endPoint.call(this,i,o,t),this._clickHandled=null},_endPoint:function(e,i,o){if(this._mouseDownOrigin){var a=L.point(e,i).distanceTo(this._mouseDownOrigin),n=this._calculateFinishDistance(o.latlng);this.options.maxPoints>1&&this.options.maxPoints==this._markers.length+1?(this.addVertex(o.latlng),this._finishShape()):n<10&&L.Browser.touch?this._finishShape():Math.abs(a)<9*(t.devicePixelRatio||1)&&this.addVertex(o.latlng),this._enableNewMarkers()}this._mouseDownOrigin=null},_onTouch:function(t){var e,i,o=t.originalEvent;!o.touches||!o.touches[0]||this._clickHandled||this._touchHandled||this._disableMarkers||(e=o.touches[0].clientX,i=o.touches[0].clientY,this._disableNewMarkers(),this._touchHandled=!0,this._startPoint.call(this,e,i),this._endPoint.call(this,e,i,t),this._touchHandled=null),this._clickHandled=null},_onMouseOut:function(){this._tooltip&&this._tooltip._onMouseOut.call(this._tooltip)},_calculateFinishDistance:function(t){var e;if(this._markers.length>0){var i;if(this.type===L.Draw.Polyline.TYPE)i=this._markers[this._markers.length-1];else{if(this.type!==L.Draw.Polygon.TYPE)return 1/0;i=this._markers[0]}var o=this._map.latLngToContainerPoint(i.getLatLng()),a=new L.Marker(t,{icon:this.options.icon,zIndexOffset:2*this.options.zIndexOffset}),n=this._map.latLngToContainerPoint(a.getLatLng());e=o.distanceTo(n)}else e=1/0;return e},_updateFinishHandler:function(){var t=this._markers.length;t>1&&this._markers[t-1].on("click",this._finishShape,this),t>2&&this._markers[t-2].off("click",this._finishShape,this)},_createMarker:function(t){var e=new L.Marker(t,{icon:this.options.icon,zIndexOffset:2*this.options.zIndexOffset});return this._markerGroup.addLayer(e),e},_updateGuide:function(t){var e=this._markers?this._markers.length:0;e>0&&(t=t||this._map.latLngToLayerPoint(this._currentLatLng),this._clearGuides(),this._drawGuide(this._map.latLngToLayerPoint(this._markers[e-1].getLatLng()),t))},_updateTooltip:function(t){var e=this._getTooltipText();t&&this._tooltip.updatePosition(t),this._errorShown||this._tooltip.updateContent(e)},_drawGuide:function(t,e){var i,o,a,n=Math.floor(Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))),s=this.options.guidelineDistance,r=this.options.maxGuideLineLength,l=n>r?n-r:s;for(this._guidesContainer||(this._guidesContainer=L.DomUtil.create("div","leaflet-draw-guides",this._overlayPane));l1&&this._markers[this._markers.length-1].off("click",this._finishShape,this)},_fireCreatedEvent:function(){var t=new this.Poly(this._poly.getLatLngs(),this.options.shapeOptions);L.Draw.Feature.prototype._fireCreatedEvent.call(this,t)}}),L.Draw.Polygon=L.Draw.Polyline.extend({statics:{TYPE:"polygon"},Poly:L.Polygon,options:{showArea:!1,showLength:!1,shapeOptions:{stroke:!0,color:"#3388ff",weight:4,opacity:.5,fill:!0,fillColor:null,fillOpacity:.2,clickable:!0},metric:!0,feet:!0,nautic:!1,precision:{}},initialize:function(t,e){L.Draw.Polyline.prototype.initialize.call(this,t,e),this.type=L.Draw.Polygon.TYPE},_updateFinishHandler:function(){var t=this._markers.length;1===t&&this._markers[0].on("click",this._finishShape,this),t>2&&(this._markers[t-1].on("dblclick",this._finishShape,this),t>3&&this._markers[t-2].off("dblclick",this._finishShape,this))},_getTooltipText:function(){var t,e;return 0===this._markers.length?t=L.drawLocal.draw.handlers.polygon.tooltip.start:this._markers.length<3?(t=L.drawLocal.draw.handlers.polygon.tooltip.cont,e=this._getMeasurementString()):(t=L.drawLocal.draw.handlers.polygon.tooltip.end,e=this._getMeasurementString()),{text:t,subtext:e}},_getMeasurementString:function(){var t=this._area,e="";return t||this.options.showLength?(this.options.showLength&&(e=L.Draw.Polyline.prototype._getMeasurementString.call(this)),t&&(e+="
"+L.GeometryUtil.readableArea(t,this.options.metric,this.options.precision)),e):null},_shapeIsValid:function(){return this._markers.length>=3},_vertexChanged:function(t,e){var i;!this.options.allowIntersection&&this.options.showArea&&(i=this._poly.getLatLngs(),this._area=L.GeometryUtil.geodesicArea(i)),L.Draw.Polyline.prototype._vertexChanged.call(this,t,e)},_cleanUpShape:function(){var t=this._markers.length;t>0&&(this._markers[0].off("click",this._finishShape,this),t>2&&this._markers[t-1].off("dblclick",this._finishShape,this))}}),L.SimpleShape={},L.Draw.SimpleShape=L.Draw.Feature.extend({options:{repeatMode:!1},initialize:function(t,e){this._endLabelText=L.drawLocal.draw.handlers.simpleshape.tooltip.end,L.Draw.Feature.prototype.initialize.call(this,t,e)},addHooks:function(){L.Draw.Feature.prototype.addHooks.call(this),this._map&&(this._mapDraggable=this._map.dragging.enabled(),this._mapDraggable&&this._map.dragging.disable(),this._container.style.cursor="crosshair",this._tooltip.updateContent({text:this._initialLabelText}),this._map.on("mousedown",this._onMouseDown,this).on("mousemove",this._onMouseMove,this).on("touchstart",this._onMouseDown,this).on("touchmove",this._onMouseMove,this),e.addEventListener("touchstart",L.DomEvent.preventDefault,{passive:!1}))},removeHooks:function(){L.Draw.Feature.prototype.removeHooks.call(this),this._map&&(this._mapDraggable&&this._map.dragging.enable(),this._container.style.cursor="",this._map.off("mousedown",this._onMouseDown,this).off("mousemove",this._onMouseMove,this).off("touchstart",this._onMouseDown,this).off("touchmove",this._onMouseMove,this),L.DomEvent.off(e,"mouseup",this._onMouseUp,this),L.DomEvent.off(e,"touchend",this._onMouseUp,this),e.removeEventListener("touchstart",L.DomEvent.preventDefault),this._shape&&(this._map.removeLayer(this._shape),delete this._shape)),this._isDrawing=!1},_getTooltipText:function(){return{text:this._endLabelText}},_onMouseDown:function(t){this._isDrawing=!0,this._startLatLng=t.latlng,L.DomEvent.on(e,"mouseup",this._onMouseUp,this).on(e,"touchend",this._onMouseUp,this).preventDefault(t.originalEvent)},_onMouseMove:function(t){var e=t.latlng;this._tooltip.updatePosition(e),this._isDrawing&&(this._tooltip.updateContent(this._getTooltipText()),this._drawShape(e))},_onMouseUp:function(){this._shape&&this._fireCreatedEvent(),this.disable(),this.options.repeatMode&&this.enable()}}),L.Draw.Rectangle=L.Draw.SimpleShape.extend({statics:{TYPE:"rectangle"},options:{shapeOptions:{stroke:!0,color:"#3388ff",weight:4,opacity:.5,fill:!0,fillColor:null,fillOpacity:.2,clickable:!0},showArea:!0,metric:!0},initialize:function(t,e){this.type=L.Draw.Rectangle.TYPE,this._initialLabelText=L.drawLocal.draw.handlers.rectangle.tooltip.start,L.Draw.SimpleShape.prototype.initialize.call(this,t,e)},disable:function(){this._enabled&&(this._isCurrentlyTwoClickDrawing=!1,L.Draw.SimpleShape.prototype.disable.call(this))},_onMouseUp:function(t){if(!this._shape&&!this._isCurrentlyTwoClickDrawing)return void(this._isCurrentlyTwoClickDrawing=!0);this._isCurrentlyTwoClickDrawing&&!o(t.target,"leaflet-pane")||L.Draw.SimpleShape.prototype._onMouseUp.call(this)},_drawShape:function(t){this._shape?this._shape.setBounds(new L.LatLngBounds(this._startLatLng,t)):(this._shape=new L.Rectangle(new L.LatLngBounds(this._startLatLng,t),this.options.shapeOptions),this._map.addLayer(this._shape))},_fireCreatedEvent:function(){var t=new L.Rectangle(this._shape.getBounds(),this.options.shapeOptions);L.Draw.SimpleShape.prototype._fireCreatedEvent.call(this,t)},_getTooltipText:function(){var t,e,i,o=L.Draw.SimpleShape.prototype._getTooltipText.call(this),a=this._shape,n=this.options.showArea;return a&&(t=this._shape._defaultShape?this._shape._defaultShape():this._shape.getLatLngs(),e=L.GeometryUtil.geodesicArea(t),i=n?L.GeometryUtil.readableArea(e,this.options.metric):""),{text:o.text,subtext:i}}}),L.Draw.Marker=L.Draw.Feature.extend({statics:{TYPE:"marker"},options:{icon:new L.Icon.Default,repeatMode:!1,zIndexOffset:2e3},initialize:function(t,e){this.type=L.Draw.Marker.TYPE,this._initialLabelText=L.drawLocal.draw.handlers.marker.tooltip.start,L.Draw.Feature.prototype.initialize.call(this,t,e)},addHooks:function(){L.Draw.Feature.prototype.addHooks.call(this),this._map&&(this._tooltip.updateContent({text:this._initialLabelText}),this._mouseMarker||(this._mouseMarker=L.marker(this._map.getCenter(),{icon:L.divIcon({className:"leaflet-mouse-marker",iconAnchor:[20,20],iconSize:[40,40]}),opacity:0,zIndexOffset:this.options.zIndexOffset})),this._mouseMarker.on("click",this._onClick,this).addTo(this._map),this._map.on("mousemove",this._onMouseMove,this),this._map.on("click",this._onTouch,this))},removeHooks:function(){L.Draw.Feature.prototype.removeHooks.call(this),this._map&&(this._map.off("click",this._onClick,this).off("click",this._onTouch,this),this._marker&&(this._marker.off("click",this._onClick,this),this._map.removeLayer(this._marker),delete this._marker),this._mouseMarker.off("click",this._onClick,this),this._map.removeLayer(this._mouseMarker),delete this._mouseMarker,this._map.off("mousemove",this._onMouseMove,this))},_onMouseMove:function(t){var e=t.latlng;this._tooltip.updatePosition(e),this._mouseMarker.setLatLng(e),this._marker?(e=this._mouseMarker.getLatLng(),this._marker.setLatLng(e)):(this._marker=this._createMarker(e),this._marker.on("click",this._onClick,this),this._map.on("click",this._onClick,this).addLayer(this._marker))},_createMarker:function(t){return new L.Marker(t,{icon:this.options.icon,zIndexOffset:this.options.zIndexOffset})},_onClick:function(){this._fireCreatedEvent(),this.disable(),this.options.repeatMode&&this.enable()},_onTouch:function(t){this._onMouseMove(t),this._onClick()},_fireCreatedEvent:function(){var t=new L.Marker.Touch(this._marker.getLatLng(),{icon:this.options.icon});L.Draw.Feature.prototype._fireCreatedEvent.call(this,t)}}),L.Draw.CircleMarker=L.Draw.Marker.extend({statics:{TYPE:"circlemarker"},options:{stroke:!0,color:"#3388ff",weight:4,opacity:.5,fill:!0,fillColor:null,fillOpacity:.2,clickable:!0,zIndexOffset:2e3},initialize:function(t,e){this.type=L.Draw.CircleMarker.TYPE,this._initialLabelText=L.drawLocal.draw.handlers.circlemarker.tooltip.start,L.Draw.Feature.prototype.initialize.call(this,t,e)},_fireCreatedEvent:function(){var t=new L.CircleMarker(this._marker.getLatLng(),this.options);L.Draw.Feature.prototype._fireCreatedEvent.call(this,t)},_createMarker:function(t){return new L.CircleMarker(t,this.options)}}),L.Draw.Circle=L.Draw.SimpleShape.extend({statics:{TYPE:"circle"},options:{shapeOptions:{stroke:!0,color:"#3388ff",weight:4,opacity:.5,fill:!0,fillColor:null,fillOpacity:.2,clickable:!0},showRadius:!0,metric:!0,feet:!0,nautic:!1},initialize:function(t,e){this.type=L.Draw.Circle.TYPE,this._initialLabelText=L.drawLocal.draw.handlers.circle.tooltip.start,L.Draw.SimpleShape.prototype.initialize.call(this,t,e)},_drawShape:function(t){if(L.GeometryUtil.isVersion07x())var e=this._startLatLng.distanceTo(t);else var e=this._map.distance(this._startLatLng,t);this._shape?this._shape.setRadius(e):(this._shape=new L.Circle(this._startLatLng,e,this.options.shapeOptions),this._map.addLayer(this._shape))},_fireCreatedEvent:function(){var t=new L.Circle(this._startLatLng,this._shape.getRadius(),this.options.shapeOptions);L.Draw.SimpleShape.prototype._fireCreatedEvent.call(this,t)},_onMouseMove:function(t){var e,i=t.latlng,o=this.options.showRadius,a=this.options.metric;if(this._tooltip.updatePosition(i),this._isDrawing){this._drawShape(i),e=this._shape.getRadius().toFixed(1);var n="";o&&(n=L.drawLocal.draw.handlers.circle.radius+": "+L.GeometryUtil.readableDistance(e,a,this.options.feet,this.options.nautic)),this._tooltip.updateContent({text:this._endLabelText,subtext:n})}}}),L.Edit=L.Edit||{},L.Edit.Marker=L.Handler.extend({initialize:function(t,e){this._marker=t,L.setOptions(this,e)},addHooks:function(){var t=this._marker;t.dragging.enable(),t.on("dragend",this._onDragEnd,t),this._toggleMarkerHighlight()},removeHooks:function(){var t=this._marker;t.dragging.disable(),t.off("dragend",this._onDragEnd,t),this._toggleMarkerHighlight()},_onDragEnd:function(t){var e=t.target;e.edited=!0,this._map.fire(L.Draw.Event.EDITMOVE,{layer:e})},_toggleMarkerHighlight:function(){var t=this._marker._icon;t&&(t.style.display="none",L.DomUtil.hasClass(t,"leaflet-edit-marker-selected")?(L.DomUtil.removeClass(t,"leaflet-edit-marker-selected"),this._offsetMarker(t,-4)):(L.DomUtil.addClass(t,"leaflet-edit-marker-selected"),this._offsetMarker(t,4)),t.style.display="")},_offsetMarker:function(t,e){var i=parseInt(t.style.marginTop,10)-e,o=parseInt(t.style.marginLeft,10)-e;t.style.marginTop=i+"px",t.style.marginLeft=o+"px"}}),L.Marker.addInitHook(function(){L.Edit.Marker&&(this.editing=new L.Edit.Marker(this),this.options.editable&&this.editing.enable())}),L.Edit=L.Edit||{},L.Edit.Poly=L.Handler.extend({initialize:function(t){this.latlngs=[t._latlngs],t._holes&&(this.latlngs=this.latlngs.concat(t._holes)),this._poly=t,this._poly.on("revert-edited",this._updateLatLngs,this)},_defaultShape:function(){return L.Polyline._flat?L.Polyline._flat(this._poly._latlngs)?this._poly._latlngs:this._poly._latlngs[0]:this._poly._latlngs},_eachVertexHandler:function(t){for(var e=0;et&&(i._index+=e)})},_createMiddleMarker:function(t,e){var i,o,a,n=this._getMiddleLatLng(t,e),s=this._createMarker(n);s.setOpacity(.6),t._middleRight=e._middleLeft=s,o=function(){s.off("touchmove",o,this);var a=e._index;s._index=a,s.off("click",i,this).on("click",this._onMarkerClick,this),n.lat=s.getLatLng().lat,n.lng=s.getLatLng().lng,this._spliceLatLngs(a,0,n),this._markers.splice(a,0,s),s.setOpacity(1),this._updateIndexes(a,1),e._index++,this._updatePrevNext(t,s),this._updatePrevNext(s,e),this._poly.fire("editstart")},a=function(){s.off("dragstart",o,this),s.off("dragend",a,this),s.off("touchmove",o,this),this._createMiddleMarker(t,s),this._createMiddleMarker(s,e)},i=function(){o.call(this),a.call(this),this._fireEdit()},s.on("click",i,this).on("dragstart",o,this).on("dragend",a,this).on("touchmove",o,this),this._markerGroup.addLayer(s)},_updatePrevNext:function(t,e){t&&(t._next=e),e&&(e._prev=t)},_getMiddleLatLng:function(t,e){var i=this._poly._map,o=i.project(t.getLatLng()),a=i.project(e.getLatLng());return i.unproject(o._add(a)._divideBy(2))}}),L.Polyline.addInitHook(function(){this.editing||(L.Edit.Poly&&(this.editing=new L.Edit.Poly(this),this.options.editable&&this.editing.enable()),this.on("add",function(){this.editing&&this.editing.enabled()&&this.editing.addHooks()}),this.on("remove",function(){this.editing&&this.editing.enabled()&&this.editing.removeHooks()}))}),L.Edit=L.Edit||{},L.Edit.SimpleShape=L.Handler.extend({options:{moveIcon:new L.DivIcon({iconSize:new L.Point(8,8),className:"leaflet-div-icon leaflet-editing-icon leaflet-edit-move"}),resizeIcon:new L.DivIcon({iconSize:new L.Point(8,8), +!function(t,e,i){function o(t,e){for(;(t=t.parentElement)&&!t.classList.contains(e););return t}L.drawVersion="1.0.3+2538bd9",L.Draw={},L.drawLocal={draw:{toolbar:{actions:{title:"Cancel drawing",text:"Cancel"},finish:{title:"Finish drawing",text:"Finish"},undo:{title:"Delete last point drawn",text:"Delete last point"},buttons:{polyline:"Draw a polyline",polygon:"Draw a polygon",rectangle:"Draw a rectangle",circle:"Draw a circle",marker:"Draw a marker",circlemarker:"Draw a circlemarker"}},handlers:{circle:{tooltip:{start:"Click and drag to draw circle."},radius:"Radius"},circlemarker:{tooltip:{start:"Click map to place circle marker."}},marker:{tooltip:{start:"Click map to place marker."}},polygon:{tooltip:{start:"Click to start drawing shape.",cont:"Click to continue drawing shape.",end:"Click first point to close this shape."}},polyline:{error:"Error: shape edges cannot cross!",tooltip:{start:"Click to start drawing line.",cont:"Click to continue drawing line.",end:"Click last point to finish line."}},rectangle:{tooltip:{start:"Click and drag to draw rectangle."}},simpleshape:{tooltip:{end:"Release mouse to finish drawing."}}}},edit:{toolbar:{actions:{save:{title:"Save changes",text:"Save"},cancel:{title:"Cancel editing, discards all changes",text:"Cancel"},clearAll:{title:"Clear all layers",text:"Clear All"}},buttons:{edit:"Edit layers",editDisabled:"No layers to edit",remove:"Delete layers",removeDisabled:"No layers to delete"}},handlers:{edit:{tooltip:{text:"Drag handles or markers to edit features.",subtext:"Click cancel to undo changes."}},remove:{tooltip:{text:"Click on a feature to remove."}}}}},L.Draw.Event={},L.Draw.Event.CREATED="draw:created",L.Draw.Event.EDITED="draw:edited",L.Draw.Event.DELETED="draw:deleted",L.Draw.Event.DRAWSTART="draw:drawstart",L.Draw.Event.DRAWSTOP="draw:drawstop",L.Draw.Event.DRAWVERTEX="draw:drawvertex",L.Draw.Event.EDITSTART="draw:editstart",L.Draw.Event.EDITMOVE="draw:editmove",L.Draw.Event.EDITRESIZE="draw:editresize",L.Draw.Event.EDITVERTEX="draw:editvertex",L.Draw.Event.EDITSTOP="draw:editstop",L.Draw.Event.DELETESTART="draw:deletestart",L.Draw.Event.DELETESTOP="draw:deletestop",L.Draw.Event.TOOLBAROPENED="draw:toolbaropened",L.Draw.Event.TOOLBARCLOSED="draw:toolbarclosed",L.Draw.Event.MARKERCONTEXT="draw:markercontext",L.Draw=L.Draw||{},L.Draw.Feature=L.Handler.extend({initialize:function(t,e){this._map=t,this._container=t._container,this._overlayPane=t._panes.overlayPane,this._popupPane=t._panes.popupPane,e&&e.shapeOptions&&(e.shapeOptions=L.Util.extend({},this.options.shapeOptions,e.shapeOptions)),L.setOptions(this,e);var i=L.version.split(".");1===parseInt(i[0],10)&&parseInt(i[1],10)>=2?L.Draw.Feature.include(L.Evented.prototype):L.Draw.Feature.include(L.Mixin.Events)},enable:function(){this._enabled||(L.Handler.prototype.enable.call(this),this.fire("enabled",{handler:this.type}),this._map.fire(L.Draw.Event.DRAWSTART,{layerType:this.type}))},disable:function(){this._enabled&&(L.Handler.prototype.disable.call(this),this._map.fire(L.Draw.Event.DRAWSTOP,{layerType:this.type}),this.fire("disabled",{handler:this.type}))},addHooks:function(){var t=this._map;t&&(L.DomUtil.disableTextSelection(),t.getContainer().focus(),this._tooltip=new L.Draw.Tooltip(this._map),L.DomEvent.on(this._container,"keyup",this._cancelDrawing,this))},removeHooks:function(){this._map&&(L.DomUtil.enableTextSelection(),this._tooltip.dispose(),this._tooltip=null,L.DomEvent.off(this._container,"keyup",this._cancelDrawing,this))},setOptions:function(t){L.setOptions(this,t)},_fireCreatedEvent:function(t){this._map.fire(L.Draw.Event.CREATED,{layer:t,layerType:this.type})},_cancelDrawing:function(t){27===t.keyCode&&(this._map.fire("draw:canceled",{layerType:this.type}),this.disable())}}),L.Draw.Polyline=L.Draw.Feature.extend({statics:{TYPE:"polyline"},Poly:L.Polyline,options:{allowIntersection:!0,repeatMode:!1,drawError:{color:"#b00b00",timeout:2500},icon:new L.DivIcon({iconSize:new L.Point(8,8),className:"leaflet-div-icon leaflet-editing-icon"}),touchIcon:new L.DivIcon({iconSize:new L.Point(20,20),className:"leaflet-div-icon leaflet-editing-icon leaflet-touch-icon"}),guidelineDistance:20,maxGuideLineLength:4e3,shapeOptions:{stroke:!0,color:"#3388ff",weight:4,opacity:.5,fill:!1,clickable:!0},metric:!0,feet:!0,nautic:!1,showLength:!0,zIndexOffset:2e3,factor:1,maxPoints:0},initialize:function(t,e){L.Browser.touch&&(this.options.icon=this.options.touchIcon),this.options.drawError.message=L.drawLocal.draw.handlers.polyline.error,e&&e.drawError&&(e.drawError=L.Util.extend({},this.options.drawError,e.drawError)),this.type=L.Draw.Polyline.TYPE,L.Draw.Feature.prototype.initialize.call(this,t,e)},addHooks:function(){L.Draw.Feature.prototype.addHooks.call(this),this._map&&(this._markers=[],this._markerGroup=new L.LayerGroup,this._map.addLayer(this._markerGroup),this._poly=new L.Polyline([],this.options.shapeOptions),this._tooltip.updateContent(this._getTooltipText()),this._mouseMarker||(this._mouseMarker=L.marker(this._map.getCenter(),{icon:L.divIcon({className:"leaflet-mouse-marker",iconAnchor:[20,20],iconSize:[40,40]}),opacity:0,zIndexOffset:this.options.zIndexOffset})),this._mouseMarker.on("mouseout",this._onMouseOut,this).on("mousemove",this._onMouseMove,this).on("mousedown",this._onMouseDown,this).on("mouseup",this._onMouseUp,this).addTo(this._map),this._map.on("mouseup",this._onMouseUp,this).on("mousemove",this._onMouseMove,this).on("zoomlevelschange",this._onZoomEnd,this).on("touchstart",this._onTouch,this).on("zoomend",this._onZoomEnd,this))},removeHooks:function(){L.Draw.Feature.prototype.removeHooks.call(this),this._clearHideErrorTimeout(),this._cleanUpShape(),this._map.removeLayer(this._markerGroup),delete this._markerGroup,delete this._markers,this._map.removeLayer(this._poly),delete this._poly,this._mouseMarker.off("mousedown",this._onMouseDown,this).off("mouseout",this._onMouseOut,this).off("mouseup",this._onMouseUp,this).off("mousemove",this._onMouseMove,this),this._map.removeLayer(this._mouseMarker),delete this._mouseMarker,this._clearGuides(),this._map.off("mouseup",this._onMouseUp,this).off("mousemove",this._onMouseMove,this).off("zoomlevelschange",this._onZoomEnd,this).off("zoomend",this._onZoomEnd,this).off("touchstart",this._onTouch,this).off("click",this._onTouch,this)},deleteLastVertex:function(){if(!(this._markers.length<=1)){var t=this._markers.pop(),e=this._poly,i=e.getLatLngs(),o=i.splice(-1,1)[0];this._poly.setLatLngs(i),this._markerGroup.removeLayer(t),e.getLatLngs().length<2&&this._map.removeLayer(e),this._vertexChanged(o,!1)}},addVertex:function(t){if(this._markers.length>=2&&!this.options.allowIntersection&&this._poly.newLatLngIntersects(t))return void this._showErrorTooltip();this._errorShown&&this._hideErrorTooltip(),this._markers.push(this._createMarker(t)),this._poly.addLatLng(t),2===this._poly.getLatLngs().length&&this._map.addLayer(this._poly),this._vertexChanged(t,!0)},completeShape:function(){this._markers.length<=1||!this._shapeIsValid()||(this._fireCreatedEvent(),this.disable(),this.options.repeatMode&&this.enable())},_finishShape:function(){var t=this._poly._defaultShape?this._poly._defaultShape():this._poly.getLatLngs(),e=this._poly.newLatLngIntersects(t[t.length-1]);if(!this.options.allowIntersection&&e||!this._shapeIsValid())return void this._showErrorTooltip();this._fireCreatedEvent(),this.disable(),this.options.repeatMode&&this.enable()},_shapeIsValid:function(){return!0},_onZoomEnd:function(){null!==this._markers&&this._updateGuide()},_onMouseMove:function(t){var e=this._map.mouseEventToLayerPoint(t.originalEvent),i=this._map.layerPointToLatLng(e);this._currentLatLng=i,this._updateTooltip(i),this._updateGuide(e),this._mouseMarker.setLatLng(i),L.DomEvent.preventDefault(t.originalEvent)},_vertexChanged:function(t,e){this._map.fire(L.Draw.Event.DRAWVERTEX,{layers:this._markerGroup}),this._updateFinishHandler(),this._updateRunningMeasure(t,e),this._clearGuides(),this._updateTooltip()},_onMouseDown:function(t){if(!this._clickHandled&&!this._touchHandled&&!this._disableMarkers){this._onMouseMove(t),this._clickHandled=!0,this._disableNewMarkers();var e=t.originalEvent,i=e.clientX,o=e.clientY;this._startPoint.call(this,i,o)}},_startPoint:function(t,e){this._mouseDownOrigin=L.point(t,e)},_onMouseUp:function(t){var e=t.originalEvent,i=e.clientX,o=e.clientY;this._endPoint.call(this,i,o,t),this._clickHandled=null},_endPoint:function(e,i,o){if(this._mouseDownOrigin){var a=L.point(e,i).distanceTo(this._mouseDownOrigin),n=this._calculateFinishDistance(o.latlng);this.options.maxPoints>1&&this.options.maxPoints==this._markers.length+1?(this.addVertex(o.latlng),this._finishShape()):n<10&&L.Browser.touch?this._finishShape():Math.abs(a)<9*(t.devicePixelRatio||1)&&this.addVertex(o.latlng),this._enableNewMarkers()}this._mouseDownOrigin=null},_onTouch:function(t){var e,i,o=t.originalEvent;!o.touches||!o.touches[0]||this._clickHandled||this._touchHandled||this._disableMarkers||(e=o.touches[0].clientX,i=o.touches[0].clientY,this._disableNewMarkers(),this._touchHandled=!0,this._startPoint.call(this,e,i),this._endPoint.call(this,e,i,t),this._touchHandled=null),this._clickHandled=null},_onMouseOut:function(){this._tooltip&&this._tooltip._onMouseOut.call(this._tooltip)},_calculateFinishDistance:function(t){var e;if(this._markers.length>0){var i;if(this.type===L.Draw.Polyline.TYPE)i=this._markers[this._markers.length-1];else{if(this.type!==L.Draw.Polygon.TYPE)return 1/0;i=this._markers[0]}var o=this._map.latLngToContainerPoint(i.getLatLng()),a=new L.Marker(t,{icon:this.options.icon,zIndexOffset:2*this.options.zIndexOffset}),n=this._map.latLngToContainerPoint(a.getLatLng());e=o.distanceTo(n)}else e=1/0;return e},_updateFinishHandler:function(){var t=this._markers.length;t>1&&this._markers[t-1].on("click",this._finishShape,this),t>2&&this._markers[t-2].off("click",this._finishShape,this)},_createMarker:function(t){var e=new L.Marker(t,{icon:this.options.icon,zIndexOffset:2*this.options.zIndexOffset});return this._markerGroup.addLayer(e),e},_updateGuide:function(t){var e=this._markers?this._markers.length:0;e>0&&(t=t||this._map.latLngToLayerPoint(this._currentLatLng),this._clearGuides(),this._drawGuide(this._map.latLngToLayerPoint(this._markers[e-1].getLatLng()),t))},_updateTooltip:function(t){var e=this._getTooltipText();t&&this._tooltip.updatePosition(t),this._errorShown||this._tooltip.updateContent(e)},_drawGuide:function(t,e){var i,o,a,n=Math.floor(Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))),s=this.options.guidelineDistance,r=this.options.maxGuideLineLength,l=n>r?n-r:s;for(this._guidesContainer||(this._guidesContainer=L.DomUtil.create("div","leaflet-draw-guides",this._overlayPane));l1&&this._markers[this._markers.length-1].off("click",this._finishShape,this)},_fireCreatedEvent:function(){var t=new this.Poly(this._poly.getLatLngs(),this.options.shapeOptions);L.Draw.Feature.prototype._fireCreatedEvent.call(this,t)}}),L.Draw.Polygon=L.Draw.Polyline.extend({statics:{TYPE:"polygon"},Poly:L.Polygon,options:{showArea:!1,showLength:!1,shapeOptions:{stroke:!0,color:"#3388ff",weight:4,opacity:.5,fill:!0,fillColor:null,fillOpacity:.2,clickable:!0},metric:!0,feet:!0,nautic:!1,precision:{}},initialize:function(t,e){L.Draw.Polyline.prototype.initialize.call(this,t,e),this.type=L.Draw.Polygon.TYPE},_updateFinishHandler:function(){var t=this._markers.length;1===t&&this._markers[0].on("click",this._finishShape,this),t>2&&(this._markers[t-1].on("dblclick",this._finishShape,this),t>3&&this._markers[t-2].off("dblclick",this._finishShape,this))},_getTooltipText:function(){var t,e;return 0===this._markers.length?t=L.drawLocal.draw.handlers.polygon.tooltip.start:this._markers.length<3?(t=L.drawLocal.draw.handlers.polygon.tooltip.cont,e=this._getMeasurementString()):(t=L.drawLocal.draw.handlers.polygon.tooltip.end,e=this._getMeasurementString()),{text:t,subtext:e}},_getMeasurementString:function(){var t=this._area,e="";return t||this.options.showLength?(this.options.showLength&&(e=L.Draw.Polyline.prototype._getMeasurementString.call(this)),t&&(e+="
"+L.GeometryUtil.readableArea(t,this.options.metric,this.options.precision)),e):null},_shapeIsValid:function(){return this._markers.length>=3},_vertexChanged:function(t,e){var i;!this.options.allowIntersection&&this.options.showArea&&(i=this._poly.getLatLngs(),this._area=L.GeometryUtil.geodesicArea(i)),L.Draw.Polyline.prototype._vertexChanged.call(this,t,e)},_cleanUpShape:function(){var t=this._markers.length;t>0&&(this._markers[0].off("click",this._finishShape,this),t>2&&this._markers[t-1].off("dblclick",this._finishShape,this))}}),L.SimpleShape={},L.Draw.SimpleShape=L.Draw.Feature.extend({options:{repeatMode:!1},initialize:function(t,e){this._endLabelText=L.drawLocal.draw.handlers.simpleshape.tooltip.end,L.Draw.Feature.prototype.initialize.call(this,t,e)},addHooks:function(){L.Draw.Feature.prototype.addHooks.call(this),this._map&&(this._mapDraggable=this._map.dragging.enabled(),this._mapDraggable&&this._map.dragging.disable(),this._container.style.cursor="crosshair",this._tooltip.updateContent({text:this._initialLabelText}),this._map.on("mousedown",this._onMouseDown,this).on("mousemove",this._onMouseMove,this).on("touchstart",this._onMouseDown,this).on("touchmove",this._onMouseMove,this),e.addEventListener("touchstart",L.DomEvent.preventDefault,{passive:!1}))},removeHooks:function(){L.Draw.Feature.prototype.removeHooks.call(this),this._map&&(this._mapDraggable&&this._map.dragging.enable(),this._container.style.cursor="",this._map.off("mousedown",this._onMouseDown,this).off("mousemove",this._onMouseMove,this).off("touchstart",this._onMouseDown,this).off("touchmove",this._onMouseMove,this),L.DomEvent.off(e,"mouseup",this._onMouseUp,this),L.DomEvent.off(e,"touchend",this._onMouseUp,this),e.removeEventListener("touchstart",L.DomEvent.preventDefault),this._shape&&(this._map.removeLayer(this._shape),delete this._shape)),this._isDrawing=!1},_getTooltipText:function(){return{text:this._endLabelText}},_onMouseDown:function(t){this._isDrawing=!0,this._startLatLng=t.latlng,L.DomEvent.on(e,"mouseup",this._onMouseUp,this).on(e,"touchend",this._onMouseUp,this).preventDefault(t.originalEvent)},_onMouseMove:function(t){var e=t.latlng;this._tooltip.updatePosition(e),this._isDrawing&&(this._tooltip.updateContent(this._getTooltipText()),this._drawShape(e))},_onMouseUp:function(){this._shape&&this._fireCreatedEvent(),this.disable(),this.options.repeatMode&&this.enable()}}),L.Draw.Rectangle=L.Draw.SimpleShape.extend({statics:{TYPE:"rectangle"},options:{shapeOptions:{stroke:!0,color:"#3388ff",weight:4,opacity:.5,fill:!0,fillColor:null,fillOpacity:.2,clickable:!0},showArea:!0,metric:!0},initialize:function(t,e){this.type=L.Draw.Rectangle.TYPE,this._initialLabelText=L.drawLocal.draw.handlers.rectangle.tooltip.start,L.Draw.SimpleShape.prototype.initialize.call(this,t,e)},disable:function(){this._enabled&&(this._isCurrentlyTwoClickDrawing=!1,L.Draw.SimpleShape.prototype.disable.call(this))},_onMouseUp:function(t){if(!this._shape&&!this._isCurrentlyTwoClickDrawing)return void(this._isCurrentlyTwoClickDrawing=!0);this._isCurrentlyTwoClickDrawing&&!o(t.target,"leaflet-pane")||L.Draw.SimpleShape.prototype._onMouseUp.call(this)},_drawShape:function(t){this._shape?this._shape.setBounds(new L.LatLngBounds(this._startLatLng,t)):(this._shape=new L.Rectangle(new L.LatLngBounds(this._startLatLng,t),this.options.shapeOptions),this._map.addLayer(this._shape))},_fireCreatedEvent:function(){var t=new L.Rectangle(this._shape.getBounds(),this.options.shapeOptions);L.Draw.SimpleShape.prototype._fireCreatedEvent.call(this,t)},_getTooltipText:function(){var t,e,i,o=L.Draw.SimpleShape.prototype._getTooltipText.call(this),a=this._shape,n=this.options.showArea;return a&&(t=this._shape._defaultShape?this._shape._defaultShape():this._shape.getLatLngs(),e=L.GeometryUtil.geodesicArea(t),i=n?L.GeometryUtil.readableArea(e,this.options.metric):""),{text:o.text,subtext:i}}}),L.Draw.Marker=L.Draw.Feature.extend({statics:{TYPE:"marker"},options:{icon:new L.Icon.Default,repeatMode:!1,zIndexOffset:2e3},initialize:function(t,e){this.type=L.Draw.Marker.TYPE,this._initialLabelText=L.drawLocal.draw.handlers.marker.tooltip.start,L.Draw.Feature.prototype.initialize.call(this,t,e)},addHooks:function(){L.Draw.Feature.prototype.addHooks.call(this),this._map&&(this._tooltip.updateContent({text:this._initialLabelText}),this._mouseMarker||(this._mouseMarker=L.marker(this._map.getCenter(),{icon:L.divIcon({className:"leaflet-mouse-marker",iconAnchor:[20,20],iconSize:[40,40]}),opacity:0,zIndexOffset:this.options.zIndexOffset})),this._mouseMarker.on("click",this._onClick,this).addTo(this._map),this._map.on("mousemove",this._onMouseMove,this),this._map.on("click",this._onTouch,this))},removeHooks:function(){L.Draw.Feature.prototype.removeHooks.call(this),this._map&&(this._map.off("click",this._onClick,this).off("click",this._onTouch,this),this._marker&&(this._marker.off("click",this._onClick,this),this._map.removeLayer(this._marker),delete this._marker),this._mouseMarker.off("click",this._onClick,this),this._map.removeLayer(this._mouseMarker),delete this._mouseMarker,this._map.off("mousemove",this._onMouseMove,this))},_onMouseMove:function(t){var e=t.latlng;this._tooltip.updatePosition(e),this._mouseMarker.setLatLng(e),this._marker?(e=this._mouseMarker.getLatLng(),this._marker.setLatLng(e)):(this._marker=this._createMarker(e),this._marker.on("click",this._onClick,this),this._map.on("click",this._onClick,this).addLayer(this._marker))},_createMarker:function(t){return new L.Marker(t,{icon:this.options.icon,zIndexOffset:this.options.zIndexOffset})},_onClick:function(){this._fireCreatedEvent(),this.disable(),this.options.repeatMode&&this.enable()},_onTouch:function(t){this._onMouseMove(t),this._onClick()},_fireCreatedEvent:function(){var t=new L.Marker.Touch(this._marker.getLatLng(),{icon:this.options.icon});L.Draw.Feature.prototype._fireCreatedEvent.call(this,t)}}),L.Draw.CircleMarker=L.Draw.Marker.extend({statics:{TYPE:"circlemarker"},options:{stroke:!0,color:"#3388ff",weight:4,opacity:.5,fill:!0,fillColor:null,fillOpacity:.2,clickable:!0,zIndexOffset:2e3},initialize:function(t,e){this.type=L.Draw.CircleMarker.TYPE,this._initialLabelText=L.drawLocal.draw.handlers.circlemarker.tooltip.start,L.Draw.Feature.prototype.initialize.call(this,t,e)},_fireCreatedEvent:function(){var t=new L.CircleMarker(this._marker.getLatLng(),this.options);L.Draw.Feature.prototype._fireCreatedEvent.call(this,t)},_createMarker:function(t){return new L.CircleMarker(t,this.options)}}),L.Draw.Circle=L.Draw.SimpleShape.extend({statics:{TYPE:"circle"},options:{shapeOptions:{stroke:!0,color:"#3388ff",weight:4,opacity:.5,fill:!0,fillColor:null,fillOpacity:.2,clickable:!0},showRadius:!0,metric:!0,feet:!0,nautic:!1},initialize:function(t,e){this.type=L.Draw.Circle.TYPE,this._initialLabelText=L.drawLocal.draw.handlers.circle.tooltip.start,L.Draw.SimpleShape.prototype.initialize.call(this,t,e)},_drawShape:function(t){if(L.GeometryUtil.isVersion07x())var e=this._startLatLng.distanceTo(t);else var e=this._map.distance(this._startLatLng,t);this._shape?this._shape.setRadius(e):(this._shape=new L.Circle(this._startLatLng,e,this.options.shapeOptions),this._map.addLayer(this._shape))},_fireCreatedEvent:function(){var t=new L.Circle(this._startLatLng,this._shape.getRadius(),this.options.shapeOptions);L.Draw.SimpleShape.prototype._fireCreatedEvent.call(this,t)},_onMouseMove:function(t){var e,i=t.latlng,o=this.options.showRadius,a=this.options.metric;if(this._tooltip.updatePosition(i),this._isDrawing){this._drawShape(i),e=this._shape.getRadius().toFixed(1);var n="";o&&(n=L.drawLocal.draw.handlers.circle.radius+": "+L.GeometryUtil.readableDistance(e,a,this.options.feet,this.options.nautic)),this._tooltip.updateContent({text:this._endLabelText,subtext:n})}}}),L.Edit=L.Edit||{},L.Edit.Marker=L.Handler.extend({initialize:function(t,e){this._marker=t,L.setOptions(this,e)},addHooks:function(){var t=this._marker;t.dragging.enable(),t.on("dragend",this._onDragEnd,t),this._toggleMarkerHighlight()},removeHooks:function(){var t=this._marker;t.dragging.disable(),t.off("dragend",this._onDragEnd,t),this._toggleMarkerHighlight()},_onDragEnd:function(t){var e=t.target;e.edited=!0,this._map.fire(L.Draw.Event.EDITMOVE,{layer:e})},_toggleMarkerHighlight:function(){var t=this._marker._icon;t&&(t.style.display="none",L.DomUtil.hasClass(t,"leaflet-edit-marker-selected")?(L.DomUtil.removeClass(t,"leaflet-edit-marker-selected"),this._offsetMarker(t,-4)):(L.DomUtil.addClass(t,"leaflet-edit-marker-selected"),this._offsetMarker(t,4)),t.style.display="")},_offsetMarker:function(t,e){var i=parseInt(t.style.marginTop,10)-e,o=parseInt(t.style.marginLeft,10)-e;t.style.marginTop=i+"px",t.style.marginLeft=o+"px"}}),L.Marker.addInitHook(function(){L.Edit.Marker&&(this.editing=new L.Edit.Marker(this),this.options.editable&&this.editing.enable())}),L.Edit=L.Edit||{},L.Edit.Poly=L.Handler.extend({initialize:function(t){this.latlngs=[t._latlngs],t._holes&&(this.latlngs=this.latlngs.concat(t._holes)),this._poly=t,this._poly.on("revert-edited",this._updateLatLngs,this)},_defaultShape:function(){return L.Polyline._flat?L.Polyline._flat(this._poly._latlngs)?this._poly._latlngs:this._poly._latlngs[0]:this._poly._latlngs},_eachVertexHandler:function(t){for(var e=0;et&&(i._index+=e)})},_createMiddleMarker:function(t,e){var i,o,a,n=this._getMiddleLatLng(t,e),s=this._createMarker(n);s.setOpacity(.6),t._middleRight=e._middleLeft=s,o=function(){s.off("touchmove",o,this);var a=e._index;s._index=a,s.off("click",i,this).on("click",this._onMarkerClick,this),n.lat=s.getLatLng().lat,n.lng=s.getLatLng().lng,this._spliceLatLngs(a,0,n),this._markers.splice(a,0,s),s.setOpacity(1),this._updateIndexes(a,1),e._index++,this._updatePrevNext(t,s),this._updatePrevNext(s,e),this._poly.fire("editstart")},a=function(){s.off("dragstart",o,this),s.off("dragend",a,this),s.off("touchmove",o,this),this._createMiddleMarker(t,s),this._createMiddleMarker(s,e)},i=function(){o.call(this),a.call(this),this._fireEdit()},s.on("click",i,this).on("dragstart",o,this).on("dragend",a,this).on("touchmove",o,this),this._markerGroup.addLayer(s)},_updatePrevNext:function(t,e){t&&(t._next=e),e&&(e._prev=t)},_getMiddleLatLng:function(t,e){var i=this._poly._map,o=i.project(t.getLatLng()),a=i.project(e.getLatLng());return i.unproject(o._add(a)._divideBy(2))}}),L.Polyline.addInitHook(function(){this.editing||(L.Edit.Poly&&(this.editing=new L.Edit.Poly(this),this.options.editable&&this.editing.enable()),this.on("add",function(){this.editing&&this.editing.enabled()&&this.editing.addHooks()}),this.on("remove",function(){this.editing&&this.editing.enabled()&&this.editing.removeHooks()}))}),L.Edit=L.Edit||{},L.Edit.SimpleShape=L.Handler.extend({options:{moveIcon:new L.DivIcon({iconSize:new L.Point(8,8),className:"leaflet-div-icon leaflet-editing-icon leaflet-edit-move"}),resizeIcon:new L.DivIcon({iconSize:new L.Point(8,8), className:"leaflet-div-icon leaflet-editing-icon leaflet-edit-resize"}),touchMoveIcon:new L.DivIcon({iconSize:new L.Point(20,20),className:"leaflet-div-icon leaflet-editing-icon leaflet-edit-move leaflet-touch-icon"}),touchResizeIcon:new L.DivIcon({iconSize:new L.Point(20,20),className:"leaflet-div-icon leaflet-editing-icon leaflet-edit-resize leaflet-touch-icon"})},initialize:function(t,e){L.Browser.touch&&(this.options.moveIcon=this.options.touchMoveIcon,this.options.resizeIcon=this.options.touchResizeIcon),this._shape=t,L.Util.setOptions(this,e)},addHooks:function(){var t=this._shape;this._shape._map&&(this._map=this._shape._map,t.setStyle(t.options.editing),t._map&&(this._map=t._map,this._markerGroup||this._initMarkers(),this._map.addLayer(this._markerGroup)))},removeHooks:function(){var t=this._shape;if(t.setStyle(t.options.original),t._map){this._unbindMarker(this._moveMarker);for(var e=0,i=this._resizeMarkers.length;e"+L.drawLocal.edit.handlers.edit.tooltip.text,subtext:L.drawLocal.draw.handlers.circle.radius+": "+L.GeometryUtil.readableDistance(radius,!0,this.options.feet,this.options.nautic)})),this._shape.setRadius(radius),this._map.fire(L.Draw.Event.EDITRESIZE,{layer:this._shape})}}),L.Circle.addInitHook(function(){L.Edit.Circle&&(this.editing=new L.Edit.Circle(this),this.options.editable&&this.editing.enable())}),L.Map.mergeOptions({touchExtend:!0}),L.Map.TouchExtend=L.Handler.extend({initialize:function(t){this._map=t,this._container=t._container,this._pane=t._panes.overlayPane},addHooks:function(){L.DomEvent.on(this._container,"touchstart",this._onTouchStart,this),L.DomEvent.on(this._container,"touchend",this._onTouchEnd,this),L.DomEvent.on(this._container,"touchmove",this._onTouchMove,this),this._detectIE()?(L.DomEvent.on(this._container,"MSPointerDown",this._onTouchStart,this),L.DomEvent.on(this._container,"MSPointerUp",this._onTouchEnd,this),L.DomEvent.on(this._container,"MSPointerMove",this._onTouchMove,this),L.DomEvent.on(this._container,"MSPointerCancel",this._onTouchCancel,this)):(L.DomEvent.on(this._container,"touchcancel",this._onTouchCancel,this),L.DomEvent.on(this._container,"touchleave",this._onTouchLeave,this))},removeHooks:function(){L.DomEvent.off(this._container,"touchstart",this._onTouchStart,this),L.DomEvent.off(this._container,"touchend",this._onTouchEnd,this),L.DomEvent.off(this._container,"touchmove",this._onTouchMove,this),this._detectIE()?(L.DomEvent.off(this._container,"MSPointerDown",this._onTouchStart,this),L.DomEvent.off(this._container,"MSPointerUp",this._onTouchEnd,this),L.DomEvent.off(this._container,"MSPointerMove",this._onTouchMove,this),L.DomEvent.off(this._container,"MSPointerCancel",this._onTouchCancel,this)):(L.DomEvent.off(this._container,"touchcancel",this._onTouchCancel,this),L.DomEvent.off(this._container,"touchleave",this._onTouchLeave,this))},_touchEvent:function(t,e){var i={};if(void 0!==t.touches){if(!t.touches.length)return;i=t.touches[0]}else{if("touch"!==t.pointerType)return;if(i=t,!this._filterClick(t))return}var o=this._map.mouseEventToContainerPoint(i),a=this._map.mouseEventToLayerPoint(i),n=this._map.layerPointToLatLng(a);this._map.fire(e,{latlng:n,layerPoint:a,containerPoint:o,pageX:i.pageX,pageY:i.pageY,originalEvent:t})},_filterClick:function(t){var e=t.timeStamp||t.originalEvent.timeStamp,i=L.DomEvent._lastClick&&e-L.DomEvent._lastClick;return i&&i>100&&i<500||t.target._simulatedClick&&!t._simulated?(L.DomEvent.stop(t),!1):(L.DomEvent._lastClick=e,!0)},_onTouchStart:function(t){if(this._map._loaded){this._touchEvent(t,"touchstart")}},_onTouchEnd:function(t){if(this._map._loaded){this._touchEvent(t,"touchend")}},_onTouchCancel:function(t){if(this._map._loaded){var e="touchcancel";this._detectIE()&&(e="pointercancel"),this._touchEvent(t,e)}},_onTouchLeave:function(t){if(this._map._loaded){this._touchEvent(t,"touchleave")}},_onTouchMove:function(t){if(this._map._loaded){this._touchEvent(t,"touchmove")}},_detectIE:function(){var e=t.navigator.userAgent,i=e.indexOf("MSIE ");if(i>0)return parseInt(e.substring(i+5,e.indexOf(".",i)),10);if(e.indexOf("Trident/")>0){var o=e.indexOf("rv:");return parseInt(e.substring(o+3,e.indexOf(".",o)),10)}var a=e.indexOf("Edge/");return a>0&&parseInt(e.substring(a+5,e.indexOf(".",a)),10)}}),L.Map.addInitHook("addHandler","touchExtend",L.Map.TouchExtend),L.Marker.Touch=L.Marker.extend({_initInteraction:function(){return this.addInteractiveTarget?L.Marker.prototype._initInteraction.apply(this):this._initInteractionLegacy()},_initInteractionLegacy:function(){if(this.options.clickable){var t=this._icon,e=["dblclick","mousedown","mouseover","mouseout","contextmenu","touchstart","touchend","touchmove"];this._detectIE?e.concat(["MSPointerDown","MSPointerUp","MSPointerMove","MSPointerCancel"]):e.concat(["touchcancel"]),L.DomUtil.addClass(t,"leaflet-clickable"),L.DomEvent.on(t,"click",this._onMouseClick,this),L.DomEvent.on(t,"keypress",this._onKeyPress,this);for(var i=0;i0)return parseInt(e.substring(i+5,e.indexOf(".",i)),10);if(e.indexOf("Trident/")>0){var o=e.indexOf("rv:");return parseInt(e.substring(o+3,e.indexOf(".",o)),10)}var a=e.indexOf("Edge/");return a>0&&parseInt(e.substring(a+5,e.indexOf(".",a)),10)}}),L.LatLngUtil={cloneLatLngs:function(t){for(var e=[],i=0,o=t.length;i2){for(var s=0;s1&&(i=i+s+r[1])}return i},readableArea:function(e,i,o){var a,n,o=L.Util.extend({},t,o);return i?(n=["ha","m"],type=typeof i,"string"===type?n=[i]:"boolean"!==type&&(n=i),a=e>=1e6&&-1!==n.indexOf("km")?L.GeometryUtil.formattedNumber(1e-6*e,o.km)+" km²":e>=1e4&&-1!==n.indexOf("ha")?L.GeometryUtil.formattedNumber(1e-4*e,o.ha)+" ha":L.GeometryUtil.formattedNumber(e,o.m)+" m²"):(e/=.836127,a=e>=3097600?L.GeometryUtil.formattedNumber(e/3097600,o.mi)+" mi²":e>=4840?L.GeometryUtil.formattedNumber(e/4840,o.ac)+" acres":L.GeometryUtil.formattedNumber(e,o.yd)+" yd²"),a},readableDistance:function(e,i,o,a,n){var s,n=L.Util.extend({},t,n);switch(i?"string"==typeof i?i:"metric":o?"feet":a?"nauticalMile":"yards"){case"metric":s=e>1e3?L.GeometryUtil.formattedNumber(e/1e3,n.km)+" km":L.GeometryUtil.formattedNumber(e,n.m)+" m";break;case"feet":e*=3.28083,s=L.GeometryUtil.formattedNumber(e,n.ft)+" ft";break;case"nauticalMile":e*=.53996,s=L.GeometryUtil.formattedNumber(e/1e3,n.nm)+" nm";break;case"yards":default:e*=1.09361,s=e>1760?L.GeometryUtil.formattedNumber(e/1760,n.mi)+" miles":L.GeometryUtil.formattedNumber(e,n.yd)+" yd"}return s},isVersion07x:function(){var t=L.version.split(".");return 0===parseInt(t[0],10)&&7===parseInt(t[1],10)}})}(),L.Util.extend(L.LineUtil,{segmentsIntersect:function(t,e,i,o){return this._checkCounterclockwise(t,i,o)!==this._checkCounterclockwise(e,i,o)&&this._checkCounterclockwise(t,e,i)!==this._checkCounterclockwise(t,e,o)},_checkCounterclockwise:function(t,e,i){return(i.y-t.y)*(e.x-t.x)>(e.y-t.y)*(i.x-t.x)}}),L.Polyline.include({intersects:function(){var t,e,i,o=this._getProjectedPoints(),a=o?o.length:0;if(this._tooFewPointsForIntersection())return!1;for(t=a-1;t>=3;t--)if(e=o[t-1],i=o[t],this._lineSegmentsIntersectsRange(e,i,t-2))return!0;return!1},newLatLngIntersects:function(t,e){return!!this._map&&this.newPointIntersects(this._map.latLngToLayerPoint(t),e)},newPointIntersects:function(t,e){var i=this._getProjectedPoints(),o=i?i.length:0,a=i?i[o-1]:null,n=o-2;return!this._tooFewPointsForIntersection(1)&&this._lineSegmentsIntersectsRange(a,t,n,e?1:0)},_tooFewPointsForIntersection:function(t){var e=this._getProjectedPoints(),i=e?e.length:0;return i+=t||0,!e||i<=3},_lineSegmentsIntersectsRange:function(t,e,i,o){var a,n,s=this._getProjectedPoints();o=o||0;for(var r=i;r>o;r--)if(a=s[r-1],n=s[r],L.LineUtil.segmentsIntersect(t,e,a,n))return!0;return!1},_getProjectedPoints:function(){if(!this._defaultShape)return this._originalPoints;for(var t=[],e=this._defaultShape(),i=0;i=2?L.Toolbar.include(L.Evented.prototype):L.Toolbar.include(L.Mixin.Events)},enabled:function(){return null!==this._activeMode},disable:function(){this.enabled()&&this._activeMode.handler.disable()},addToolbar:function(t){var e,i=L.DomUtil.create("div","leaflet-draw-section"),o=0,a=this._toolbarClass||"",n=this.getModeHandlers(t);for(this._toolbarContainer=L.DomUtil.create("div","leaflet-draw-toolbar leaflet-bar"),this._map=t,e=0;e0&&this._singleLineLabel&&(L.DomUtil.removeClass(this._container,"leaflet-draw-tooltip-single"),this._singleLineLabel=!1):(L.DomUtil.addClass(this._container,"leaflet-draw-tooltip-single"),this._singleLineLabel=!0),this._container.innerHTML=(t.subtext.length>0?''+t.subtext+"
":"")+""+t.text+"",t.text||t.subtext?(this._visible=!0,this._container.style.visibility="inherit"):(this._visible=!1,this._container.style.visibility="hidden"),this):this},updatePosition:function(t){var e=this._map.latLngToLayerPoint(t),i=this._container;return this._container&&(this._visible&&(i.style.visibility="inherit"),L.DomUtil.setPosition(i,e)),this},showAsError:function(){return this._container&&L.DomUtil.addClass(this._container,"leaflet-error-draw-tooltip"),this},removeError:function(){return this._container&&L.DomUtil.removeClass(this._container,"leaflet-error-draw-tooltip"),this},_onMouseOut:function(){this._container&&(this._container.style.visibility="hidden")}}),L.DrawToolbar=L.Toolbar.extend({statics:{TYPE:"draw"},options:{polyline:{},polygon:{},rectangle:{},circle:{},marker:{},circlemarker:{}},initialize:function(t){for(var e in this.options)this.options.hasOwnProperty(e)&&t[e]&&(t[e]=L.extend({},this.options[e],t[e]));this._toolbarClass="leaflet-draw-draw",L.Toolbar.prototype.initialize.call(this,t)},getModeHandlers:function(t){return[{enabled:this.options.polyline,handler:new L.Draw.Polyline(t,this.options.polyline),title:L.drawLocal.draw.toolbar.buttons.polyline},{enabled:this.options.polygon,handler:new L.Draw.Polygon(t,this.options.polygon),title:L.drawLocal.draw.toolbar.buttons.polygon},{enabled:this.options.rectangle,handler:new L.Draw.Rectangle(t,this.options.rectangle),title:L.drawLocal.draw.toolbar.buttons.rectangle},{enabled:this.options.circle,handler:new L.Draw.Circle(t,this.options.circle),title:L.drawLocal.draw.toolbar.buttons.circle},{enabled:this.options.marker,handler:new L.Draw.Marker(t,this.options.marker),title:L.drawLocal.draw.toolbar.buttons.marker},{enabled:this.options.circlemarker,handler:new L.Draw.CircleMarker(t,this.options.circlemarker),title:L.drawLocal.draw.toolbar.buttons.circlemarker}]},getActions:function(t){return[{enabled:t.completeShape,title:L.drawLocal.draw.toolbar.finish.title,text:L.drawLocal.draw.toolbar.finish.text,callback:t.completeShape,context:t},{enabled:t.deleteLastVertex,title:L.drawLocal.draw.toolbar.undo.title,text:L.drawLocal.draw.toolbar.undo.text,callback:t.deleteLastVertex,context:t},{title:L.drawLocal.draw.toolbar.actions.title,text:L.drawLocal.draw.toolbar.actions.text,callback:this.disable,context:this}]},setOptions:function(t){L.setOptions(this,t);for(var e in this._modes)this._modes.hasOwnProperty(e)&&t.hasOwnProperty(e)&&this._modes[e].handler.setOptions(t[e])}}),L.EditToolbar=L.Toolbar.extend({statics:{TYPE:"edit"},options:{edit:{selectedPathOptions:{dashArray:"10, 10",fill:!0,fillColor:"#fe57a1",fillOpacity:.1,maintainColor:!1}},remove:{},poly:null,featureGroup:null},initialize:function(t){t.edit&&(void 0===t.edit.selectedPathOptions&&(t.edit.selectedPathOptions=this.options.edit.selectedPathOptions),t.edit.selectedPathOptions=L.extend({},this.options.edit.selectedPathOptions,t.edit.selectedPathOptions)),t.remove&&(t.remove=L.extend({},this.options.remove,t.remove)),t.poly&&(t.poly=L.extend({},this.options.poly,t.poly)),this._toolbarClass="leaflet-draw-edit",L.Toolbar.prototype.initialize.call(this,t),this._selectedFeatureCount=0},getModeHandlers:function(t){var e=this.options.featureGroup;return[{enabled:this.options.edit,handler:new L.EditToolbar.Edit(t,{featureGroup:e,selectedPathOptions:this.options.edit.selectedPathOptions,poly:this.options.poly}),title:L.drawLocal.edit.toolbar.buttons.edit},{enabled:this.options.remove,handler:new L.EditToolbar.Delete(t,{featureGroup:e}),title:L.drawLocal.edit.toolbar.buttons.remove}]},getActions:function(t){var e=[{title:L.drawLocal.edit.toolbar.actions.save.title,text:L.drawLocal.edit.toolbar.actions.save.text,callback:this._save,context:this},{title:L.drawLocal.edit.toolbar.actions.cancel.title,text:L.drawLocal.edit.toolbar.actions.cancel.text,callback:this.disable,context:this}];return t.removeAllLayers&&e.push({title:L.drawLocal.edit.toolbar.actions.clearAll.title,text:L.drawLocal.edit.toolbar.actions.clearAll.text,callback:this._clearAllLayers,context:this}),e},addToolbar:function(t){var e=L.Toolbar.prototype.addToolbar.call(this,t);return this._checkDisabled(),this.options.featureGroup.on("layeradd layerremove",this._checkDisabled,this),e},removeToolbar:function(){this.options.featureGroup.off("layeradd layerremove",this._checkDisabled,this),L.Toolbar.prototype.removeToolbar.call(this)},disable:function(){this.enabled()&&(this._activeMode.handler.revertLayers(),L.Toolbar.prototype.disable.call(this))},_save:function(){this._activeMode.handler.save(),this._activeMode&&this._activeMode.handler.disable()},_clearAllLayers:function(){this._activeMode.handler.removeAllLayers(),this._activeMode&&this._activeMode.handler.disable()},_checkDisabled:function(){var t,e=this.options.featureGroup,i=0!==e.getLayers().length;this.options.edit&&(t=this._modes[L.EditToolbar.Edit.TYPE].button,i?L.DomUtil.removeClass(t,"leaflet-disabled"):L.DomUtil.addClass(t,"leaflet-disabled"),t.setAttribute("title",i?L.drawLocal.edit.toolbar.buttons.edit:L.drawLocal.edit.toolbar.buttons.editDisabled)),this.options.remove&&(t=this._modes[L.EditToolbar.Delete.TYPE].button,i?L.DomUtil.removeClass(t,"leaflet-disabled"):L.DomUtil.addClass(t,"leaflet-disabled"),t.setAttribute("title",i?L.drawLocal.edit.toolbar.buttons.remove:L.drawLocal.edit.toolbar.buttons.removeDisabled))}}),L.EditToolbar.Edit=L.Handler.extend({statics:{TYPE:"edit"},initialize:function(t,e){if(L.Handler.prototype.initialize.call(this,t),L.setOptions(this,e),this._featureGroup=e.featureGroup,!(this._featureGroup instanceof L.FeatureGroup))throw new Error("options.featureGroup must be a L.FeatureGroup");this._uneditedLayerProps={},this.type=L.EditToolbar.Edit.TYPE;var i=L.version.split(".");1===parseInt(i[0],10)&&parseInt(i[1],10)>=2?L.EditToolbar.Edit.include(L.Evented.prototype):L.EditToolbar.Edit.include(L.Mixin.Events)},enable:function(){!this._enabled&&this._hasAvailableLayers()&&(this.fire("enabled",{handler:this.type}),this._map.fire(L.Draw.Event.EDITSTART,{handler:this.type}),L.Handler.prototype.enable.call(this),this._featureGroup.on("layeradd",this._enableLayerEdit,this).on("layerremove",this._disableLayerEdit,this))},disable:function(){this._enabled&&(this._featureGroup.off("layeradd",this._enableLayerEdit,this).off("layerremove",this._disableLayerEdit,this),L.Handler.prototype.disable.call(this),this._map.fire(L.Draw.Event.EDITSTOP,{handler:this.type}),this.fire("disabled",{handler:this.type}))},addHooks:function(){var t=this._map;t&&(t.getContainer().focus(),this._featureGroup.eachLayer(this._enableLayerEdit,this),this._tooltip=new L.Draw.Tooltip(this._map),this._tooltip.updateContent({text:L.drawLocal.edit.handlers.edit.tooltip.text,subtext:L.drawLocal.edit.handlers.edit.tooltip.subtext}),t._editTooltip=this._tooltip,this._updateTooltip(),this._map.on("mousemove",this._onMouseMove,this).on("touchmove",this._onMouseMove,this).on("MSPointerMove",this._onMouseMove,this).on(L.Draw.Event.EDITVERTEX,this._updateTooltip,this))},removeHooks:function(){this._map&&(this._featureGroup.eachLayer(this._disableLayerEdit,this),this._map._editTooltip.dispose(),this._map._editTooltip=null,this._uneditedLayerProps={},this._tooltip.dispose(),this._tooltip=null,this._map.off("mousemove",this._onMouseMove,this).off("touchmove",this._onMouseMove,this).off("MSPointerMove",this._onMouseMove,this).off(L.Draw.Event.EDITVERTEX,this._updateTooltip,this))},revertLayers:function(){this._featureGroup.eachLayer(function(t){this._revertLayer(t)},this)},save:function(){var t=new L.LayerGroup;this._featureGroup.eachLayer(function(e){e.edited&&(t.addLayer(e),e.edited=!1)}),this._map.fire(L.Draw.Event.EDITED,{layers:t})},_backupLayer:function(t){var e=L.Util.stamp(t);this._uneditedLayerProps[e]||(t instanceof L.Polyline||t instanceof L.Polygon||t instanceof L.Rectangle?this._uneditedLayerProps[e]={latlngs:L.LatLngUtil.cloneLatLngs(t.getLatLngs())}:t instanceof L.Circle?this._uneditedLayerProps[e]={latlng:L.LatLngUtil.cloneLatLng(t.getLatLng()),radius:t.getRadius()}:(t instanceof L.Marker||t instanceof L.CircleMarker)&&(this._uneditedLayerProps[e]={latlng:L.LatLngUtil.cloneLatLng(t.getLatLng())}))},_getTooltipText:function(){return{text:L.drawLocal.edit.handlers.edit.tooltip.text,subtext:L.drawLocal.edit.handlers.edit.tooltip.subtext}},_updateTooltip:function(){this._tooltip.updateContent(this._getTooltipText())},_revertLayer:function(t){var e=L.Util.stamp(t);t.edited=!1,this._uneditedLayerProps.hasOwnProperty(e)&&(t instanceof L.Polyline||t instanceof L.Polygon||t instanceof L.Rectangle?t.setLatLngs(this._uneditedLayerProps[e].latlngs):t instanceof L.Circle?(t.setLatLng(this._uneditedLayerProps[e].latlng),t.setRadius(this._uneditedLayerProps[e].radius)):(t instanceof L.Marker||t instanceof L.CircleMarker)&&t.setLatLng(this._uneditedLayerProps[e].latlng),t.fire("revert-edited",{layer:t}))},_enableLayerEdit:function(t){var e,i,o=t.layer||t.target||t;this._backupLayer(o),this.options.poly&&(i=L.Util.extend({},this.options.poly),o.options.poly=i),this.options.selectedPathOptions&&(e=L.Util.extend({},this.options.selectedPathOptions),e.maintainColor&&(e.color=o.options.color,e.fillColor=o.options.fillColor),o.options.original=L.extend({},o.options),o.options.editing=e),o instanceof L.Marker?(o.editing&&o.editing.enable(),o.dragging.enable(),o.on("dragend",this._onMarkerDragEnd).on("touchmove",this._onTouchMove,this).on("MSPointerMove",this._onTouchMove,this).on("touchend",this._onMarkerDragEnd,this).on("MSPointerUp",this._onMarkerDragEnd,this)):o.editing.enable()},_disableLayerEdit:function(t){var e=t.layer||t.target||t;e.edited=!1,e.editing&&e.editing.disable(), delete e.options.editing,delete e.options.original,this._selectedPathOptions&&(e instanceof L.Marker?this._toggleMarkerHighlight(e):(e.setStyle(e.options.previousOptions),delete e.options.previousOptions)),e instanceof L.Marker?(e.dragging.disable(),e.off("dragend",this._onMarkerDragEnd,this).off("touchmove",this._onTouchMove,this).off("MSPointerMove",this._onTouchMove,this).off("touchend",this._onMarkerDragEnd,this).off("MSPointerUp",this._onMarkerDragEnd,this)):e.editing.disable()},_onMouseMove:function(t){this._tooltip.updatePosition(t.latlng)},_onMarkerDragEnd:function(t){var e=t.target;e.edited=!0,this._map.fire(L.Draw.Event.EDITMOVE,{layer:e})},_onTouchMove:function(t){var e=t.originalEvent.changedTouches[0],i=this._map.mouseEventToLayerPoint(e),o=this._map.layerPointToLatLng(i);t.target.setLatLng(o)},_hasAvailableLayers:function(){return 0!==this._featureGroup.getLayers().length}}),L.EditToolbar.Delete=L.Handler.extend({statics:{TYPE:"remove"},initialize:function(t,e){if(L.Handler.prototype.initialize.call(this,t),L.Util.setOptions(this,e),this._deletableLayers=this.options.featureGroup,!(this._deletableLayers instanceof L.FeatureGroup))throw new Error("options.featureGroup must be a L.FeatureGroup");this.type=L.EditToolbar.Delete.TYPE;var i=L.version.split(".");1===parseInt(i[0],10)&&parseInt(i[1],10)>=2?L.EditToolbar.Delete.include(L.Evented.prototype):L.EditToolbar.Delete.include(L.Mixin.Events)},enable:function(){!this._enabled&&this._hasAvailableLayers()&&(this.fire("enabled",{handler:this.type}),this._map.fire(L.Draw.Event.DELETESTART,{handler:this.type}),L.Handler.prototype.enable.call(this),this._deletableLayers.on("layeradd",this._enableLayerDelete,this).on("layerremove",this._disableLayerDelete,this))},disable:function(){this._enabled&&(this._deletableLayers.off("layeradd",this._enableLayerDelete,this).off("layerremove",this._disableLayerDelete,this),L.Handler.prototype.disable.call(this),this._map.fire(L.Draw.Event.DELETESTOP,{handler:this.type}),this.fire("disabled",{handler:this.type}))},addHooks:function(){var t=this._map;t&&(t.getContainer().focus(),this._deletableLayers.eachLayer(this._enableLayerDelete,this),this._deletedLayers=new L.LayerGroup,this._tooltip=new L.Draw.Tooltip(this._map),this._tooltip.updateContent({text:L.drawLocal.edit.handlers.remove.tooltip.text}),this._map.on("mousemove",this._onMouseMove,this))},removeHooks:function(){this._map&&(this._deletableLayers.eachLayer(this._disableLayerDelete,this),this._deletedLayers=null,this._tooltip.dispose(),this._tooltip=null,this._map.off("mousemove",this._onMouseMove,this))},revertLayers:function(){this._deletedLayers.eachLayer(function(t){this._deletableLayers.addLayer(t),t.fire("revert-deleted",{layer:t})},this)},save:function(){this._map.fire(L.Draw.Event.DELETED,{layers:this._deletedLayers})},removeAllLayers:function(){this._deletableLayers.eachLayer(function(t){this._removeLayer({layer:t})},this),this.save()},_enableLayerDelete:function(t){(t.layer||t.target||t).on("click",this._removeLayer,this)},_disableLayerDelete:function(t){var e=t.layer||t.target||t;e.off("click",this._removeLayer,this),this._deletedLayers.removeLayer(e)},_removeLayer:function(t){var e=t.layer||t.target||t;this._deletableLayers.removeLayer(e),this._deletedLayers.addLayer(e),e.fire("deleted")},_onMouseMove:function(t){this._tooltip.updatePosition(t.latlng)},_hasAvailableLayers:function(){return 0!==this._deletableLayers.getLayers().length}})}(window,document); \ No newline at end of file diff --git a/src/edit/handler/Edit.Circle.js b/src/edit/handler/Edit.Circle.js index 600d1cc0e..671f31f5c 100644 --- a/src/edit/handler/Edit.Circle.js +++ b/src/edit/handler/Edit.Circle.js @@ -33,8 +33,8 @@ L.Edit.Circle = L.Edit.CircleMarker.extend({ this._shape.setRadius(radius); if (this._map._editTooltip) { - this._map._editTooltip.updatePosition(latlng); - this._map._editTooltip.updateContent({ + this._map._editTooltip.updatePosition(latlng); + this._map._editTooltip.updateContent({ text: L.drawLocal.edit.handlers.edit.tooltip.subtext + '
' + L.drawLocal.edit.handlers.edit.tooltip.text, subtext: L.drawLocal.draw.handlers.circle.radius + ': ' + L.GeometryUtil.readableDistance(radius, true, this.options.feet, this.options.nautic)