1/* 2 Leaflet.draw 1.0.4, a plugin that adds drawing and editing tools to Leaflet powered maps. 3 (c) 2012-2017, Jacob Toye, Jon West, Smartrak, Leaflet 4 5 https://github.com/Leaflet/Leaflet.draw 6 http://leafletjs.com 7 */ 8 ! function(t, e, i) { 9 function o(t, e) { 10 for (; 11 (t = t.parentElement) && !t.classList.contains(e);); 12 return t 13 } 14 L.drawVersion = "1.0.4", L.Draw = {}, L.drawLocal = { 15 draw: { 16 toolbar: { 17 actions: { 18 title: "Cancel drawing", 19 text: "Cancel" 20 }, 21 finish: { 22 title: "Finish drawing", 23 text: "Finish" 24 }, 25 undo: { 26 title: "Delete last point drawn", 27 text: "Delete last point" 28 }, 29 buttons: { 30 polyline: "Draw a polyline", 31 polygon: "Draw a polygon", 32 rectangle: "Draw a rectangle", 33 circle: "Draw a circle", 34 marker: "Draw a marker", 35 circlemarker: "Draw a circlemarker" 36 } 37 }, 38 handlers: { 39 circle: { 40 tooltip: { 41 start: "Click and drag to draw circle." 42 }, 43 radius: "Radius" 44 }, 45 circlemarker: { 46 tooltip: { 47 start: "Click map to place circle marker." 48 } 49 }, 50 marker: { 51 tooltip: { 52 start: "Click map to place marker." 53 } 54 }, 55 polygon: { 56 tooltip: { 57 start: "Click to start drawing shape.", 58 cont: "Click to continue drawing shape.", 59 end: "Click first point to close this shape." 60 } 61 }, 62 polyline: { 63 error: "<strong>Error:</strong> shape edges cannot cross!", 64 tooltip: { 65 start: "Click to start drawing line.", 66 cont: "Click to continue drawing line.", 67 end: "Click last point to finish line." 68 } 69 }, 70 rectangle: { 71 tooltip: { 72 start: "Click and drag to draw rectangle." 73 } 74 }, 75 simpleshape: { 76 tooltip: { 77 end: "Release mouse to finish drawing." 78 } 79 } 80 } 81 }, 82 edit: { 83 toolbar: { 84 actions: { 85 save: { 86 title: "Save changes", 87 text: "Save" 88 }, 89 cancel: { 90 title: "Cancel editing, discards all changes", 91 text: "Cancel" 92 }, 93 clearAll: { 94 title: "Clear all layers", 95 text: "Clear All" 96 } 97 }, 98 buttons: { 99 edit: "Edit layers", 100 editDisabled: "No layers to edit", 101 remove: "Delete layers", 102 removeDisabled: "No layers to delete" 103 } 104 }, 105 handlers: { 106 edit: { 107 tooltip: { 108 text: "Drag handles or markers to edit features.", 109 subtext: "Click cancel to undo changes." 110 } 111 }, 112 remove: { 113 tooltip: { 114 text: "Click on a feature to remove." 115 } 116 } 117 } 118 } 119 }, 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.EDIT
vendor: 96,954 bytes, lines 119-1711
119START = "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({ 120 initialize: function(t, e) { 121 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); 122 var i = L.version.split("."); 123 1 === parseInt(i[0], 10) && parseInt(i[1], 10) >= 2 ? L.Draw.Feature.include(L.Evented.prototype) : L.Draw.Feature.include(L.Mixin.Events) 124 }, 125 enable: function() { 126 this._enabled || (L.Handler.prototype.enable.call(this), this.fire("enabled", { 127 handler: this.type 128 }), this._map.fire(L.Draw.Event.DRAWSTART, { 129 layerType: this.type 130 })) 131 }, 132 disable: function() { 133 this._enabled && (L.Handler.prototype.disable.call(this), this._map.fire(L.Draw.Event.DRAWSTOP, { 134 layerType: this.type 135 }), this.fire("disabled", { 136 handler: this.type 137 })) 138 }, 139 addHooks: function() { 140 var t = this._map; 141 t && (L.DomUtil.disableTextSelection(), t.getContainer().focus(), this._tooltip = new L.Draw.Tooltip(this._map), L.DomEvent.on(this._container, "keyup", this._cancelDrawing, this)) 142 }, 143 removeHooks: function() { 144 this._map && (L.DomUtil.enableTextSelection(), this._tooltip.dispose(), this._tooltip = null, L.DomEvent.off(this._container, "keyup", this._cancelDrawing, this)) 145 }, 146 setOptions: function(t) { 147 L.setOptions(this, t) 148 }, 149 _fireCreatedEvent: function(t) { 150 this._map.fire(L.Draw.Event.CREATED, { 151 layer: t, 152 layerType: this.type 153 }) 154 }, 155 _cancelDrawing: function(t) { 156 27 === t.keyCode && (this._map.fire("draw:canceled", { 157 layerType: this.type 158 }), this.disable()) 159 } 160 }), L.Draw.Polyline = L.Draw.Feature.extend({ 161 statics: { 162 TYPE: "polyline" 163 }, 164 Poly: L.Polyline, 165 options: { 166 allowIntersection: !0, 167 repeatMode: !1, 168 drawError: { 169 color: "#b00b00", 170 timeout: 2500 171 }, 172 icon: new L.DivIcon({ 173 iconSize: new L.Point(8, 8), 174 className: "leaflet-div-icon leaflet-editing-icon" 175 }), 176 touchIcon: new L.DivIcon({ 177 iconSize: new L.Point(20, 20), 178 className: "leaflet-div-icon leaflet-editing-icon leaflet-touch-icon" 179 }), 180 guidelineDistance: 20, 181 maxGuideLineLength: 4e3, 182 shapeOptions: { 183 stroke: !0, 184 color: "#3388ff", 185 weight: 4, 186 opacity: .5, 187 fill: !1, 188 clickable: !0 189 }, 190 metric: !0, 191 feet: !0, 192 nautic: !1, 193 showLength: !0, 194 zIndexOffset: 2e3, 195 factor: 1, 196 maxPoints: 0 197 }, 198 initialize: function(t, e) { 199 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) 200 }, 201 addHooks: function() { 202 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(), { 203 icon: L.divIcon({ 204 className: "leaflet-mouse-marker", 205 iconAnchor: [20, 20], 206 iconSize: [40, 40] 207 }), 208 opacity: 0, 209 zIndexOffset: this.options.zIndexOffset 210 })), 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)) 211 }, 212 removeHooks: function() { 213 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) 214 }, 215 deleteLastVertex: function() { 216 if (!(this._markers.length <= 1)) { 217 var t = this._markers.pop(), 218 e = this._poly, 219 i = e.getLatLngs(), 220 o = i.splice(-1, 1)[0]; 221 this._poly.setLatLngs(i), this._markerGroup.removeLayer(t), e.getLatLngs().length < 2 && this._map.removeLayer(e), this._vertexChanged(o, !1) 222 } 223 }, 224 addVertex: function(t) { 225 if (this._markers.length >= 2 && !this.options.allowIntersection && this._poly.newLatLngIntersects(t)) return void this._showErrorTooltip(); 226 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) 227 }, 228 completeShape: function() { 229 this._markers.length <= 1 || !this._shapeIsValid() || (this._fireCreatedEvent(), this.disable(), this.options.repeatMode && this.enable()) 230 }, 231 _finishShape: function() { 232 var t = this._poly._defaultShape ? this._poly._defaultShape() : this._poly.getLatLngs(), 233 e = this._poly.newLatLngIntersects(t[t.length - 1]); 234 if (!this.options.allowIntersection && e || !this._shapeIsValid()) return void this._showErrorTooltip(); 235 this._fireCreatedEvent(), this.disable(), this.options.repeatMode && this.enable() 236 }, 237 _shapeIsValid: function() { 238 return !0 239 }, 240 _onZoomEnd: function() { 241 null !== this._markers && this._updateGuide() 242 }, 243 _onMouseMove: function(t) { 244 var e = this._map.mouseEventToLayerPoint(t.originalEvent), 245 i = this._map.layerPointToLatLng(e); 246 this._currentLatLng = i, this._updateTooltip(i), this._updateGuide(e), this._mouseMarker.setLatLng(i), L.DomEvent.preventDefault(t.originalEvent) 247 }, 248 _vertexChanged: function(t, e) { 249 this._map.fire(L.Draw.Event.DRAWVERTEX, { 250 layers: this._markerGroup 251 }), this._updateFinishHandler(), this._updateRunningMeasure(t, e), this._clearGuides(), this._updateTooltip() 252 }, 253 _onMouseDown: function(t) { 254 if (!this._clickHandled && !this._touchHandled && !this._disableMarkers) { 255 this._onMouseMove(t), this._clickHandled = !0, this._disableNewMarkers(); 256 var e = t.originalEvent, 257 i = e.clientX, 258 o = e.clientY; 259 this._startPoint.call(this, i, o) 260 } 261 }, 262 _startPoint: function(t, e) { 263 this._mouseDownOrigin = L.point(t, e) 264 }, 265 _onMouseUp: function(t) { 266 var e = t.originalEvent, 267 i = e.clientX, 268 o = e.clientY; 269 this._endPoint.call(this, i, o, t), this._clickHandled = null 270 }, 271 _endPoint: function(e, i, o) { 272 if (this._mouseDownOrigin) { 273 var a = L.point(e, i).distanceTo(this._mouseDownOrigin), 274 n = this._calculateFinishDistance(o.latlng); 275 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() 276 } 277 this._mouseDownOrigin = null 278 }, 279 _onTouch: function(t) { 280 var e, i, o = t.originalEvent; 281 !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 282 }, 283 _onMouseOut: function() { 284 this._tooltip && this._tooltip._onMouseOut.call(this._tooltip) 285 }, 286 _calculateFinishDistance: function(t) { 287 var e; 288 if (this._markers.length > 0) { 289 var i; 290 if (this.type === L.Draw.Polyline.TYPE) i = this._markers[this._markers.length - 1]; 291 else { 292 if (this.type !== L.Draw.Polygon.TYPE) return 1 / 0; 293 i = this._markers[0] 294 } 295 var o = this._map.latLngToContainerPoint(i.getLatLng()), 296 a = new L.Marker(t, { 297 icon: this.options.icon, 298 zIndexOffset: 2 * this.options.zIndexOffset 299 }), 300 n = this._map.latLngToContainerPoint(a.getLatLng()); 301 e = o.distanceTo(n) 302 } else e = 1 / 0; 303 return e 304 }, 305 _updateFinishHandler: function() { 306 var t = this._markers.length; 307 t > 1 && this._markers[t - 1].on("click", this._finishShape, this), t > 2 && this._markers[t - 2].off("click", this._finishShape, this) 308 }, 309 _createMarker: function(t) { 310 var e = new L.Marker(t, { 311 icon: this.options.icon, 312 zIndexOffset: 2 * this.options.zIndexOffset 313 }); 314 return this._markerGroup.addLayer(e), e 315 }, 316 _updateGuide: function(t) { 317 var e = this._markers ? this._markers.length : 0; 318 e > 0 && (t = t || this._map.latLngToLayerPoint(this._currentLatLng), this._clearGuides(), this._drawGuide(this._map.latLngToLayerPoint(this._markers[e - 1].getLatLng()), t)) 319 }, 320 _updateTooltip: function(t) { 321 var e = this._getTooltipText(); 322 t && this._tooltip.updatePosition(t), this._errorShown || this._tooltip.updateContent(e) 323 }, 324 _drawGuide: function(t, e) { 325 var i, o, a, n = Math.floor(Math.sqrt(Math.pow(e.x - t.x, 2) + Math.pow(e.y - t.y, 2))), 326 s = this.options.guidelineDistance, 327 r = this.options.maxGuideLineLength, 328 l = n > r ? n - r : s; 329 for (this._guidesContainer || (this._guidesContainer = L.DomUtil.create("div", "leaflet-draw-guides", this._overlayPane)); l < n; l += this.options.guidelineDistance) i = l / n, o = { 330 x: Math.floor(t.x * (1 - i) + i * e.x), 331 y: Math.floor(t.y * (1 - i) + i * e.y) 332 }, a = L.DomUtil.create("div", "leaflet-draw-guide-dash", this._guidesContainer), a.style.backgroundColor = this._errorShown ? this.options.drawError.color : this.options.shapeOptions.color, L.DomUtil.setPosition(a, o) 333 }, 334 _updateGuideColor: function(t) { 335 if (this._guidesContainer) 336 for (var e = 0, i = this._guidesContainer.childNodes.length; e < i; e++) this._guidesContainer.childNodes[e].style.backgroundColor = t 337 }, 338 _clearGuides: function() { 339 if (this._guidesContainer) 340 for (; this._guidesContainer.firstChild;) this._guidesContainer.removeChild(this._guidesContainer.firstChild) 341 }, 342 _getTooltipText: function() { 343 var t, e, i = this.options.showLength; 344 return 0 === this._markers.length ? t = { 345 text: L.drawLocal.draw.handlers.polyline.tooltip.start 346 } : (e = i ? this._getMeasurementString() : "", t = 1 === this._markers.length ? { 347 text: L.drawLocal.draw.handlers.polyline.tooltip.cont, 348 subtext: e 349 } : { 350 text: L.drawLocal.draw.handlers.polyline.tooltip.end, 351 subtext: e 352 }), t 353 }, 354 _updateRunningMeasure: function(t, e) { 355 var i, o, a = this._markers.length; 356 1 === this._markers.length ? this._measurementRunningTotal = 0 : (i = a - (e ? 2 : 1), o = L.GeometryUtil.isVersion07x() ? t.distanceTo(this._markers[i].getLatLng()) * (this.options.factor || 1) : this._map.distance(t, this._markers[i].getLatLng()) * (this.options.factor || 1), this._measurementRunningTotal += o * (e ? 1 : -1)) 357 }, 358 _getMeasurementString: function() { 359 var t, e = this._currentLatLng, 360 i = this._markers[this._markers.length - 1].getLatLng(); 361 return t = L.GeometryUtil.isVersion07x() ? i && e && e.distanceTo ? this._measurementRunningTotal + e.distanceTo(i) * (this.options.factor || 1) : this._measurementRunningTotal || 0 : i && e ? this._measurementRunningTotal + this._map.distance(e, i) * (this.options.factor || 1) : this._measurementRunningTotal || 0, L.GeometryUtil.readableDistance(t, this.options.metric, this.options.feet, this.options.nautic, this.options.precision) 362 }, 363 _showErrorTooltip: function() { 364 this._errorShown = !0, this._tooltip.showAsError().updateContent({ 365 text: this.options.drawError.message 366 }), this._updateGuideColor(this.options.drawError.color), this._poly.setStyle({ 367 color: this.options.drawError.color 368 }), this._clearHideErrorTimeout(), this._hideErrorTimeout = setTimeout(L.Util.bind(this._hideErrorTooltip, this), this.options.drawError.timeout) 369 }, 370 _hideErrorTooltip: function() { 371 this._errorShown = !1, this._clearHideErrorTimeout(), this._tooltip.removeError().updateContent(this._getTooltipText()), this._updateGuideColor(this.options.shapeOptions.color), this._poly.setStyle({ 372 color: this.options.shapeOptions.color 373 }) 374 }, 375 _clearHideErrorTimeout: function() { 376 this._hideErrorTimeout && (clearTimeout(this._hideErrorTimeout), this._hideErrorTimeout = null) 377 }, 378 _disableNewMarkers: function() { 379 this._disableMarkers = !0 380 }, 381 _enableNewMarkers: function() { 382 setTimeout(function() { 383 this._disableMarkers = !1 384 }.bind(this), 50) 385 }, 386 _cleanUpShape: function() { 387 this._markers.length > 1 && this._markers[this._markers.length - 1].off("click", this._finishShape, this) 388 }, 389 _fireCreatedEvent: function() { 390 var t = new this.Poly(this._poly.getLatLngs(), this.options.shapeOptions); 391 L.Draw.Feature.prototype._fireCreatedEvent.call(this, t) 392 } 393 }), L.Draw.Polygon = L.Draw.Polyline.extend({ 394 statics: { 395 TYPE: "polygon" 396 }, 397 Poly: L.Polygon, 398 options: { 399 showArea: !1, 400 showLength: !1, 401 shapeOptions: { 402 stroke: !0, 403 color: "#3388ff", 404 weight: 4, 405 opacity: .5, 406 fill: !0, 407 fillColor: null, 408 fillOpacity: .2, 409 clickable: !0 410 }, 411 metric: !0, 412 feet: !0, 413 nautic: !1, 414 precision: {} 415 }, 416 initialize: function(t, e) { 417 L.Draw.Polyline.prototype.initialize.call(this, t, e), this.type = L.Draw.Polygon.TYPE 418 }, 419 _updateFinishHandler: function() { 420 var t = this._markers.length; 421 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)) 422 }, 423 _getTooltipText: function() { 424 var t, e; 425 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()), { 426 text: t, 427 subtext: e 428 } 429 }, 430 _getMeasurementString: function() { 431 var t = this._area, 432 e = ""; 433 return t || this.options.showLength ? (this.options.showLength && (e = L.Draw.Polyline.prototype._getMeasurementString.call(this)), t && (e += "<br>" + L.GeometryUtil.readableArea(t, this.options.metric, this.options.precision)), e) : null 434 }, 435 _shapeIsValid: function() { 436 return this._markers.length >= 3 437 }, 438 _vertexChanged: function(t, e) { 439 var i; 440 !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) 441 }, 442 _cleanUpShape: function() { 443 var t = this._markers.length; 444 t > 0 && (this._markers[0].off("click", this._finishShape, this), t > 2 && this._markers[t - 1].off("dblclick", this._finishShape, this)) 445 } 446 }), L.SimpleShape = {}, L.Draw.SimpleShape = L.Draw.Feature.extend({ 447 options: { 448 repeatMode: !1 449 }, 450 initialize: function(t, e) { 451 this._endLabelText = L.drawLocal.draw.handlers.simpleshape.tooltip.end, L.Draw.Feature.prototype.initialize.call(this, t, e) 452 }, 453 addHooks: function() { 454 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({ 455 text: this._initialLabelText 456 }), 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, { 457 passive: !1 458 })) 459 }, 460 removeHooks: function() { 461 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 462 }, 463 _getTooltipText: function() { 464 return { 465 text: this._endLabelText 466 } 467 }, 468 _onMouseDown: function(t) { 469 this._isDrawing = !0, this._startLatLng = t.latlng, L.DomEvent.on(e, "mouseup", this._onMouseUp, this).on(e, "touchend", this._onMouseUp, this).preventDefault(t.originalEvent) 470 }, 471 _onMouseMove: function(t) { 472 var e = t.latlng; 473 this._tooltip.updatePosition(e), this._isDrawing && (this._tooltip.updateContent(this._getTooltipText()), this._drawShape(e)) 474 }, 475 _onMouseUp: function() { 476 this._shape && this._fireCreatedEvent(), this.disable(), this.options.repeatMode && this.enable() 477 } 478 }), L.Draw.Rectangle = L.Draw.SimpleShape.extend({ 479 statics: { 480 TYPE: "rectangle" 481 }, 482 options: { 483 shapeOptions: { 484 stroke: !0, 485 color: "#3388ff", 486 weight: 4, 487 opacity: .5, 488 fill: !0, 489 fillColor: null, 490 fillOpacity: .2, 491 clickable: !0 492 }, 493 showArea: !0, 494 metric: !0 495 }, 496 initialize: function(t, e) { 497 this.type = L.Draw.Rectangle.TYPE, this._initialLabelText = L.drawLocal.draw.handlers.rectangle.tooltip.start, L.Draw.SimpleShape.prototype.initialize.call(this, t, e) 498 }, 499 disable: function() { 500 this._enabled && (this._isCurrentlyTwoClickDrawing = !1, L.Draw.SimpleShape.prototype.disable.call(this)) 501 }, 502 _onMouseUp: function(t) { 503 if (!this._shape && !this._isCurrentlyTwoClickDrawing) return void(this._isCurrentlyTwoClickDrawing = !0); 504 this._isCurrentlyTwoClickDrawing && !o(t.target, "leaflet-pane") || L.Draw.SimpleShape.prototype._onMouseUp.call(this) 505 }, 506 _drawShape: function(t) { 507 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)) 508 }, 509 _fireCreatedEvent: function() { 510 var t = new L.Rectangle(this._shape.getBounds(), this.options.shapeOptions); 511 L.Draw.SimpleShape.prototype._fireCreatedEvent.call(this, t) 512 }, 513 _getTooltipText: function() { 514 var t, e, i, o = L.Draw.SimpleShape.prototype._getTooltipText.call(this), 515 a = this._shape, 516 n = this.options.showArea; 517 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) : ""), { 518 text: o.text, 519 subtext: i 520 } 521 } 522 }), L.Draw.Marker = L.Draw.Feature.extend({ 523 statics: { 524 TYPE: "marker" 525 }, 526 options: { 527 icon: new L.Icon.Default, 528 repeatMode: !1, 529 zIndexOffset: 2e3 530 }, 531 initialize: function(t, e) { 532 this.type = L.Draw.Marker.TYPE, this._initialLabelText = L.drawLocal.draw.handlers.marker.tooltip.start, L.Draw.Feature.prototype.initialize.call(this, t, e) 533 }, 534 addHooks: function() { 535 L.Draw.Feature.prototype.addHooks.call(this), this._map && (this._tooltip.updateContent({ 536 text: this._initialLabelText 537 }), this._mouseMarker || (this._mouseMarker = L.marker(this._map.getCenter(), { 538 icon: L.divIcon({ 539 className: "leaflet-mouse-marker", 540 iconAnchor: [20, 20], 541 iconSize: [40, 40] 542 }), 543 opacity: 0, 544 zIndexOffset: this.options.zIndexOffset 545 })), this._mouseMarker.on("click", this._onClick, this).addTo(this._map), this._map.on("mousemove", this._onMouseMove, this), this._map.on("click", this._onTouch, this)) 546 }, 547 removeHooks: function() { 548 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)) 549 }, 550 _onMouseMove: function(t) { 551 var e = t.latlng; 552 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)) 553 }, 554 _createMarker: function(t) { 555 return new L.Marker(t, { 556 icon: this.options.icon, 557 zIndexOffset: this.options.zIndexOffset 558 }) 559 }, 560 _onClick: function() { 561 this._fireCreatedEvent(), this.disable(), this.options.repeatMode && this.enable() 562 }, 563 _onTouch: function(t) { 564 this._onMouseMove(t), this._onClick() 565 }, 566 _fireCreatedEvent: function() { 567 var t = new L.Marker.Touch(this._marker.getLatLng(), { 568 icon: this.options.icon 569 }); 570 L.Draw.Feature.prototype._fireCreatedEvent.call(this, t) 571 } 572 }), L.Draw.CircleMarker = L.Draw.Marker.extend({ 573 statics: { 574 TYPE: "circlemarker" 575 }, 576 options: { 577 stroke: !0, 578 color: "#3388ff", 579 weight: 4, 580 opacity: .5, 581 fill: !0, 582 fillColor: null, 583 fillOpacity: .2, 584 clickable: !0, 585 zIndexOffset: 2e3 586 }, 587 initialize: function(t, e) { 588 this.type = L.Draw.CircleMarker.TYPE, this._initialLabelText = L.drawLocal.draw.handlers.circlemarker.tooltip.start, L.Draw.Feature.prototype.initialize.call(this, t, e) 589 }, 590 _fireCreatedEvent: function() { 591 var t = new L.CircleMarker(this._marker.getLatLng(), this.options); 592 L.Draw.Feature.prototype._fireCreatedEvent.call(this, t) 593 }, 594 _createMarker: function(t) { 595 return new L.CircleMarker(t, this.options) 596 } 597 }), L.Draw.Circle = L.Draw.SimpleShape.extend({ 598 statics: { 599 TYPE: "circle" 600 }, 601 options: { 602 shapeOptions: { 603 stroke: !0, 604 color: "#3388ff", 605 weight: 4, 606 opacity: .5, 607 fill: !0, 608 fillColor: null, 609 fillOpacity: .2, 610 clickable: !0 611 }, 612 showRadius: !0, 613 metric: !0, 614 feet: !0, 615 nautic: !1 616 }, 617 initialize: function(t, e) { 618 this.type = L.Draw.Circle.TYPE, this._initialLabelText = L.drawLocal.draw.handlers.circle.tooltip.start, L.Draw.SimpleShape.prototype.initialize.call(this, t, e) 619 }, 620 _drawShape: function(t) { 621 if (L.GeometryUtil.isVersion07x()) var e = this._startLatLng.distanceTo(t); 622 else var e = this._map.distance(this._startLatLng, t); 623 this._shape ? this._shape.setRadius(e) : (this._shape = new L.Circle(this._startLatLng, e, this.options.shapeOptions), this._map.addLayer(this._shape)) 624 }, 625 _fireCreatedEvent: function() { 626 var t = new L.Circle(this._startLatLng, this._shape.getRadius(), this.options.shapeOptions); 627 L.Draw.SimpleShape.prototype._fireCreatedEvent.call(this, t) 628 }, 629 _onMouseMove: function(t) { 630 var e, i = t.latlng, 631 o = this.options.showRadius, 632 a = this.options.metric; 633 if (this._tooltip.updatePosition(i), this._isDrawing) { 634 this._drawShape(i), e = this._shape.getRadius().toFixed(1); 635 var n = ""; 636 o && (n = L.drawLocal.draw.handlers.circle.radius + ": " + L.GeometryUtil.readableDistance(e, a, this.options.feet, this.options.nautic)), this._tooltip.updateContent({ 637 text: this._endLabelText, 638 subtext: n 639 }) 640 } 641 } 642 }), L.Edit = L.Edit || {}, L.Edit.Marker = L.Handler.extend({ 643 initialize: function(t, e) { 644 this._marker = t, L.setOptions(this, e) 645 }, 646 addHooks: function() { 647 var t = this._marker; 648 t.dragging.enable(), t.on("dragend", this._onDragEnd, t), this._toggleMarkerHighlight() 649 }, 650 removeHooks: function() { 651 var t = this._marker; 652 t.dragging.disable(), t.off("dragend", this._onDragEnd, t), this._toggleMarkerHighlight() 653 }, 654 _onDragEnd: function(t) { 655 var e = t.target; 656 e.edited = !0, this._map.fire(L.Draw.Event.EDITMOVE, { 657 layer: e 658 }) 659 }, 660 _toggleMarkerHighlight: function() { 661 var t = this._marker._icon; 662 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 = "") 663 }, 664 _offsetMarker: function(t, e) { 665 var i = parseInt(t.style.marginTop, 10) - e, 666 o = parseInt(t.style.marginLeft, 10) - e; 667 t.style.marginTop = i + "px", t.style.marginLeft = o + "px" 668 } 669 }), L.Marker.addInitHook(function() { 670 L.Edit.Marker && (this.editing = new L.Edit.Marker(this), this.options.editable && this.editing.enable()) 671 }), L.Edit = L.Edit || {}, L.Edit.Poly = L.Handler.extend({ 672 initialize: function(t) { 673 this.latlngs = [t._latlngs], t._holes && (this.latlngs = this.latlngs.concat(t._holes)), this._poly = t, this._poly.on("revert-edited", this._updateLatLngs, this) 674 }, 675 _defaultShape: function() { 676 return L.Polyline._flat ? L.Polyline._flat(this._poly._latlngs) ? this._poly._latlngs : this._poly._latlngs[0] : this._poly._latlngs 677 }, 678 _eachVertexHandler: function(t) { 679 for (var e = 0; e < this._verticesHandlers.length; e++) t(this._verticesHandlers[e]) 680 }, 681 addHooks: function() { 682 this._initHandlers(), this._eachVertexHandler(function(t) { 683 t.addHooks() 684 }) 685 }, 686 removeHooks: function() { 687 this._eachVertexHandler(function(t) { 688 t.removeHooks() 689 }) 690 }, 691 updateMarkers: function() { 692 this._eachVertexHandler(function(t) { 693 t.updateMarkers() 694 }) 695 }, 696 _initHandlers: function() { 697 this._verticesHandlers = []; 698 for (var t = 0; t < this.latlngs.length; t++) this._verticesHandlers.push(new L.Edit.PolyVerticesEdit(this._poly, this.latlngs[t], this._poly.options.poly)) 699 }, 700 _updateLatLngs: function(t) { 701 this.latlngs = [t.layer._latlngs], t.layer._holes && (this.latlngs = this.latlngs.concat(t.layer._holes)) 702 } 703 }), L.Edit.PolyVerticesEdit = L.Handler.extend({ 704 options: { 705 icon: new L.DivIcon({ 706 iconSize: new L.Point(8, 8), 707 className: "leaflet-div-icon leaflet-editing-icon" 708 }), 709 touchIcon: new L.DivIcon({ 710 iconSize: new L.Point(20, 20), 711 className: "leaflet-div-icon leaflet-editing-icon leaflet-touch-icon" 712 }), 713 drawError: { 714 color: "#b00b00", 715 timeout: 1e3 716 } 717 }, 718 initialize: function(t, e, i) { 719 L.Browser.touch && (this.options.icon = this.options.touchIcon), this._poly = t, i && i.drawError && (i.drawError = L.Util.extend({}, this.options.drawError, i.drawError)), this._latlngs = e, L.setOptions(this, i) 720 }, 721 _defaultShape: function() { 722 return L.Polyline._flat ? L.Polyline._flat(this._latlngs) ? this._latlngs : this._latlngs[0] : this._latlngs 723 }, 724 addHooks: function() { 725 var t = this._poly, 726 e = t._path; 727 t instanceof L.Polygon || (t.options.fill = !1, t.options.editing && (t.options.editing.fill = !1)), e && t.options.editing && t.options.editing.className && (t.options.original.className && t.options.original.className.split(" ").forEach(function(t) { 728 L.DomUtil.removeClass(e, t) 729 }), t.options.editing.className.split(" ").forEach(function(t) { 730 L.DomUtil.addClass(e, t) 731 })), t.setStyle(t.options.editing), this._poly._map && (this._map = this._poly._map, this._markerGroup || this._initMarkers(), this._poly._map.addLayer(this._markerGroup)) 732 }, 733 removeHooks: function() { 734 var t = this._poly, 735 e = t._path; 736 e && t.options.editing && t.options.editing.className && (t.options.editing.className.split(" ").forEach(function(t) { 737 L.DomUtil.removeClass(e, t) 738 }), t.options.original.className && t.options.original.className.split(" ").forEach(function(t) { 739 L.DomUtil.addClass(e, t) 740 })), t.setStyle(t.options.original), t._map && (t._map.removeLayer(this._markerGroup), delete this._markerGroup, delete this._markers) 741 }, 742 updateMarkers: function() { 743 this._markerGroup.clearLayers(), this._initMarkers() 744 }, 745 _initMarkers: function() { 746 this._markerGroup || (this._markerGroup = new L.LayerGroup), this._markers = []; 747 var t, e, i, o, a = this._defaultShape(); 748 for (t = 0, i = a.length; t < i; t++) o = this._createMarker(a[t], t), o.on("click", this._onMarkerClick, this), o.on("contextmenu", this._onContextMenu, this), this._markers.push(o); 749 var n, s; 750 for (t = 0, e = i - 1; t < i; e = t++)(0 !== t || L.Polygon && this._poly instanceof L.Polygon) && (n = this._markers[e], s = this._markers[t], this._createMiddleMarker(n, s), this._updatePrevNext(n, s)) 751 }, 752 _createMarker: function(t, e) { 753 var i = new L.Marker.Touch(t, { 754 draggable: !0, 755 icon: this.options.icon 756 }); 757 return i._origLatLng = t, i._index = e, i.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(i), i 758 }, 759 _onMarkerDragStart: function() { 760 this._poly.fire("editstart") 761 }, 762 _spliceLatLngs: function() { 763 var t = this._defaultShape(), 764 e = [].splice.apply(t, arguments); 765 return this._poly._convertLatLngs(t, !0), this._poly.redraw(), e 766 }, 767 _removeMarker: function(t) { 768 var e = t._index; 769 this._markerGroup.removeLayer(t), this._markers.splice(e, 1), this._spliceLatLngs(e, 1), this._updateIndexes(e, -1), t.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) 770 }, 771 _fireEdit: function() { 772 this._poly.edited = !0, this._poly.fire("edit"), this._poly._map.fire(L.Draw.Event.EDITVERTEX, { 773 layers: this._markerGroup, 774 poly: this._poly 775 }) 776 }, 777 _onMarkerDrag: function(t) { 778 var e = t.target, 779 i = this._poly, 780 o = L.LatLngUtil.cloneLatLng(e._origLatLng); 781 if (L.extend(e._origLatLng, e._latlng), i.options.poly) { 782 var a = i._map._editTooltip; 783 if (!i.options.poly.allowIntersection && i.intersects()) { 784 L.extend(e._origLatLng, o), e.setLatLng(o); 785 var n = i.options.color; 786 i.setStyle({ 787 color: this.options.drawError.color 788 }), a && a.updateContent({ 789 text: L.drawLocal.draw.handlers.polyline.error 790 }), setTimeout(function() { 791 i.setStyle({ 792 color: n 793 }), a && a.updateContent({ 794 text: L.drawLocal.edit.handlers.edit.tooltip.text, 795 subtext: L.drawLocal.edit.handlers.edit.tooltip.subtext 796 }) 797 }, 1e3) 798 } 799 } 800 e._middleLeft && e._middleLeft.setLatLng(this._getMiddleLatLng(e._prev, e)), e._middleRight && e._middleRight.setLatLng(this._getMiddleLatLng(e, e._next)), this._poly._bounds._southWest = L.latLng(1 / 0, 1 / 0), this._poly._bounds._northEast = L.latLng(-1 / 0, -1 / 0); 801 var s = this._poly.getLatLngs(); 802 this._poly._convertLatLngs(s, !0), this._poly.redraw(), this._poly.fire("editdrag") 803 }, 804 _onMarkerClick: function(t) { 805 var e = L.Polygon && this._poly instanceof L.Polygon ? 4 : 3, 806 i = t.target; 807 this._defaultShape().length < e || (this._removeMarker(i), this._updatePrevNext(i._prev, i._next), i._middleLeft && this._markerGroup.removeLayer(i._middleLeft), i._middleRight && this._markerGroup.removeLayer(i._middleRight), i._prev && i._next ? this._createMiddleMarker(i._prev, i._next) : i._prev ? i._next || (i._prev._middleRight = null) : i._next._middleLeft = null, this._fireEdit()) 808 }, 809 _onContextMenu: function(t) { 810 var e = t.target; 811 this._poly; 812 this._poly._map.fire(L.Draw.Event.MARKERCONTEXT, { 813 marker: e, 814 layers: this._markerGroup, 815 poly: this._poly 816 }), L.DomEvent.stopPropagation 817 }, 818 _onTouchMove: function(t) { 819 var e = this._map.mouseEventToLayerPoint(t.originalEvent.touches[0]), 820 i = this._map.layerPointToLatLng(e), 821 o = t.target; 822 L.extend(o._origLatLng, i), o._middleLeft && o._middleLeft.setLatLng(this._getMiddleLatLng(o._prev, o)), o._middleRight && o._middleRight.setLatLng(this._getMiddleLatLng(o, o._next)), this._poly.redraw(), this.updateMarkers() 823 }, 824 _updateIndexes: function(t, e) { 825 this._markerGroup.eachLayer(function(i) { 826 i._index > t && (i._index += e) 827 }) 828 }, 829 _createMiddleMarker: function(t, e) { 830 var i, o, a, n = this._getMiddleLatLng(t, e), 831 s = this._createMarker(n); 832 s.setOpacity(.6), t._middleRight = e._middleLeft = s, o = function() { 833 s.off("touchmove", o, this); 834 var a = e._index; 835 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") 836 }, a = function() { 837 s.off("dragstart", o, this), s.off("dragend", a, this), s.off("touchmove", o, this), this._createMiddleMarker(t, s), this._createMiddleMarker(s, e) 838 }, i = function() { 839 o.call(this), a.call(this), this._fireEdit() 840 }, s.on("click", i, this).on("dragstart", o, this).on("dragend", a, this).on("touchmove", o, this), this._markerGroup.addLayer(s) 841 }, 842 _updatePrevNext: function(t, e) { 843 t && (t._next = e), e && (e._prev = t) 844 }, 845 _getMiddleLatLng: function(t, e) { 846 var i = this._poly._map, 847 o = i.project(t.getLatLng()), 848 a = i.project(e.getLatLng()); 849 return i.unproject(o._add(a)._divideBy(2)) 850 } 851 }), L.Polyline.addInitHook(function() { 852 this.editing || (L.Edit.Poly && (this.editing = new L.Edit.Poly(this), this.options.editable && this.editing.enable()), this.on("add", function() { 853 this.editing && this.editing.enabled() && this.editing.addHooks() 854 }), this.on("remove", function() { 855 this.editing && this.editing.enabled() && this.editing.removeHooks() 856 })) 857 }), L.Edit = L.Edit || {}, L.Edit.SimpleShape = L.Handler.extend({ 858 options: { 859 moveIcon: new L.DivIcon({ 860 iconSize: new L.Point(8, 8), 861 className: "leaflet-div-icon leaflet-editing-icon leaflet-edit-move" 862 }), 863 resizeIcon: new L.DivIcon({ 864 iconSize: new L.Point(8, 8), 865 className: "leaflet-div-icon leaflet-editing-icon leaflet-edit-resize" 866 }), 867 touchMoveIcon: new L.DivIcon({ 868 iconSize: new L.Point(20, 20), 869 className: "leaflet-div-icon leaflet-editing-icon leaflet-edit-move leaflet-touch-icon" 870 }), 871 touchResizeIcon: new L.DivIcon({ 872 iconSize: new L.Point(20, 20), 873 className: "leaflet-div-icon leaflet-editing-icon leaflet-edit-resize leaflet-touch-icon" 874 }) 875 }, 876 initialize: function(t, e) { 877 L.Browser.touch && (this.options.moveIcon = this.options.touchMoveIcon, this.options.resizeIcon = this.options.touchResizeIcon), this._shape = t, L.Util.setOptions(this, e) 878 }, 879 addHooks: function() { 880 var t = this._shape; 881 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))) 882 }, 883 removeHooks: function() { 884 var t = this._shape; 885 if (t.setStyle(t.options.original), t._map) { 886 this._unbindMarker(this._moveMarker); 887 for (var e = 0, i = this._resizeMarkers.length; e < i; e++) this._unbindMarker(this._resizeMarkers[e]); 888 this._resizeMarkers = null, this._map.removeLayer(this._markerGroup), delete this._markerGroup 889 } 890 this._map = null 891 }, 892 updateMarkers: function() { 893 this._markerGroup.clearLayers(), this._initMarkers() 894 }, 895 _initMarkers: function() { 896 this._markerGroup || (this._markerGroup = new L.LayerGroup), this._createMoveMarker(), this._createResizeMarker() 897 }, 898 _createMoveMarker: function() {}, 899 _createResizeMarker: function() {}, 900 _createMarker: function(t, e) { 901 var i = new L.Marker.Touch(t, { 902 draggable: !0, 903 icon: e, 904 zIndexOffset: 10 905 }); 906 return this._bindMarker(i), this._markerGroup.addLayer(i), i 907 }, 908 _bindMarker: function(t) { 909 t.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) 910 }, 911 _unbindMarker: function(t) { 912 t.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) 913 }, 914 _onMarkerDragStart: function(t) { 915 t.target.setOpacity(0), this._shape.fire("editstart") 916 }, 917 _fireEdit: function() { 918 this._shape.edited = !0, this._shape.fire("edit") 919 }, 920 _onMarkerDrag: function(t) { 921 var e = t.target, 922 i = e.getLatLng(); 923 e === this._moveMarker ? this._move(i) : this._resize(i), this._shape.redraw(), this._shape.fire("editdrag") 924 }, 925 _onMarkerDragEnd: function(t) { 926 t.target.setOpacity(1), this._fireEdit() 927 }, 928 _onTouchStart: function(t) { 929 if (L.Edit.SimpleShape.prototype._onMarkerDragStart.call(this, t), "function" == typeof this._getCorners) { 930 var e = this._getCorners(), 931 i = t.target, 932 o = i._cornerIndex; 933 i.setOpacity(0), this._oppositeCorner = e[(o + 2) % 4], this._toggleCornerMarkers(0, o) 934 } 935 this._shape.fire("editstart") 936 }, 937 _onTouchMove: function(t) { 938 var e = this._map.mouseEventToLayerPoint(t.originalEvent.touches[0]), 939 i = this._map.layerPointToLatLng(e); 940 return t.target === this._moveMarker ? this._move(i) : this._resize(i), this._shape.redraw(), !1 941 }, 942 _onTouchEnd: function(t) { 943 t.target.setOpacity(1), this.updateMarkers(), this._fireEdit() 944 }, 945 _move: function() {}, 946 _resize: function() {} 947 }), L.Edit = L.Edit || {}, L.Edit.Rectangle = L.Edit.SimpleShape.extend({ 948 _createMoveMarker: function() { 949 var t = this._shape.getBounds(), 950 e = t.getCenter(); 951 this._moveMarker = this._createMarker(e, this.options.moveIcon) 952 }, 953 _createResizeMarker: function() { 954 var t = this._getCorners(); 955 this._resizeMarkers = []; 956 for (var e = 0, i = t.length; e < i; e++) this._resizeMarkers.push(this._createMarker(t[e], this.options.resizeIcon)), this._resizeMarkers[e]._cornerIndex = e 957 }, 958 _onMarkerDragStart: function(t) { 959 L.Edit.SimpleShape.prototype._onMarkerDragStart.call(this, t); 960 var e = this._getCorners(), 961 i = t.target, 962 o = i._cornerIndex; 963 this._oppositeCorner = e[(o + 2) % 4], this._toggleCornerMarkers(0, o) 964 }, 965 _onMarkerDragEnd: function(t) { 966 var e, i, o = t.target; 967 o === this._moveMarker && (e = this._shape.getBounds(), i = e.getCenter(), o.setLatLng(i)), this._toggleCornerMarkers(1), this._repositionCornerMarkers(), L.Edit.SimpleShape.prototype._onMarkerDragEnd.call(this, t) 968 }, 969 _move: function(t) { 970 for (var e, i = this._shape._defaultShape ? this._shape._defaultShape() : this._shape.getLatLngs(), o = this._shape.getBounds(), a = o.getCenter(), n = [], s = 0, r = i.length; s < r; s++) e = [i[s].lat - a.lat, i[s].lng - a.lng], n.push([t.lat + e[0], t.lng + e[1]]); 971 this._shape.setLatLngs(n), this._repositionCornerMarkers(), this._map.fire(L.Draw.Event.EDITMOVE, { 972 layer: this._shape 973 }) 974 }, 975 _resize: function(t) { 976 var e; 977 this._shape.setBounds(L.latLngBounds(t, this._oppositeCorner)), e = this._shape.getBounds(), this._moveMarker.setLatLng(e.getCenter()), this._map.fire(L.Draw.Event.EDITRESIZE, { 978 layer: this._shape 979 }) 980 }, 981 _getCorners: function() { 982 var t = this._shape.getBounds(); 983 return [t.getNorthWest(), t.getNorthEast(), t.getSouthEast(), t.getSouthWest()] 984 }, 985 _toggleCornerMarkers: function(t) { 986 for (var e = 0, i = this._resizeMarkers.length; e < i; e++) this._resizeMarkers[e].setOpacity(t) 987 }, 988 _repositionCornerMarkers: function() { 989 for (var t = this._getCorners(), e = 0, i = this._resizeMarkers.length; e < i; e++) this._resizeMarkers[e].setLatLng(t[e]) 990 } 991 }), L.Rectangle.addInitHook(function() { 992 L.Edit.Rectangle && (this.editing = new L.Edit.Rectangle(this), this.options.editable && this.editing.enable()) 993 }), L.Edit = L.Edit || {}, L.Edit.CircleMarker = L.Edit.SimpleShape.extend({ 994 _createMoveMarker: function() { 995 var t = this._shape.getLatLng(); 996 this._moveMarker = this._createMarker(t, this.options.moveIcon) 997 }, 998 _createResizeMarker: function() { 999 this._resizeMarkers = [] 1000 }, 1001 _move: function(t) { 1002 if (this._resizeMarkers.length) { 1003 var e = this._getResizeMarkerPoint(t); 1004 this._resizeMarkers[0].setLatLng(e) 1005 } 1006 this._shape.setLatLng(t), this._map.fire(L.Draw.Event.EDITMOVE, { 1007 layer: this._shape 1008 }) 1009 } 1010 }), L.CircleMarker.addInitHook(function() { 1011 L.Edit.CircleMarker && (this.editing = new L.Edit.CircleMarker(this), this.options.editable && this.editing.enable()), this.on("add", function() { 1012 this.editing && this.editing.enabled() && this.editing.addHooks() 1013 }), this.on("remove", function() { 1014 this.editing && this.editing.enabled() && this.editing.removeHooks() 1015 }) 1016 }), L.Edit = L.Edit || {}, L.Edit.Circle = L.Edit.CircleMarker.extend({ 1017 _createResizeMarker: function() { 1018 var t = this._shape.getLatLng(), 1019 e = this._getResizeMarkerPoint(t); 1020 this._resizeMarkers = [], this._resizeMarkers.push(this._createMarker(e, this.options.resizeIcon)) 1021 }, 1022 _getResizeMarkerPoint: function(t) { 1023 var e = this._shape._radius * Math.cos(Math.PI / 4), 1024 i = this._map.project(t); 1025 return this._map.unproject([i.x + e, i.y - e]) 1026 }, 1027 _resize: function(t) { 1028 var e = this._moveMarker.getLatLng(); 1029 L.GeometryUtil.isVersion07x() ? radius = e.distanceTo(t) : radius = this._map.distance(e, t), this._shape.setRadius(radius), this._map.editTooltip && this._map._editTooltip.updateContent({ 1030 text: L.drawLocal.edit.handlers.edit.tooltip.subtext + "<br />" + L.drawLocal.edit.handlers.edit.tooltip.text, 1031 subtext: L.drawLocal.draw.handlers.circle.radius + ": " + L.GeometryUtil.readableDistance(radius, !0, this.options.feet, this.options.nautic) 1032 }), this._shape.setRadius(radius), this._map.fire(L.Draw.Event.EDITRESIZE, { 1033 layer: this._shape 1034 }) 1035 } 1036 }), L.Circle.addInitHook(function() { 1037 L.Edit.Circle && (this.editing = new L.Edit.Circle(this), this.options.editable && this.editing.enable()) 1038 }), L.Map.mergeOptions({ 1039 touchExtend: !0 1040 }), L.Map.TouchExtend = L.Handler.extend({ 1041 initialize: function(t) { 1042 this._map = t, this._container = t._container, this._pane = t._panes.overlayPane 1043 }, 1044 addHooks: function() { 1045 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)) 1046 }, 1047 removeHooks: function() { 1048 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)) 1049 }, 1050 _touchEvent: function(t, e) { 1051 var i = {}; 1052 if (void 0 !== t.touches) { 1053 if (!t.touches.length) return; 1054 i = t.touches[0] 1055 } else { 1056 if ("touch" !== t.pointerType) return; 1057 if (i = t, !this._filterClick(t)) return 1058 } 1059 var o = this._map.mouseEventToContainerPoint(i), 1060 a = this._map.mouseEventToLayerPoint(i), 1061 n = this._map.layerPointToLatLng(a); 1062 this._map.fire(e, { 1063 latlng: n, 1064 layerPoint: a, 1065 containerPoint: o, 1066 pageX: i.pageX, 1067 pageY: i.pageY, 1068 originalEvent: t 1069 }) 1070 }, 1071 _filterClick: function(t) { 1072 var e = t.timeStamp || t.originalEvent.timeStamp, 1073 i = L.DomEvent._lastClick && e - L.DomEvent._lastClick; 1074 return i && i > 100 && i < 500 || t.target._simulatedClick && !t._simulated ? (L.DomEvent.stop(t), !1) : (L.DomEvent._lastClick = e, !0) 1075 }, 1076 _onTouchStart: function(t) { 1077 if (this._map._loaded) { 1078 this._touchEvent(t, "touchstart") 1079 } 1080 }, 1081 _onTouchEnd: function(t) { 1082 if (this._map._loaded) { 1083 this._touchEvent(t, "touchend") 1084 } 1085 }, 1086 _onTouchCancel: function(t) { 1087 if (this._map._loaded) { 1088 var e = "touchcancel"; 1089 this._detectIE() && (e = "pointercancel"), this._touchEvent(t, e) 1090 } 1091 }, 1092 _onTouchLeave: function(t) { 1093 if (this._map._loaded) { 1094 this._touchEvent(t, "touchleave") 1095 } 1096 }, 1097 _onTouchMove: function(t) { 1098 if (this._map._loaded) { 1099 this._touchEvent(t, "touchmove") 1100 } 1101 }, 1102 _detectIE: function() { 1103 var e = t.navigator.userAgent, 1104 i = e.indexOf("MSIE "); 1105 if (i > 0) return parseInt(e.substring(i + 5, e.indexOf(".", i)), 10); 1106 if (e.indexOf("Trident/") > 0) { 1107 var o = e.indexOf("rv:"); 1108 return parseInt(e.substring(o + 3, e.indexOf(".", o)), 10) 1109 } 1110 var a = e.indexOf("Edge/"); 1111 return a > 0 && parseInt(e.substring(a + 5, e.indexOf(".", a)), 10) 1112 } 1113 }), L.Map.addInitHook("addHandler", "touchExtend", L.Map.TouchExtend), L.Marker.Touch = L.Marker.extend({ 1114 _initInteraction: function() { 1115 return this.addInteractiveTarget ? L.Marker.prototype._initInteraction.apply(this) : this._initInteractionLegacy() 1116 }, 1117 _initInteractionLegacy: function() { 1118 if (this.options.clickable) { 1119 var t = this._icon, 1120 e = ["dblclick", "mousedown", "mouseover", "mouseout", "contextmenu", "touchstart", "touchend", "touchmove"]; 1121 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); 1122 for (var i = 0; i < e.length; i++) L.DomEvent.on(t, e[i], this._fireMouseEvent, this); 1123 L.Handler.MarkerDrag && (this.dragging = new L.Handler.MarkerDrag(this), this.options.draggable && this.dragging.enable()) 1124 } 1125 }, 1126 _detectIE: function() { 1127 var e = t.navigator.userAgent, 1128 i = e.indexOf("MSIE "); 1129 if (i > 0) return parseInt(e.substring(i + 5, e.indexOf(".", i)), 10); 1130 if (e.indexOf("Trident/") > 0) { 1131 var o = e.indexOf("rv:"); 1132 return parseInt(e.substring(o + 3, e.indexOf(".", o)), 10) 1133 } 1134 var a = e.indexOf("Edge/"); 1135 return a > 0 && parseInt(e.substring(a + 5, e.indexOf(".", a)), 10) 1136 } 1137 }), L.LatLngUtil = { 1138 cloneLatLngs: function(t) { 1139 for (var e = [], i = 0, o = t.length; i < o; i++) Array.isArray(t[i]) ? e.push(L.LatLngUtil.cloneLatLngs(t[i])) : e.push(this.cloneLatLng(t[i])); 1140 return e 1141 }, 1142 cloneLatLng: function(t) { 1143 return L.latLng(t.lat, t.lng) 1144 } 1145 }, 1146 function() { 1147 var t = { 1148 km: 2, 1149 ha: 2, 1150 m: 0, 1151 mi: 2, 1152 ac: 2, 1153 yd: 0, 1154 ft: 0, 1155 nm: 2 1156 }; 1157 L.GeometryUtil = L.extend(L.GeometryUtil || {}, { 1158 geodesicArea: function(t) { 1159 var e, i, o = t.length, 1160 a = 0, 1161 n = Math.PI / 180; 1162 if (o > 2) { 1163 for (var s = 0; s < o; s++) e = t[s], i = t[(s + 1) % o], a += (i.lng - e.lng) * n * (2 + Math.sin(e.lat * n) + Math.sin(i.lat * n)); 1164 a = 6378137 * a * 6378137 / 2 1165 } 1166 return Math.abs(a) 1167 }, 1168 formattedNumber: function(t, e) { 1169 var i = parseFloat(t).toFixed(e), 1170 o = L.drawLocal.format && L.drawLocal.format.numeric, 1171 a = o && o.delimiters, 1172 n = a && a.thousands, 1173 s = a && a.decimal; 1174 if (n || s) { 1175 var r = i.split("."); 1176 i = n ? r[0].replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1" + n) : r[0], s = s || ".", r.length > 1 && (i = i + s + r[1]) 1177 } 1178 return i 1179 }, 1180 readableArea: function(e, i, o) { 1181 var a, n, o = L.Util.extend({}, t, o); 1182 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 1183 }, 1184 readableDistance: function(e, i, o, a, n) { 1185 var s, n = L.Util.extend({}, t, n); 1186 switch (i ? "string" == typeof i ? i : "metric" : o ? "feet" : a ? "nauticalMile" : "yards") { 1187 case "metric": 1188 s = e > 1e3 ? L.GeometryUtil.formattedNumber(e / 1e3, n.km) + " km" : L.GeometryUtil.formattedNumber(e, n.m) + " m"; 1189 break; 1190 case "feet": 1191 e *= 3.28083, s = L.GeometryUtil.formattedNumber(e, n.ft) + " ft"; 1192 break; 1193 case "nauticalMile": 1194 e *= .53996, s = L.GeometryUtil.formattedNumber(e / 1e3, n.nm) + " nm"; 1195 break; 1196 case "yards": 1197 default: 1198 e *= 1.09361, s = e > 1760 ? L.GeometryUtil.formattedNumber(e / 1760, n.mi) + " miles" : L.GeometryUtil.formattedNumber(e, n.yd) + " yd" 1199 } 1200 return s 1201 }, 1202 isVersion07x: function() { 1203 var t = L.version.split("."); 1204 return 0 === parseInt(t[0], 10) && 7 === parseInt(t[1], 10) 1205 } 1206 }) 1207 }(), L.Util.extend(L.LineUtil, { 1208 segmentsIntersect: function(t, e, i, o) { 1209 return this._checkCounterclockwise(t, i, o) !== this._checkCounterclockwise(e, i, o) && this._checkCounterclockwise(t, e, i) !== this._checkCounterclockwise(t, e, o) 1210 }, 1211 _checkCounterclockwise: function(t, e, i) { 1212 return (i.y - t.y) * (e.x - t.x) > (e.y - t.y) * (i.x - t.x) 1213 } 1214 }), L.Polyline.include({ 1215 intersects: function() { 1216 var t, e, i, o = this._getProjectedPoints(), 1217 a = o ? o.length : 0; 1218 if (this._tooFewPointsForIntersection()) return !1; 1219 for (t = a - 1; t >= 3; t--) 1220 if (e = o[t - 1], i = o[t], this._lineSegmentsIntersectsRange(e, i, t - 2)) return !0; 1221 return !1 1222 }, 1223 newLatLngIntersects: function(t, e) { 1224 return !!this._map && this.newPointIntersects(this._map.latLngToLayerPoint(t), e) 1225 }, 1226 newPointIntersects: function(t, e) { 1227 var i = this._getProjectedPoints(), 1228 o = i ? i.length : 0, 1229 a = i ? i[o - 1] : null, 1230 n = o - 2; 1231 return !this._tooFewPointsForIntersection(1) && this._lineSegmentsIntersectsRange(a, t, n, e ? 1 : 0) 1232 }, 1233 _tooFewPointsForIntersection: function(t) { 1234 var e = this._getProjectedPoints(), 1235 i = e ? e.length : 0; 1236 return i += t || 0, !e || i <= 3 1237 }, 1238 _lineSegmentsIntersectsRange: function(t, e, i, o) { 1239 var a, n, s = this._getProjectedPoints(); 1240 o = o || 0; 1241 for (var r = i; r > o; r--) 1242 if (a = s[r - 1], n = s[r], L.LineUtil.segmentsIntersect(t, e, a, n)) return !0; 1243 return !1 1244 }, 1245 _getProjectedPoints: function() { 1246 if (!this._defaultShape) return this._originalPoints; 1247 for (var t = [], e = this._defaultShape(), i = 0; i < e.length; i++) t.push(this._map.latLngToLayerPoint(e[i])); 1248 return t 1249 } 1250 }), L.Polygon.include({ 1251 intersects: function() { 1252 var t, e, i, o, a = this._getProjectedPoints(); 1253 return !this._tooFewPointsForIntersection() && (!!L.Polyline.prototype.intersects.call(this) || (t = a.length, e = a[0], i = a[t - 1], o = t - 2, this._lineSegmentsIntersectsRange(i, e, o, 1))) 1254 } 1255 }), L.Control.Draw = L.Control.extend({ 1256 options: { 1257 position: "topleft", 1258 draw: {}, 1259 edit: !1 1260 }, 1261 initialize: function(t) { 1262 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/"); 1263 L.Control.prototype.initialize.call(this, t); 1264 var e; 1265 this._toolbars = {}, L.DrawToolbar && this.options.draw && (e = new L.DrawToolbar(this.options.draw), this._toolbars[L.DrawToolbar.TYPE] = e, this._toolbars[L.DrawToolbar.TYPE].on("enable", this._toolbarEnabled, this)), L.EditToolbar && this.options.edit && (e = new L.EditToolbar(this.options.edit), this._toolbars[L.EditToolbar.TYPE] = e, this._toolbars[L.EditToolbar.TYPE].on("enable", this._toolbarEnabled, this)), L.toolbar = this 1266 }, 1267 onAdd: function(t) { 1268 var e, i = L.DomUtil.create("div", "leaflet-draw"), 1269 o = !1; 1270 for (var a in this._toolbars) this._toolbars.hasOwnProperty(a) && (e = this._toolbars[a].addToolbar(t)) && (o || (L.DomUtil.hasClass(e, "leaflet-draw-toolbar-top") || L.DomUtil.addClass(e.childNodes[0], "leaflet-draw-toolbar-top"), o = !0), i.appendChild(e)); 1271 return i 1272 }, 1273 onRemove: function() { 1274 for (var t in this._toolbars) this._toolbars.hasOwnProperty(t) && this._toolbars[t].removeToolbar() 1275 }, 1276 setDrawingOptions: function(t) { 1277 for (var e in this._toolbars) this._toolbars[e] instanceof L.DrawToolbar && this._toolbars[e].setOptions(t) 1278 }, 1279 _toolbarEnabled: function(t) { 1280 var e = t.target; 1281 for (var i in this._toolbars) this._toolbars[i] !== e && this._toolbars[i].disable() 1282 } 1283 }), L.Map.mergeOptions({ 1284 drawControlTooltips: !0, 1285 drawControl: !1 1286 }), L.Map.addInitHook(function() { 1287 this.options.drawControl && (this.drawControl = new L.Control.Draw, this.addControl(this.drawControl)) 1288 }), L.Toolbar = L.Class.extend({ 1289 initialize: function(t) { 1290 L.setOptions(this, t), this._modes = {}, this._actionButtons = [], this._activeMode = null; 1291 var e = L.version.split("."); 1292 1 === parseInt(e[0], 10) && parseInt(e[1], 10) >= 2 ? L.Toolbar.include(L.Evented.prototype) : L.Toolbar.include(L.Mixin.Events) 1293 }, 1294 enabled: function() { 1295 return null !== this._activeMode 1296 }, 1297 disable: function() { 1298 this.enabled() && this._activeMode.handler.disable() 1299 }, 1300 addToolbar: function(t) { 1301 var e, i = L.DomUtil.create("div", "leaflet-draw-section"), 1302 o = 0, 1303 a = this._toolbarClass || "", 1304 n = this.getModeHandlers(t); 1305 for (this._toolbarContainer = L.DomUtil.create("div", "leaflet-draw-toolbar leaflet-bar"), this._map = t, e = 0; e < n.length; e++) n[e].enabled && this._initModeHandler(n[e].handler, this._toolbarContainer, o++, a, n[e].title); 1306 if (o) return this._lastButtonIndex = --o, this._actionsContainer = L.DomUtil.create("ul", "leaflet-draw-actions"), i.appendChild(this._toolbarContainer), i.appendChild(this._actionsContainer), i 1307 }, 1308 removeToolbar: function() { 1309 for (var t in this._modes) this._modes.hasOwnProperty(t) && (this._disposeButton(this._modes[t].button, this._modes[t].handler.enable, this._modes[t].handler), this._modes[t].handler.disable(), this._modes[t].handler.off("enabled", this._handlerActivated, this).off("disabled", this._handlerDeactivated, this)); 1310 this._modes = {}; 1311 for (var e = 0, i = this._actionButtons.length; e < i; e++) this._disposeButton(this._actionButtons[e].button, this._actionButtons[e].callback, this); 1312 this._actionButtons = [], this._actionsContainer = null 1313 }, 1314 _initModeHandler: function(t, e, i, o, a) { 1315 var n = t.type; 1316 this._modes[n] = {}, this._modes[n].handler = t, this._modes[n].button = this._createButton({ 1317 type: n, 1318 title: a, 1319 className: o + "-" + n, 1320 container: e, 1321 callback: this._modes[n].handler.enable, 1322 context: this._modes[n].handler 1323 }), this._modes[n].buttonIndex = i, this._modes[n].handler.on("enabled", this._handlerActivated, this).on("disabled", this._handlerDeactivated, this) 1324 }, 1325 _detectIOS: function() { 1326 return /iPad|iPhone|iPod/.test(navigator.userAgent) && !t.MSStream 1327 }, 1328 _createButton: function(t) { 1329 var e = L.DomUtil.create("a", t.className || "", t.container), 1330 i = L.DomUtil.create("span", "sr-only", t.container); 1331 e.href = "#", e.appendChild(i), t.title && (e.title = t.title, i.innerHTML = t.title), t.text && (e.innerHTML = t.text, i.innerHTML = t.text); 1332 var o = this._detectIOS() ? "touchstart" : "click"; 1333 return L.DomEvent.on(e, "click", L.DomEvent.stopPropagation).on(e, "mousedown", L.DomEvent.stopPropagation).on(e, "dblclick", L.DomEvent.stopPropagation).on(e, "touchstart", L.DomEvent.stopPropagation).on(e, "click", L.DomEvent.preventDefault).on(e, o, t.callback, t.context), e 1334 }, 1335 _disposeButton: function(t, e) { 1336 var i = this._detectIOS() ? "touchstart" : "click"; 1337 L.DomEvent.off(t, "click", L.DomEvent.stopPropagation).off(t, "mousedown", L.DomEvent.stopPropagation).off(t, "dblclick", L.DomEvent.stopPropagation).off(t, "touchstart", L.DomEvent.stopPropagation).off(t, "click", L.DomEvent.preventDefault).off(t, i, e) 1338 }, 1339 _handlerActivated: function(t) { 1340 this.disable(), this._activeMode = this._modes[t.handler], L.DomUtil.addClass(this._activeMode.button, "leaflet-draw-toolbar-button-enabled"), this._showActionsToolbar(), this.fire("enable") 1341 }, 1342 _handlerDeactivated: function() { 1343 this._hideActionsToolbar(), L.DomUtil.removeClass(this._activeMode.button, "leaflet-draw-toolbar-button-enabled"), this._activeMode = null, this.fire("disable") 1344 }, 1345 _createActions: function(t) { 1346 var e, i, o, a, n = this._actionsContainer, 1347 s = this.getActions(t), 1348 r = s.length; 1349 for (i = 0, o = this._actionButtons.length; i < o; i++) this._disposeButton(this._actionButtons[i].button, this._actionButtons[i].callback); 1350 for (this._actionButtons = []; n.firstChild;) n.removeChild(n.firstChild); 1351 for (var l = 0; l < r; l++) "enabled" in s[l] && !s[l].enabled || (e = L.DomUtil.create("li", "", n), a = this._createButton({ 1352 title: s[l].title, 1353 text: s[l].text, 1354 container: e, 1355 callback: s[l].callback, 1356 context: s[l].context 1357 }), this._actionButtons.push({ 1358 button: a, 1359 callback: s[l].callback 1360 })) 1361 }, 1362 _showActionsToolbar: function() { 1363 var t = this._activeMode.buttonIndex, 1364 e = this._lastButtonIndex, 1365 i = this._activeMode.button.offsetTop - 1; 1366 this._createActions(this._activeMode.handler), this._actionsContainer.style.top = i + "px", 0 === t && (L.DomUtil.addClass(this._toolbarContainer, "leaflet-draw-toolbar-notop"), L.DomUtil.addClass(this._actionsContainer, "leaflet-draw-actions-top")), t === e && (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) 1367 }, 1368 _hideActionsToolbar: function() { 1369 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) 1370 } 1371 }), L.Draw = L.Draw || {}, L.Draw.Tooltip = L.Class.extend({ 1372 initialize: function(t) { 1373 this._map = t, this._popupPane = t._panes.popupPane, this._visible = !1, this._container = t.options.drawControlTooltips ? L.DomUtil.create("div", "leaflet-draw-tooltip", this._popupPane) : null, this._singleLineLabel = !1, this._map.on("mouseout", this._onMouseOut, this) 1374 }, 1375 dispose: function() { 1376 this._map.off("mouseout", this._onMouseOut, this), this._container && (this._popupPane.removeChild(this._container), this._container = null) 1377 }, 1378 updateContent: function(t) { 1379 return this._container ? (t.subtext = t.subtext || "", 0 !== t.subtext.length || this._singleLineLabel ? t.subtext.length > 0 && 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 ? '<span class="leaflet-draw-tooltip-subtext">' + t.subtext + "</span><br />" : "") + "<span>" + t.text + "</span>", t.text || t.subtext ? (this._visible = !0, this._container.style.visibility = "inherit") : (this._visible = !1, this._container.style.visibility = "hidden"), this) : this 1380 }, 1381 updatePosition: function(t) { 1382 var e = this._map.latLngToLayerPoint(t), 1383 i = this._container; 1384 return this._container && (this._visible && (i.style.visibility = "inherit"), L.DomUtil.setPosition(i, e)), this 1385 }, 1386 showAsError: function() { 1387 return this._container && L.DomUtil.addClass(this._container, "leaflet-error-draw-tooltip"), this 1388 }, 1389 removeError: function() { 1390 return this._container && L.DomUtil.removeClass(this._container, "leaflet-error-draw-tooltip"), this 1391 }, 1392 _onMouseOut: function() { 1393 this._container && (this._container.style.visibility = "hidden") 1394 } 1395 }), L.DrawToolbar = L.Toolbar.extend({ 1396 statics: { 1397 TYPE: "draw" 1398 }, 1399 options: { 1400 polyline: {}, 1401 polygon: {}, 1402 rectangle: {}, 1403 circle: {}, 1404 marker: {}, 1405 circlemarker: {} 1406 }, 1407 initialize: function(t) { 1408 for (var e in this.options) this.options.hasOwnProperty(e) && t[e] && (t[e] = L.extend({}, this.options[e], t[e])); 1409 this._toolbarClass = "leaflet-draw-draw", L.Toolbar.prototype.initialize.call(this, t) 1410 }, 1411 getModeHandlers: function(t) { 1412 return [{ 1413 enabled: this.options.polyline, 1414 handler: new L.Draw.Polyline(t, this.options.polyline), 1415 title: L.drawLocal.draw.toolbar.buttons.polyline 1416 }, { 1417 enabled: this.options.polygon, 1418 handler: new L.Draw.Polygon(t, this.options.polygon), 1419 title: L.drawLocal.draw.toolbar.buttons.polygon 1420 }, { 1421 enabled: this.options.rectangle, 1422 handler: new L.Draw.Rectangle(t, this.options.rectangle), 1423 title: L.drawLocal.draw.toolbar.buttons.rectangle 1424 }, { 1425 enabled: this.options.circle, 1426 handler: new L.Draw.Circle(t, this.options.circle), 1427 title: L.drawLocal.draw.toolbar.buttons.circle 1428 }, { 1429 enabled: this.options.marker, 1430 handler: new L.Draw.Marker(t, this.options.marker), 1431 title: L.drawLocal.draw.toolbar.buttons.marker 1432 }, { 1433 enabled: this.options.circlemarker, 1434 handler: new L.Draw.CircleMarker(t, this.options.circlemarker), 1435 title: L.drawLocal.draw.toolbar.buttons.circlemarker 1436 }] 1437 }, 1438 getActions: function(t) { 1439 return [{ 1440 enabled: t.completeShape, 1441 title: L.drawLocal.draw.toolbar.finish.title, 1442 text: L.drawLocal.draw.toolbar.finish.text, 1443 callback: t.completeShape, 1444 context: t 1445 }, { 1446 enabled: t.deleteLastVertex, 1447 title: L.drawLocal.draw.toolbar.undo.title, 1448 text: L.drawLocal.draw.toolbar.undo.text, 1449 callback: t.deleteLastVertex, 1450 context: t 1451 }, { 1452 title: L.drawLocal.draw.toolbar.actions.title, 1453 text: L.drawLocal.draw.toolbar.actions.text, 1454 callback: this.disable, 1455 context: this 1456 }] 1457 }, 1458 setOptions: function(t) { 1459 L.setOptions(this, t); 1460 for (var e in this._modes) this._modes.hasOwnProperty(e) && t.hasOwnProperty(e) && this._modes[e].handler.setOptions(t[e]) 1461 } 1462 }), L.EditToolbar = L.Toolbar.extend({ 1463 statics: { 1464 TYPE: "edit" 1465 }, 1466 options: { 1467 edit: { 1468 selectedPathOptions: { 1469 dashArray: "10, 10", 1470 fill: !0, 1471 fillColor: "#fe57a1", 1472 fillOpacity: .1, 1473 maintainColor: !1 1474 } 1475 }, 1476 remove: {}, 1477 poly: null, 1478 featureGroup: null 1479 }, 1480 initialize: function(t) { 1481 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 1482 }, 1483 getModeHandlers: function(t) { 1484 var e = this.options.featureGroup; 1485 return [{ 1486 enabled: this.options.edit, 1487 handler: new L.EditToolbar.Edit(t, { 1488 featureGroup: e, 1489 selectedPathOptions: this.options.edit.selectedPathOptions, 1490 poly: this.options.poly 1491 }), 1492 title: L.drawLocal.edit.toolbar.buttons.edit 1493 }, { 1494 enabled: this.options.remove, 1495 handler: new L.EditToolbar.Delete(t, { 1496 featureGroup: e 1497 }), 1498 title: L.drawLocal.edit.toolbar.buttons.remove 1499 }] 1500 }, 1501 getActions: function(t) { 1502 var e = [{ 1503 title: L.drawLocal.edit.toolbar.actions.save.title, 1504 text: L.drawLocal.edit.toolbar.actions.save.text, 1505 callback: this._save, 1506 context: this 1507 }, { 1508 title: L.drawLocal.edit.toolbar.actions.cancel.title, 1509 text: L.drawLocal.edit.toolbar.actions.cancel.text, 1510 callback: this.disable, 1511 context: this 1512 }]; 1513 return t.removeAllLayers && e.push({ 1514 title: L.drawLocal.edit.toolbar.actions.clearAll.title, 1515 text: L.drawLocal.edit.toolbar.actions.clearAll.text, 1516 callback: this._clearAllLayers, 1517 context: this 1518 }), e 1519 }, 1520 addToolbar: function(t) { 1521 var e = L.Toolbar.prototype.addToolbar.call(this, t); 1522 return this._checkDisabled(), this.options.featureGroup.on("layeradd layerremove", this._checkDisabled, this), e 1523 }, 1524 removeToolbar: function() { 1525 this.options.featureGroup.off("layeradd layerremove", this._checkDisabled, this), L.Toolbar.prototype.removeToolbar.call(this) 1526 }, 1527 disable: function() { 1528 this.enabled() && (this._activeMode.handler.revertLayers(), L.Toolbar.prototype.disable.call(this)) 1529 }, 1530 _save: function() { 1531 this._activeMode.handler.save(), this._activeMode && this._activeMode.handler.disable() 1532 }, 1533 _clearAllLayers: function() { 1534 this._activeMode.handler.removeAllLayers(), this._activeMode && this._activeMode.handler.disable() 1535 }, 1536 _checkDisabled: function() { 1537 var t, e = this.options.featureGroup, 1538 i = 0 !== e.getLayers().length; 1539 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)) 1540 } 1541 }), L.EditToolbar.Edit = L.Handler.extend({ 1542 statics: { 1543 TYPE: "edit" 1544 }, 1545 initialize: function(t, e) { 1546 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"); 1547 this._uneditedLayerProps = {}, this.type = L.EditToolbar.Edit.TYPE; 1548 var i = L.version.split("."); 1549 1 === parseInt(i[0], 10) && parseInt(i[1], 10) >= 2 ? L.EditToolbar.Edit.include(L.Evented.prototype) : L.EditToolbar.Edit.include(L.Mixin.Events) 1550 }, 1551 enable: function() { 1552 !this._enabled && this._hasAvailableLayers() && (this.fire("enabled", { 1553 handler: this.type 1554 }), this._map.fire(L.Draw.Event.EDITSTART, { 1555 handler: this.type 1556 }), L.Handler.prototype.enable.call(this), this._featureGroup.on("layeradd", this._enableLayerEdit, this).on("layerremove", this._disableLayerEdit, this)) 1557 }, 1558 disable: function() { 1559 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, { 1560 handler: this.type 1561 }), this.fire("disabled", { 1562 handler: this.type 1563 })) 1564 }, 1565 addHooks: function() { 1566 var t = this._map; 1567 t && (t.getContainer().focus(), this._featureGroup.eachLayer(this._enableLayerEdit, this), this._tooltip = new L.Draw.Tooltip(this._map), this._tooltip.updateContent({ 1568 text: L.drawLocal.edit.handlers.edit.tooltip.text, 1569 subtext: L.drawLocal.edit.handlers.edit.tooltip.subtext 1570 }), 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)) 1571 }, 1572 removeHooks: function() { 1573 this._map && (this._featureGroup.eachLayer(this._disableLayerEdit, this), 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)) 1574 }, 1575 revertLayers: function() { 1576 this._featureGroup.eachLayer(function(t) { 1577 this._revertLayer(t) 1578 }, this) 1579 }, 1580 save: function() { 1581 var t = new L.LayerGroup; 1582 this._featureGroup.eachLayer(function(e) { 1583 e.edited && (t.addLayer(e), e.edited = !1) 1584 }), this._map.fire(L.Draw.Event.EDITED, { 1585 layers: t 1586 }) 1587 }, 1588 _backupLayer: function(t) { 1589 var e = L.Util.stamp(t); 1590 this._uneditedLayerProps[e] || (t instanceof L.Polyline || t instanceof L.Polygon || t instanceof L.Rectangle ? this._uneditedLayerProps[e] = { 1591 latlngs: L.LatLngUtil.cloneLatLngs(t.getLatLngs()) 1592 } : t instanceof L.Circle ? this._uneditedLayerProps[e] = { 1593 latlng: L.LatLngUtil.cloneLatLng(t.getLatLng()), 1594 radius: t.getRadius() 1595 } : (t instanceof L.Marker || t instanceof L.CircleMarker) && (this._uneditedLayerProps[e] = { 1596 latlng: L.LatLngUtil.cloneLatLng(t.getLatLng()) 1597 })) 1598 }, 1599 _getTooltipText: function() { 1600 return { 1601 text: L.drawLocal.edit.handlers.edit.tooltip.text, 1602 subtext: L.drawLocal.edit.handlers.edit.tooltip.subtext 1603 } 1604 }, 1605 _updateTooltip: function() { 1606 this._tooltip.updateContent(this._getTooltipText()) 1607 }, 1608 _revertLayer: function(t) { 1609 var e = L.Util.stamp(t); 1610 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", { 1611 layer: t 1612 })) 1613 }, 1614 _enableLayerEdit: function(t) { 1615 var e, i, o = t.layer || t.target || t; 1616 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() 1617 }, 1618 _disableLayerEdit: function(t) { 1619 var e = t.layer || t.target || t; 1620 e.edited = !1, e.editing && e.editing.disable(), delete e.options.editing, delete e.options.original, 1621 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() 1622 }, 1623 _onMouseMove: function(t) { 1624 this._tooltip.updatePosition(t.latlng) 1625 }, 1626 _onMarkerDragEnd: function(t) { 1627 var e = t.target; 1628 e.edited = !0, this._map.fire(L.Draw.Event.EDITMOVE, { 1629 layer: e 1630 }) 1631 }, 1632 _onTouchMove: function(t) { 1633 var e = t.originalEvent.changedTouches[0], 1634 i = this._map.mouseEventToLayerPoint(e), 1635 o = this._map.layerPointToLatLng(i); 1636 t.target.setLatLng(o) 1637 }, 1638 _hasAvailableLayers: function() { 1639 return 0 !== this._featureGroup.getLayers().length 1640 } 1641 }), L.EditToolbar.Delete = L.Handler.extend({ 1642 statics: { 1643 TYPE: "remove" 1644 }, 1645 initialize: function(t, e) { 1646 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"); 1647 this.type = L.EditToolbar.Delete.TYPE; 1648 var i = L.version.split("."); 1649 1 === parseInt(i[0], 10) && parseInt(i[1], 10) >= 2 ? L.EditToolbar.Delete.include(L.Evented.prototype) : L.EditToolbar.Delete.include(L.Mixin.Events) 1650 }, 1651 enable: function() { 1652 !this._enabled && this._hasAvailableLayers() && (this.fire("enabled", { 1653 handler: this.type 1654 }), this._map.fire(L.Draw.Event.DELETESTART, { 1655 handler: this.type 1656 }), L.Handler.prototype.enable.call(this), this._deletableLayers.on("layeradd", this._enableLayerDelete, this).on("layerremove", this._disableLayerDelete, this)) 1657 }, 1658 disable: function() { 1659 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, { 1660 handler: this.type 1661 }), this.fire("disabled", { 1662 handler: this.type 1663 })) 1664 }, 1665 addHooks: function() { 1666 var t = this._map; 1667 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({ 1668 text: L.drawLocal.edit.handlers.remove.tooltip.text 1669 }), this._map.on("mousemove", this._onMouseMove, this)) 1670 }, 1671 removeHooks: function() { 1672 this._map && (this._deletableLayers.eachLayer(this._disableLayerDelete, this), this._deletedLayers = null, this._tooltip.dispose(), this._tooltip = null, this._map.off("mousemove", this._onMouseMove, this)) 1673 }, 1674 revertLayers: function() { 1675 this._deletedLayers.eachLayer(function(t) { 1676 this._deletableLayers.addLayer(t), t.fire("revert-deleted", { 1677 layer: t 1678 }) 1679 }, this) 1680 }, 1681 save: function() { 1682 this._map.fire(L.Draw.Event.DELETED, { 1683 layers: this._deletedLayers 1684 }) 1685 }, 1686 removeAllLayers: function() { 1687 this._deletableLayers.eachLayer(function(t) { 1688 this._removeLayer({ 1689 layer: t 1690 }) 1691 }, this), this.save() 1692 }, 1693 _enableLayerDelete: function(t) { 1694 (t.layer || t.target || t).on("click", this._removeLayer, this) 1695 }, 1696 _disableLayerDelete: function(t) { 1697 var e = t.layer || t.target || t; 1698 e.off("click", this._removeLayer, this), this._deletedLayers.removeLayer(e) 1699 }, 1700 _removeLayer: function(t) { 1701 var e = t.layer || t.target || t; 1702 this._deletableLayers.removeLayer(e), this._deletedLayers.addLayer(e), e.fire("deleted") 1703 }, 1704 _onMouseMove: function(t) { 1705 this._tooltip.updatePosition(t.latlng) 1706 }, 1707 _hasAvailableLayers: function() { 1708 return 0 !== this._deletableLayers.getLayers().length 1709 } 1710 }) 1711}(window, document);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.