node-red-contrib-snap4city-user
Version:
Nodes for Snap4city project, targeted to standard user (no developer)
871 lines (870 loc) • 102 kB
JavaScript
/*
Leaflet.draw 1.0.2, 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.2", 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: "<strong>Error:</strong> 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._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)); l < n; l += this.options.guidelineDistance) i = l / n, o = {
x: Math.floor(t.x * (1 - i) + i * e.x),
y: Math.floor(t.y * (1 - i) + i * e.y)
}, 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)
},
_updateGuideColor: function (t) {
if (this._guidesContainer)
for (var e = 0, i = this._guidesContainer.childNodes.length; e < i; e++) this._guidesContainer.childNodes[e].style.backgroundColor = t
},
_clearGuides: function () {
if (this._guidesContainer)
for (; this._guidesContainer.firstChild;) this._guidesContainer.removeChild(this._guidesContainer.firstChild)
},
_getTooltipText: function () {
var t, e, i = this.options.showLength;
return 0 === this._markers.length ? t = {
text: L.drawLocal.draw.handlers.polyline.tooltip.start
} : (e = i ? this._getMeasurementString() : "", t = 1 === this._markers.length ? {
text: L.drawLocal.draw.handlers.polyline.tooltip.cont,
subtext: e
} : {
text: L.drawLocal.draw.handlers.polyline.tooltip.end,
subtext: e
}), t
},
_updateRunningMeasure: function (t, e) {
var i, o, a = this._markers.length;
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))
},
_getMeasurementString: function () {
var t, e = this._currentLatLng,
i = this._markers[this._markers.length - 1].getLatLng();
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)
},
_showErrorTooltip: function () {
this._errorShown = !0, this._tooltip.showAsError().updateContent({
text: this.options.drawError.message
}), this._updateGuideColor(this.options.drawError.color), this._poly.setStyle({
color: this.options.drawError.color
}), this._clearHideErrorTimeout(), this._hideErrorTimeout = setTimeout(L.Util.bind(this._hideErrorTooltip, this), this.options.drawError.timeout)
},
_hideErrorTooltip: function () {
this._errorShown = !1, this._clearHideErrorTimeout(), this._tooltip.removeError().updateContent(this._getTooltipText()), this._updateGuideColor(this.options.shapeOptions.color), this._poly.setStyle({
color: this.options.shapeOptions.color
})
},
_clearHideErrorTimeout: function () {
this._hideErrorTimeout && (clearTimeout(this._hideErrorTimeout), this._hideErrorTimeout = null)
},
_disableNewMarkers: function () {
this._disableMarkers = !0
},
_enableNewMarkers: function () {
setTimeout(function () {
this._disableMarkers = !1
}.bind(this), 50)
},
_cleanUpShape: function () {
this._markers.length > 1 && 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 += "<br>" + 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,
showArea: !0,
clickable: !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; e < this._verticesHandlers.length; e++) t(this._verticesHandlers[e])
},
addHooks: function () {
this._initHandlers(), this._eachVertexHandler(function (t) {
t.addHooks()
})
},
removeHooks: function () {
this._eachVertexHandler(function (t) {
t.removeHooks()
})
},
updateMarkers: function () {
this._eachVertexHandler(function (t) {
t.updateMarkers()
})
},
_initHandlers: function () {
this._verticesHandlers = [];
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))
},
_updateLatLngs: function (t) {
this.latlngs = [t.layer._latlngs], t.layer._holes && (this.latlngs = this.latlngs.concat(t.layer._holes))
}
}), 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: 1e3
}
},
initialize: function (t, e, i) {
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)
},
_defaultShape: function () {
return L.Polyline._flat ? L.Polyline._flat(this._latlngs) ? this._latlngs : this._latlngs[0] : this._latlngs
},
addHooks: function () {
var t = this._poly,
e = t._path;
t instanceof L.Polygon || (t.options.fill = !1, t.options.editing && (t.options.editing.fill = !1)), e && t.options.editing.className && (t.options.original.className && t.options.original.className.split(" ").forEach(function (t) {
L.DomUtil.removeClass(e, t)
}), t.options.editing.className.split(" ").forEach(function (t) {
L.DomUtil.addClass(e, t)
})), t.setStyle(t.options.editing), this._poly._map && (this._map = this._poly._map, this._markerGroup || this._initMarkers(), this._poly._map.addLayer(this._markerGroup))
},
removeHooks: function () {
var t = this._poly,
e = t._path;
e && t.options.editing.className && (t.options.editing.className.split(" ").forEach(function (t) {
L.DomUtil.removeClass(e, t)
}), t.options.original.className && t.options.original.className.split(" ").forEach(function (t) {
L.DomUtil.addClass(e, t)
})), t.setStyle(t.options.original), t._map && (t._map.removeLayer(this._markerGroup), delete this._markerGroup, delete this._markers)
},
updateMarkers: function () {
this._markerGroup.clearLayers(), this._initMarkers()
},
_initMarkers: function () {
this._markerGroup || (this._markerGroup = new L.LayerGroup), this._markers = [];
var t, e, i, o, a = this._defaultShape();
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);
var n, s;
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))
},
_createMarker: function (t, e) {
var i = new L.Marker.Touch(t, {
draggable: !0,
icon: this.options.icon
});
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
},
_onMarkerDragStart: function () {
this._poly.fire("editstart")
},
_spliceLatLngs: function () {
var t = this._defaultShape(),
e = [].splice.apply(t, arguments);
return this._poly._convertLatLngs(t, !0), this._poly.redraw(), e
},
_removeMarker: function (t) {
var e = t._index;
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)
},
_fireEdit: function () {
this._poly.edited = !0, this._poly.fire("edit"), this._poly._map.fire(L.Draw.Event.EDITVERTEX, {
layers: this._markerGroup,
poly: this._poly
})
},
_onMarkerDrag: function (t) {
var e = t.target,
i = this._poly;
if (L.extend(e._origLatLng, e._latlng), e._middleLeft && e._middleLeft.setLatLng(this._getMiddleLatLng(e._prev, e)), e._middleRight && e._middleRight.setLatLng(this._getMiddleLatLng(e, e._next)), i.options.poly) {
var o = i._map._editTooltip;
if (!i.options.poly.allowIntersection && i.intersects()) {
var a = i.options.color;
i.setStyle({
color: this.options.drawError.color
}), 0 !== L.version.indexOf("0.7") && e.dragging._draggable._onUp(t), this._onMarkerClick(t), o && o.updateContent({
text: L.drawLocal.draw.handlers.polyline.error
}), setTimeout(function () {
i.setStyle({
color: a
}), o && o.updateContent({
text: L.drawLocal.edit.handlers.edit.tooltip.text,
subtext: L.drawLocal.edit.handlers.edit.tooltip.subtext
})
}, 1e3)
}
}
this._poly._bounds._southWest = L.latLng(1 / 0, 1 / 0), this._poly._bounds._northEast = L.latLng(-1 / 0, -1 / 0);
var n = this._poly.getLatLngs();
this._poly._convertLatLngs(n, !0), this._poly.redraw(), this._poly.fire("editdrag")
},
_onMarkerClick: function (t) {
var e = L.Polygon && this._poly instanceof L.Polygon ? 4 : 3,
i = t.target;
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())
},
_onContextMenu: function (t) {
var e = t.target;
this._poly;
this._poly._map.fire(L.Draw.Event.MARKERCONTEXT, {
marker: e,
layers: this._markerGroup,
poly: this._poly
}), L.DomEvent.stopPropagation
},
_onTouchMove: function (t) {
var e = this._map.mouseEventToLayerPoint(t.originalEvent.touches[0]),
i = this._map.layerPointToLatLng(e),
o = t.target;
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()
},
_updateIndexes: function (t, e) {
this._markerGroup.eachLayer(function (i) {
i._index > t && (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-d