diff --git a/.github/ISSUE_TEMPLATE/--first-timers-issue-template.md b/.github/ISSUE_TEMPLATE/--first-timers-issue-template.md
index b884466ce..4f2e0045c 100644
--- a/.github/ISSUE_TEMPLATE/--first-timers-issue-template.md
+++ b/.github/ISSUE_TEMPLATE/--first-timers-issue-template.md
@@ -1,3 +1,18 @@
+---
+name: "\U00002728 First Timers Only issue"
+about: Open a First Timers Only issue for someone
+title: ''
+labels: fto-candidate
+assignees: ''
+
+---
+
+### 💡Format this Issue Into a First Timers Issue
+
+This has been marked as a good candidate for becoming a [first-timers-only issue](https://code.publiclab.org/#r=all) like these, meaning that it's **simple, self-contained**, and with some extra formatting✍️, could be a great entry point for a new contributor. If you're familiar enough with this code, please consider **reformatting it as a first-timers-only issue**, and then ping @publiclab/reviewers to get it labeled🏷. Or, if this is not your first time, **try to solve it yourself**🧑💻!
+
+---
+
Hi, this is a [first-timers-only issue](https://code.publiclab.org/#r=all). This means we've worked to make it more legible to folks who either **haven't contributed to our codebase before, or even folks who haven't contributed to open source before**.
If that's you, we're interested in helping you take the first step and can answer questions and help you out as you do. Note that we're especially interested in contributions from people from underrepresented groups in free and open-source software!
diff --git a/.github/first-timers-issue-template.md b/.github/first-timers-issue-template.md
index b884466ce..a3d3eca02 100644
--- a/.github/first-timers-issue-template.md
+++ b/.github/first-timers-issue-template.md
@@ -50,6 +50,6 @@ Leave a comment below!
### Is someone else already working on this?
-We encourage you to link to this issue by mentioning the issue # in your pull request, so we can see if someone's already started on it. **If someone seem stuck, offer them some help!** Otherwise, [take a look at some other issues you can help with](https://publiclab.github.io/community-toolbox/#r=all). Thanks!
+We encourage you to link to this issue by mentioning the issue # in your pull request, so we can see if someone's already started on it. **If someone seems stuck, offer them some help!** Otherwise, [take a look at some other issues you can help with](https://publiclab.github.io/community-toolbox/#r=all). Thanks!
(This issue was created by [First-Timers-Bot](https://github.com/hoodiehq/first-timers-bot).)
diff --git a/README.md b/README.md
index 56f356fc4..472a8b403 100644
--- a/README.md
+++ b/README.md
@@ -32,6 +32,10 @@ npm i leaflet-distortableimage
Compatible with Leaflet 1.0.0 and greater
+ ### MapKnitter Lite
+
+Check out an early prototype of the [Mapknitter Lite project](https://publiclab.github.io/Leaflet.DistortableImage/examples/archive)
+
## Demo
Check out this [simple demo](https://publiclab.github.io/Leaflet.DistortableImage/examples/index.html).
@@ -165,7 +169,7 @@ Values available to pass to `mode` are:
* **freeRotate**: Combines the rotate and scale modes into one.
* **lock**: Locks the image in place. Disables any user gestures, toolbar actions, or hotkeys that are not associated with mode. Exception: `L.ExportAction` will still be enabled.
-In the below example, the image will be initialiazed with "freeRotate" handles:
+In the below example, the image will be initialized with "freeRotate" handles:
```js
img = L.distortableImageOverlay('example.jpg', {
diff --git a/dist/leaflet.distortableimage.js b/dist/leaflet.distortableimage.js
index 84da547da..74f79597c 100644
--- a/dist/leaflet.distortableimage.js
+++ b/dist/leaflet.distortableimage.js
@@ -1,2884 +1,8292 @@
-!(function () {
- var t = {
- 808: function () {
- (L.DistortableCollection = L.FeatureGroup.extend({
- options: {
- editable: !0,
- exportOpts: {
- exportStartUrl: "//export.mapknitter.org/export",
- statusUrl: "//export.mapknitter.org",
- exportUrl: "http://export.mapknitter.org/",
- },
- },
- initialize: function (t) {
- L.setOptions(this, t),
- L.FeatureGroup.prototype.initialize.call(this, t),
- L.Utils.initTranslation.call(this),
- (this.editable = this.options.editable);
- },
- onAdd: function (t) {
- L.FeatureGroup.prototype.onAdd.call(this, t),
- (this._map = t),
- this.editable && this.editing.enable(),
- this.on("layeradd", this._addEvents, this),
- this.on("layerremove", this._removeEvents, this);
- },
- onRemove: function () {
- this.editing && this.editing.disable(),
- this.off("layeradd", this._addEvents, this),
- this.off("layerremove", this._removeEvents, this);
- },
- _addEvents: function (t) {
- var e = t.layer;
- L.DomEvent.on(
- e,
- { dragstart: this._dragStartMultiple, drag: this._dragMultiple },
- this
- ),
- L.DomEvent.on(
- e.getElement(),
- {
- mousedown: this._deselectOthers,
- contextmenu: this._longPressMultiSelect,
- },
- this
- );
- },
- _removeEvents: function (t) {
- var e = t.layer;
- L.DomEvent.off(
- e,
- { dragstart: this._dragStartMultiple, drag: this._dragMultiple },
- this
- ),
- L.DomEvent.off(
- e.getElement(),
- {
- mousedown: this._deselectOthers,
- contextmenu: this._longPressMultiSelect,
- },
- this
- );
- },
- _longPressMultiSelect: function (t) {
- var e = this;
- this.editable &&
- (t.preventDefault(),
- this.eachLayer(function (i) {
- var o = i.editing;
- i.getElement() === t.target &&
- o.enabled() &&
- (L.DomUtil.toggleClass(i.getElement(), "collected"),
- e.anyCollected()
- ? (i.deselect(), e.editing._addToolbar())
- : e.editing._removeToolbar());
- }));
- },
- isCollected: function (t) {
- return L.DomUtil.hasClass(t.getElement(), "collected");
- },
- anyCollected: function () {
- return this.getLayers().some(this.isCollected.bind(this));
- },
- _toggleCollected: function (t, e) {
- t.shiftKey &&
- e.editing.enabled() &&
- L.DomUtil.toggleClass(t.target, "collected"),
- this.anyCollected() ? e.deselect() : this.editing._removeToolbar();
- },
- _deselectOthers: function (t) {
- var e = this;
- this.editable &&
- (this.eachLayer(function (i) {
- i.getElement() !== t.target
- ? i.deselect()
- : e._toggleCollected(t, i);
- }),
- t && L.DomEvent.stopPropagation(t));
- },
- _dragStartMultiple: function (t) {
- var e,
- i = t.target,
- o = this._map;
- this.isCollected(i) &&
- this.eachLayer(function (t) {
- for (t._dragStartPoints = {}, t.deselect(), e = 0; e < 4; e++) {
- var i = t.getCorner(e);
- t._dragStartPoints[e] = o.latLngToLayerPoint(i);
- }
- });
- },
- _dragMultiple: function (t) {
- var e = t.target,
- i = this._map;
- if (this.isCollected(e)) {
- var o = i.latLngToLayerPoint(e.getCorner(0)),
- n = e._dragStartPoints[0].subtract(o);
- this._updateCollectionFromPoints(n, e);
- }
- },
- _toRemove: function () {
- var t = this;
- return this.getLayers().filter(function (e) {
- var i = e.editing._mode;
- return t.isCollected(e) && "lock" !== i;
- });
- },
- _toMove: function (t) {
- var e = this;
- return this.getLayers().filter(function (i) {
- var o = i.editing._mode;
- return i !== t && e.isCollected(i) && "lock" !== o;
- });
- },
- _updateCollectionFromPoints: function (t, e) {
- var i,
- o = this._toMove(e),
- n = new L.Transformation(1, -t.x, 1, -t.y);
- o.forEach(function (t) {
- var e = {};
- for (i = 0; i < 4; i++) e[i] = n.transform(t._dragStartPoints[i]);
- t.setCornersFromPoints(e);
- });
- },
- _getAvgCmPerPixel: function (t) {
- return (
- t.reduce(function (t, e) {
- return t + e.cm_per_pixel;
- }, 0) / t.length
- );
- },
- generateExportJson: function () {
- var t = { images: [] };
- return (
- this.eachLayer(function (e) {
- if (this.isCollected(e)) {
- var i = e._image.src.split("/"),
- o = i[i.length - 1],
- n = e.getCorners(),
- a = [
- { lat: n[0].lat, lon: n[0].lng },
- { lat: n[1].lat, lon: n[1].lng },
- { lat: n[3].lat, lon: n[3].lng },
- { lat: n[2].lat, lon: n[2].lng },
- ];
- t.images.push({
- id: this.getLayerId(e),
- src: e._image.src,
- width: e._image.width,
- height: e._image.height,
- image_file_name: o,
- nodes: a,
- cm_per_pixel: L.ImageUtil.getCmPerPixel(e),
- });
- }
- }, this),
- (t.images = t.images.reverse()),
- (t.avg_cm_per_pixel = this._getAvgCmPerPixel(t.images)),
- t
- );
- },
- })),
- (L.distortableCollection = function (t, e) {
- return new L.DistortableCollection(t, e);
+/******/ (function() { // webpackBootstrap
+/******/ var __webpack_modules__ = ({
+
+/***/ "./node_modules/ansi-html-community/index.js":
+/*!***************************************************!*\
+ !*** ./node_modules/ansi-html-community/index.js ***!
+ \***************************************************/
+/***/ (function(module) {
+
+"use strict";
+
+
+module.exports = ansiHTML
+
+// Reference to https://github.com/sindresorhus/ansi-regex
+var _regANSI = /(?:(?:\u001b\[)|\u009b)(?:(?:[0-9]{1,3})?(?:(?:;[0-9]{0,3})*)?[A-M|f-m])|\u001b[A-M]/
+
+var _defColors = {
+ reset: ['fff', '000'], // [FOREGROUD_COLOR, BACKGROUND_COLOR]
+ black: '000',
+ red: 'ff0000',
+ green: '209805',
+ yellow: 'e8bf03',
+ blue: '0000ff',
+ magenta: 'ff00ff',
+ cyan: '00ffee',
+ lightgrey: 'f0f0f0',
+ darkgrey: '888'
+}
+var _styles = {
+ 30: 'black',
+ 31: 'red',
+ 32: 'green',
+ 33: 'yellow',
+ 34: 'blue',
+ 35: 'magenta',
+ 36: 'cyan',
+ 37: 'lightgrey'
+}
+var _openTags = {
+ '1': 'font-weight:bold', // bold
+ '2': 'opacity:0.5', // dim
+ '3': '', // italic
+ '4': '', // underscore
+ '8': 'display:none', // hidden
+ '9': '' // delete
+}
+var _closeTags = {
+ '23': '', // reset italic
+ '24': '', // reset underscore
+ '29': '' // reset delete
+}
+
+;[0, 21, 22, 27, 28, 39, 49].forEach(function (n) {
+ _closeTags[n] = ''
+})
+
+/**
+ * Converts text with ANSI color codes to HTML markup.
+ * @param {String} text
+ * @returns {*}
+ */
+function ansiHTML (text) {
+ // Returns the text if the string has no ANSI escape code.
+ if (!_regANSI.test(text)) {
+ return text
+ }
+
+ // Cache opened sequence.
+ var ansiCodes = []
+ // Replace with markup.
+ var ret = text.replace(/\033\[(\d+)m/g, function (match, seq) {
+ var ot = _openTags[seq]
+ if (ot) {
+ // If current sequence has been opened, close it.
+ if (!!~ansiCodes.indexOf(seq)) { // eslint-disable-line no-extra-boolean-cast
+ ansiCodes.pop()
+ return ''
+ }
+ // Open tag.
+ ansiCodes.push(seq)
+ return ot[0] === '<' ? ot : ''
+ }
+
+ var ct = _closeTags[seq]
+ if (ct) {
+ // Pop sequence
+ ansiCodes.pop()
+ return ct
+ }
+ return ''
+ })
+
+ // Make sure tags are closed.
+ var l = ansiCodes.length
+ ;(l > 0) && (ret += Array(l + 1).join(''))
+
+ return ret
+}
+
+/**
+ * Customize colors.
+ * @param {Object} colors reference to _defColors
+ */
+ansiHTML.setColors = function (colors) {
+ if (typeof colors !== 'object') {
+ throw new Error('`colors` parameter must be an Object.')
+ }
+
+ var _finalColors = {}
+ for (var key in _defColors) {
+ var hex = colors.hasOwnProperty(key) ? colors[key] : null
+ if (!hex) {
+ _finalColors[key] = _defColors[key]
+ continue
+ }
+ if ('reset' === key) {
+ if (typeof hex === 'string') {
+ hex = [hex]
+ }
+ if (!Array.isArray(hex) || hex.length === 0 || hex.some(function (h) {
+ return typeof h !== 'string'
+ })) {
+ throw new Error('The value of `' + key + '` property must be an Array and each item could only be a hex string, e.g.: FF0000')
+ }
+ var defHexColor = _defColors[key]
+ if (!hex[0]) {
+ hex[0] = defHexColor[0]
+ }
+ if (hex.length === 1 || !hex[1]) {
+ hex = [hex[0]]
+ hex.push(defHexColor[1])
+ }
+
+ hex = hex.slice(0, 2)
+ } else if (typeof hex !== 'string') {
+ throw new Error('The value of `' + key + '` property must be a hex string, e.g.: FF0000')
+ }
+ _finalColors[key] = hex
+ }
+ _setTags(_finalColors)
+}
+
+/**
+ * Reset colors.
+ */
+ansiHTML.reset = function () {
+ _setTags(_defColors)
+}
+
+/**
+ * Expose tags, including open and close.
+ * @type {Object}
+ */
+ansiHTML.tags = {}
+
+if (Object.defineProperty) {
+ Object.defineProperty(ansiHTML.tags, 'open', {
+ get: function () { return _openTags }
+ })
+ Object.defineProperty(ansiHTML.tags, 'close', {
+ get: function () { return _closeTags }
+ })
+} else {
+ ansiHTML.tags.open = _openTags
+ ansiHTML.tags.close = _closeTags
+}
+
+function _setTags (colors) {
+ // reset all
+ _openTags['0'] = 'font-weight:normal;opacity:1;color:#' + colors.reset[0] + ';background:#' + colors.reset[1]
+ // inverse
+ _openTags['7'] = 'color:#' + colors.reset[1] + ';background:#' + colors.reset[0]
+ // dark grey
+ _openTags['90'] = 'color:#' + colors.darkgrey
+
+ for (var code in _styles) {
+ var color = _styles[code]
+ var oriColor = colors[color] || '000'
+ _openTags[code] = 'color:#' + oriColor
+ code = parseInt(code)
+ _openTags[(code + 10).toString()] = 'background:#' + oriColor
+ }
+}
+
+ansiHTML.reset()
+
+
+/***/ }),
+
+/***/ "./src/DistortableCollection.js":
+/*!**************************************!*\
+ !*** ./src/DistortableCollection.js ***!
+ \**************************************/
+/***/ (function() {
+
+L.DistortableCollection = L.FeatureGroup.extend({
+ options: {
+ editable: true,
+ exportOpts: {
+ exportStartUrl: '//export.mapknitter.org/export',
+ statusUrl: '//export.mapknitter.org',
+ exportUrl: 'http://export.mapknitter.org/'
+ }
+ },
+ initialize: function initialize(options) {
+ L.setOptions(this, options);
+ L.FeatureGroup.prototype.initialize.call(this, options);
+ L.Utils.initTranslation.call(this);
+ this.editable = this.options.editable;
+ },
+ onAdd: function onAdd(map) {
+ L.FeatureGroup.prototype.onAdd.call(this, map);
+ this._map = map;
+
+ if (this.editable) {
+ this.editing.enable();
+ }
+ /**
+ * although we have a DistortableCollection.Edit class that handles collection events to keep our code managable,
+ * events that need to be added on individual images are kept here to do so through `layeradd`.
+ */
+
+
+ this.on('layeradd', this._addEvents, this);
+ this.on('layerremove', this._removeEvents, this);
+ },
+ onRemove: function onRemove() {
+ if (this.editing) {
+ this.editing.disable();
+ }
+
+ this.off('layeradd', this._addEvents, this);
+ this.off('layerremove', this._removeEvents, this);
+ },
+ _addEvents: function _addEvents(e) {
+ var layer = e.layer;
+ L.DomEvent.on(layer, {
+ dragstart: this._dragStartMultiple,
+ drag: this._dragMultiple
+ }, this);
+ L.DomEvent.on(layer.getElement(), {
+ mousedown: this._deselectOthers,
+
+ /* Enable longpress for multi select for touch devices. */
+ contextmenu: this._longPressMultiSelect
+ }, this);
+ },
+ _removeEvents: function _removeEvents(e) {
+ var layer = e.layer;
+ L.DomEvent.off(layer, {
+ dragstart: this._dragStartMultiple,
+ drag: this._dragMultiple
+ }, this);
+ L.DomEvent.off(layer.getElement(), {
+ mousedown: this._deselectOthers,
+ contextmenu: this._longPressMultiSelect
+ }, this);
+ },
+ _longPressMultiSelect: function _longPressMultiSelect(e) {
+ var _this = this;
+
+ if (!this.editable) {
+ return;
+ }
+
+ e.preventDefault();
+ this.eachLayer(function (layer) {
+ var edit = layer.editing;
+
+ if (layer.getElement() === e.target && edit.enabled()) {
+ L.DomUtil.toggleClass(layer.getElement(), 'collected');
+
+ if (_this.anyCollected()) {
+ layer.deselect();
+
+ _this.editing._addToolbar();
+ } else {
+ _this.editing._removeToolbar();
+ }
+ }
+ });
+ },
+ isCollected: function isCollected(overlay) {
+ return L.DomUtil.hasClass(overlay.getElement(), 'collected');
+ },
+ anyCollected: function anyCollected() {
+ var layerArr = this.getLayers();
+ return layerArr.some(this.isCollected.bind(this));
+ },
+ _toggleCollected: function _toggleCollected(e, layer) {
+ if (e.shiftKey) {
+ /* conditional prevents disabled images from flickering multi-select mode */
+ if (layer.editing.enabled()) {
+ L.DomUtil.toggleClass(e.target, 'collected');
+ }
+ }
+
+ if (this.anyCollected()) {
+ layer.deselect();
+ } else {
+ this.editing._removeToolbar();
+ }
+ },
+ _deselectOthers: function _deselectOthers(e) {
+ var _this2 = this;
+
+ if (!this.editable) {
+ return;
+ }
+
+ this.eachLayer(function (layer) {
+ if (layer.getElement() !== e.target) {
+ layer.deselect();
+ } else {
+ _this2._toggleCollected(e, layer);
+ }
+ });
+
+ if (e) {
+ L.DomEvent.stopPropagation(e);
+ }
+ },
+ _dragStartMultiple: function _dragStartMultiple(e) {
+ var overlay = e.target;
+ var map = this._map;
+ var i;
+
+ if (!this.isCollected(overlay)) {
+ return;
+ }
+
+ this.eachLayer(function (layer) {
+ layer._dragStartPoints = {};
+ layer.deselect();
+
+ for (i = 0; i < 4; i++) {
+ var c = layer.getCorner(i);
+ layer._dragStartPoints[i] = map.latLngToLayerPoint(c);
+ }
+ });
+ },
+ _dragMultiple: function _dragMultiple(e) {
+ var overlay = e.target;
+ var map = this._map;
+
+ if (!this.isCollected(overlay)) {
+ return;
+ }
+
+ var topLeft = map.latLngToLayerPoint(overlay.getCorner(0));
+
+ var delta = overlay._dragStartPoints[0].subtract(topLeft);
+
+ this._updateCollectionFromPoints(delta, overlay);
+ },
+ _toRemove: function _toRemove() {
+ var _this3 = this;
+
+ var layerArr = this.getLayers();
+ return layerArr.filter(function (layer) {
+ var mode = layer.editing._mode;
+ return _this3.isCollected(layer) && mode !== 'lock';
+ });
+ },
+ _toMove: function _toMove(overlay) {
+ var _this4 = this;
+
+ var layerArr = this.getLayers();
+ return layerArr.filter(function (layer) {
+ var mode = layer.editing._mode;
+ return layer !== overlay && _this4.isCollected(layer) && mode !== 'lock';
+ });
+ },
+ _updateCollectionFromPoints: function _updateCollectionFromPoints(delta, overlay) {
+ var layersToMove = this._toMove(overlay);
+
+ var p = new L.Transformation(1, -delta.x, 1, -delta.y);
+ var i;
+ layersToMove.forEach(function (layer) {
+ var movedPoints = {};
+
+ for (i = 0; i < 4; i++) {
+ movedPoints[i] = p.transform(layer._dragStartPoints[i]);
+ }
+
+ layer.setCornersFromPoints(movedPoints);
+ });
+ },
+ _getAvgCmPerPixel: function _getAvgCmPerPixel(imgs) {
+ var reduce = imgs.reduce(function (sum, img) {
+ return sum + img.cm_per_pixel;
+ }, 0);
+ return reduce / imgs.length;
+ },
+ generateExportJson: function generateExportJson() {
+ var json = {};
+ json.images = [];
+ this.eachLayer(function (layer) {
+ if (this.isCollected(layer)) {
+ var sections = layer._image.src.split('/');
+
+ var filename = sections[sections.length - 1];
+ var zc = layer.getCorners();
+ var corners = [{
+ lat: zc[0].lat,
+ lon: zc[0].lng
+ }, {
+ lat: zc[1].lat,
+ lon: zc[1].lng
+ }, {
+ lat: zc[3].lat,
+ lon: zc[3].lng
+ }, {
+ lat: zc[2].lat,
+ lon: zc[2].lng
+ }];
+ json.images.push({
+ id: this.getLayerId(layer),
+ src: layer._image.src,
+ width: layer._image.width,
+ height: layer._image.height,
+ image_file_name: filename,
+ nodes: corners,
+ cm_per_pixel: L.ImageUtil.getCmPerPixel(layer)
});
- },
- 477: function () {
- (L.DistortableImageOverlay = L.ImageOverlay.extend({
- options: {
- height: 200,
- crossOrigin: !0,
- edgeMinWidth: 50,
- editable: !0,
- mode: "distort",
- selected: !1,
- },
- initialize: function (t, e) {
- L.setOptions(this, e),
- L.Utils.initTranslation.call(this),
- (this.edgeMinWidth = this.options.edgeMinWidth),
- (this.editable = this.options.editable),
- (this._selected = this.options.selected),
- (this._url = t),
- (this.rotation = {});
- },
- onAdd: function (t) {
- var e = this;
- (this._map = t),
- this.getElement() || this._initImage(),
- t.on("viewreset", this._reset, this),
- this.options.corners &&
- ((this._corners = this.options.corners),
- t.options.zoomAnimation &&
- L.Browser.any3d &&
- t.on("zoomanim", this._animateZoom, this)),
- L.DomEvent.on(this.getElement(), "load", function () {
- if (
- (e.getPane().appendChild(e.getElement()),
- e._initImageDimensions(),
- e.options.rotation)
- ) {
- var i = e.options.rotation.deg ? "deg" : "rad";
- e.setAngle(e.options.rotation[i], i);
- } else (e.rotation = { deg: 0, rad: 0 }), e._reset();
- e._corners ||
- (t.options.zoomAnimation &&
- L.Browser.any3d &&
- t.on("zoomanim", e._animateZoom, e));
- var o = e._eventParents;
- o
- ? ((e.eP = o[Object.keys(o)[0]]),
- e.eP.editable && e.editing.enable())
- : (e.editable && e.editing.enable(), (e.eP = null));
- }),
- L.DomEvent.on(this.getElement(), "click", this.select, this),
- L.DomEvent.on(
- t,
- {
- singleclickon: this._singleClickListeners,
- singleclickoff: this._resetClickListeners,
- singleclick: this._singleClick,
- },
- this
- ),
- t.doubleClickZoom.enabled() ||
- t.doubleClickLabels.enabled() ||
- L.DomEvent.on(t, "click", this.deselect, this),
- this.fire("add");
- },
- onRemove: function (t) {
- L.DomEvent.off(this.getElement(), "click", this.select, this),
- L.DomEvent.off(
- t,
- {
- singleclickon: this._singleClickListeners,
- singleclickoff: this._resetClickListeners,
- singleclick: this._singleClick,
- },
- this
- ),
- L.DomEvent.off(t, "click", this.deselect, this),
- this.editing && this.editing.disable(),
- this.fire("remove"),
- L.ImageOverlay.prototype.onRemove.call(this, t);
- },
- _initImageDimensions: function () {
- var t = this._map,
- e = L.DomUtil.getStyle(this.getElement(), "width"),
- i = L.DomUtil.getStyle(this.getElement(), "height"),
- o = parseInt(e) / parseInt(i),
- n = this.options.height,
- a = parseInt(o * n),
- s = t.project(t.getCenter()),
- r = L.point(a, n).divideBy(2);
- this.options.corners
- ? (this._corners = this.options.corners)
- : (this._corners = [
- t.unproject(s.subtract(r)),
- t.unproject(s.add(L.point(r.x, -r.y))),
- t.unproject(s.add(L.point(-r.x, r.y))),
- t.unproject(s.add(r)),
- ]),
- (this._initialDimensions = {
- center: s,
- offset: r,
- zoom: t.getZoom(),
- }),
- this.setBounds(L.latLngBounds(this.getCorners()));
- },
- _singleClick: function (t) {
- "singleclick" === t.type && this.deselect();
- },
- _singleClickListeners: function () {
- var t = this._map;
- L.DomEvent.off(t, "click", this.deselect, this),
- L.DomEvent.on(t, "singleclick", this.deselect, this);
- },
- _resetClickListeners: function () {
- var t = this._map;
- L.DomEvent.on(t, "click", this.deselect, this),
- L.DomEvent.off(t, "singleclick", this.deselect, this);
- },
- isSelected: function () {
- return this._selected;
- },
- deselect: function () {
- var t = this.editing;
- if (t.enabled())
- return (
- t._removeToolbar(),
- t._hideMarkers(),
- (this._selected = !1),
- this.fire("deselect"),
- this
- );
- },
- select: function (t) {
- var e = this.editing,
- i = this.eP;
- if (e.enabled()) {
- if (
- (t && L.DomEvent.stopPropagation(t),
- this._programmaticGrouping(),
- (this._selected = !0),
- e._addToolbar(),
- e._showMarkers(),
- this.fire("select"),
- !i || !i.anyCollected())
- )
- return this;
- this.deselect();
- }
- },
- _programmaticGrouping: function () {
- this._map.eachLayer(function (t) {
- t instanceof L.DistortableImageOverlay && t.deselect();
- });
- },
- setCorner: function (t, e) {
- var i = this.editing;
- return (
- (this._corners[t] = e),
- this.setBounds(L.latLngBounds(this.getCorners())),
- this.fire("update"),
- i.toolbar &&
- i.toolbar instanceof L.DistortableImage.PopupBar &&
- i._updateToolbarPos(),
- (this.edited = !0),
- this
- );
- },
- _cornerExceedsMapLats: function (t, e, i) {
- return (
- i.options.crs != L.CRS.Simple &&
- (0 === t
- ? ((o = i.project(e).y < 2), (n = i.project(e).y >= 255))
- : ((o = i.project(e).y / t < 2),
- (n = i.project(e).y / Math.pow(2, t) >= 255)),
- o || n)
- );
- var o, n;
- },
- setCorners: function (t) {
- var e = this._map,
- i = e.getZoom(),
- o = this.editing,
- n = 0;
- for (var a in t)
- if (this._cornerExceedsMapLats(i, t[a], e))
- return (
- this.setBounds(L.latLngBounds(this.getCorners())),
- void this.fire("update")
- );
- for (a in t) (this._corners[n] = t[a]), (n += 1);
- return (
- this.setBounds(L.latLngBounds(this.getCorners())),
- this.fire("update"),
- o.toolbar &&
- o.toolbar instanceof L.DistortableImage.PopupBar &&
- o._updateToolbarPos(),
- (this.edited = !0),
- this
- );
- },
- setCornersFromPoints: function (t) {
- var e = this._map,
- i = e.getZoom(),
- o = this.editing,
- n = 0;
- for (var a in t) {
- var s = e.layerPointToLatLng(t[a]);
- if (this._cornerExceedsMapLats(i, s, e))
- return (
- this.setBounds(L.latLngBounds(this.getCorners())),
- void this.fire("update")
- );
- }
- for (a in t)
- (this._corners[n] = e.layerPointToLatLng(t[a])), (n += 1);
- return (
- this.setBounds(L.latLngBounds(this.getCorners())),
- this.fire("update"),
- o.toolbar &&
- o.toolbar instanceof L.DistortableImage.PopupBar &&
- o._updateToolbarPos(),
- (this.edited = !0),
- this
- );
- },
- scaleBy: function (t) {
- var e,
- i,
- o = this._map,
- n = o.project(this.getCenter()),
- a = {};
- if (0 !== t) {
- for (e = 0; e < 4; e++)
- (i = o
- .project(this.getCorner(e))
- .subtract(n)
- .multiplyBy(t)
- .add(n)),
- (a[e] = o.unproject(i));
- return this.setCorners(a), this;
+ }
+ }, this);
+ json.images = json.images.reverse();
+ json.avg_cm_per_pixel = this._getAvgCmPerPixel(json.images);
+ return json;
+ }
+});
+
+L.distortableCollection = function (id, options) {
+ return new L.DistortableCollection(id, options);
+};
+
+/***/ }),
+
+/***/ "./src/DistortableImageOverlay.js":
+/*!****************************************!*\
+ !*** ./src/DistortableImageOverlay.js ***!
+ \****************************************/
+/***/ (function() {
+
+L.DistortableImageOverlay = L.ImageOverlay.extend({
+ options: {
+ height: 200,
+ crossOrigin: true,
+ // todo: find ideal number to prevent distortions during RotateScale, and make it dynamic (remove hardcoding)
+ edgeMinWidth: 50,
+ editable: true,
+ mode: 'distort',
+ selected: false
+ },
+ initialize: function initialize(url, options) {
+ L.setOptions(this, options);
+ L.Utils.initTranslation.call(this);
+ this.edgeMinWidth = this.options.edgeMinWidth;
+ this.editable = this.options.editable;
+ this._selected = this.options.selected;
+ this._url = url;
+ this.rotation = {};
+ },
+ onAdd: function onAdd(map) {
+ var _this = this;
+
+ this._map = map;
+
+ if (!this.getElement()) {
+ this._initImage();
+ }
+
+ map.on('viewreset', this._reset, this);
+
+ if (this.options.corners) {
+ this._corners = this.options.corners;
+
+ if (map.options.zoomAnimation && L.Browser.any3d) {
+ map.on('zoomanim', this._animateZoom, this);
+ }
+ } // Have to wait for the image to load because need to access its w/h
+
+
+ L.DomEvent.on(this.getElement(), 'load', function () {
+ _this.getPane().appendChild(_this.getElement());
+
+ _this._initImageDimensions();
+
+ if (_this.options.rotation) {
+ var units = _this.options.rotation.deg ? 'deg' : 'rad';
+
+ _this.setAngle(_this.options.rotation[units], units);
+ } else {
+ _this.rotation = {
+ deg: 0,
+ rad: 0
+ };
+
+ _this._reset();
+ }
+ /* Initialize default corners if not already set */
+
+
+ if (!_this._corners) {
+ if (map.options.zoomAnimation && L.Browser.any3d) {
+ map.on('zoomanim', _this._animateZoom, _this);
+ }
+ }
+ /** if there is a featureGroup, only its editable option matters */
+
+
+ var eventParents = _this._eventParents;
+
+ if (eventParents) {
+ _this.eP = eventParents[Object.keys(eventParents)[0]];
+
+ if (_this.eP.editable) {
+ _this.editing.enable();
+ }
+ } else {
+ if (_this.editable) {
+ _this.editing.enable();
+ }
+
+ _this.eP = null;
+ }
+ });
+ L.DomEvent.on(this.getElement(), 'click', this.select, this);
+ L.DomEvent.on(map, {
+ singleclickon: this._singleClickListeners,
+ singleclickoff: this._resetClickListeners,
+ singleclick: this._singleClick
+ }, this);
+ /**
+ * custom events fired from DoubleClickLabels.js. Used to differentiate
+ * single / dblclick to not deselect images on map dblclick.
+ */
+
+ if (!(map.doubleClickZoom.enabled() || map.doubleClickLabels.enabled())) {
+ L.DomEvent.on(map, 'click', this.deselect, this);
+ }
+
+ this.fire('add');
+ },
+ onRemove: function onRemove(map) {
+ L.DomEvent.off(this.getElement(), 'click', this.select, this);
+ L.DomEvent.off(map, {
+ singleclickon: this._singleClickListeners,
+ singleclickoff: this._resetClickListeners,
+ singleclick: this._singleClick
+ }, this);
+ L.DomEvent.off(map, 'click', this.deselect, this);
+
+ if (this.editing) {
+ this.editing.disable();
+ }
+
+ this.fire('remove');
+ L.ImageOverlay.prototype.onRemove.call(this, map);
+ },
+ _initImageDimensions: function _initImageDimensions() {
+ var map = this._map;
+ var originalImageWidth = L.DomUtil.getStyle(this.getElement(), 'width');
+ var originalImageHeight = L.DomUtil.getStyle(this.getElement(), 'height');
+ var aspectRatio = parseInt(originalImageWidth) / parseInt(originalImageHeight);
+ var imageHeight = this.options.height;
+ var imageWidth = parseInt(aspectRatio * imageHeight);
+ var center = map.project(map.getCenter());
+ var offset = L.point(imageWidth, imageHeight).divideBy(2);
+
+ if (this.options.corners) {
+ this._corners = this.options.corners;
+ } else {
+ this._corners = [map.unproject(center.subtract(offset)), map.unproject(center.add(L.point(offset.x, -offset.y))), map.unproject(center.add(L.point(-offset.x, offset.y))), map.unproject(center.add(offset))];
+ }
+
+ this._initialDimensions = {
+ 'center': center,
+ 'offset': offset,
+ 'zoom': map.getZoom()
+ };
+ this.setBounds(L.latLngBounds(this.getCorners()));
+ },
+ _singleClick: function _singleClick(e) {
+ if (e.type === 'singleclick') {
+ this.deselect();
+ } else {
+ return;
+ }
+ },
+ _singleClickListeners: function _singleClickListeners() {
+ var map = this._map;
+ L.DomEvent.off(map, 'click', this.deselect, this);
+ L.DomEvent.on(map, 'singleclick', this.deselect, this);
+ },
+ _resetClickListeners: function _resetClickListeners() {
+ var map = this._map;
+ L.DomEvent.on(map, 'click', this.deselect, this);
+ L.DomEvent.off(map, 'singleclick', this.deselect, this);
+ },
+ isSelected: function isSelected() {
+ return this._selected;
+ },
+ deselect: function deselect() {
+ var edit = this.editing;
+
+ if (!edit.enabled()) {
+ return;
+ }
+
+ edit._removeToolbar();
+
+ edit._hideMarkers();
+
+ this._selected = false;
+ this.fire('deselect');
+ return this;
+ },
+ select: function select(e) {
+ var edit = this.editing;
+ var eP = this.eP;
+
+ if (!edit.enabled()) {
+ return;
+ }
+
+ if (e) {
+ L.DomEvent.stopPropagation(e);
+ } // this ensures deselection of all other images, allowing us to keep collection group optional
+
+
+ this._programmaticGrouping();
+
+ this._selected = true;
+
+ edit._addToolbar();
+
+ edit._showMarkers();
+
+ this.fire('select'); // we run the selection logic 1st anyway because the collection group's _addToolbar method depends on it
+
+ if (eP && eP.anyCollected()) {
+ this.deselect();
+ return;
+ }
+
+ return this;
+ },
+ _programmaticGrouping: function _programmaticGrouping() {
+ this._map.eachLayer(function (layer) {
+ if (layer instanceof L.DistortableImageOverlay) {
+ layer.deselect();
+ }
+ });
+ },
+ setCorner: function setCorner(corner, latlng) {
+ var edit = this.editing;
+ this._corners[corner] = latlng;
+ this.setBounds(L.latLngBounds(this.getCorners()));
+ this.fire('update');
+
+ if (edit.toolbar && edit.toolbar instanceof L.DistortableImage.PopupBar) {
+ edit._updateToolbarPos();
+ }
+
+ this.edited = true;
+ return this;
+ },
+ _cornerExceedsMapLats: function _cornerExceedsMapLats(zoom, corner, map) {
+ if (map.options.crs.Simple == L.CRS.Simple) {
+ return false;
+ } else {
+ var exceedsTop;
+ var exceedsBottom;
+
+ if (zoom === 0) {
+ exceedsTop = map.project(corner).y < 2;
+ exceedsBottom = map.project(corner).y >= 255;
+ } else {
+ exceedsTop = map.project(corner).y / zoom < 2;
+ exceedsBottom = map.project(corner).y / Math.pow(2, zoom) >= 255;
+ }
+
+ return exceedsTop || exceedsBottom;
+ }
+ },
+ setCorners: function setCorners(latlngObj) {
+ var map = this._map;
+ var zoom = map.getZoom();
+ var edit = this.editing;
+ var i = 0; // this is to fix https://github.com/publiclab/Leaflet.DistortableImage/issues/402
+
+ for (var k in latlngObj) {
+ if (this._cornerExceedsMapLats(zoom, latlngObj[k], map)) {
+ // calling reset / update w/ the same corners bc it prevents a marker flicker for rotate
+ this.setBounds(L.latLngBounds(this.getCorners()));
+ this.fire('update');
+ return;
+ }
+ }
+
+ for (var _k in latlngObj) {
+ this._corners[i] = latlngObj[_k];
+ i += 1;
+ }
+
+ this.setBounds(L.latLngBounds(this.getCorners()));
+ this.fire('update');
+
+ if (edit.toolbar && edit.toolbar instanceof L.DistortableImage.PopupBar) {
+ edit._updateToolbarPos();
+ }
+
+ this.edited = true;
+ return this;
+ },
+ setCornersFromPoints: function setCornersFromPoints(pointsObj) {
+ var map = this._map;
+ var zoom = map.getZoom();
+ var edit = this.editing;
+ var i = 0;
+
+ for (var k in pointsObj) {
+ var corner = map.layerPointToLatLng(pointsObj[k]);
+
+ if (this._cornerExceedsMapLats(zoom, corner, map)) {
+ // calling reset / update w/ the same corners bc it prevents a marker flicker for rotate
+ this.setBounds(L.latLngBounds(this.getCorners()));
+ this.fire('update');
+ return;
+ }
+ }
+
+ for (var _k2 in pointsObj) {
+ this._corners[i] = map.layerPointToLatLng(pointsObj[_k2]);
+ i += 1;
+ }
+
+ this.setBounds(L.latLngBounds(this.getCorners()));
+ this.fire('update');
+
+ if (edit.toolbar && edit.toolbar instanceof L.DistortableImage.PopupBar) {
+ edit._updateToolbarPos();
+ }
+
+ this.edited = true;
+ return this;
+ },
+ scaleBy: function scaleBy(scale) {
+ var map = this._map;
+ var center = map.project(this.getCenter());
+ var i;
+ var p;
+ var scaledCorners = {};
+
+ if (scale === 0) {
+ return;
+ }
+
+ for (i = 0; i < 4; i++) {
+ p = map.project(this.getCorner(i)).subtract(center).multiplyBy(scale).add(center);
+ scaledCorners[i] = map.unproject(p);
+ }
+
+ this.setCorners(scaledCorners);
+ return this;
+ },
+ getAngle: function getAngle() {
+ var unit = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'deg';
+ var matrix = this.getElement().style[L.DomUtil.TRANSFORM].split('matrix3d')[1].slice(1, -1).split(',');
+ var row0x = matrix[0];
+ var row0y = matrix[1];
+ var row1x = matrix[4];
+ var row1y = matrix[5];
+ var determinant = row0x * row1y - row0y * row1x;
+ var angle = L.TrigUtil.calcAngle(row0x, row0y, 'rad');
+
+ if (determinant < 0) {
+ angle += angle < 0 ? Math.PI : -Math.PI;
+ }
+
+ if (angle < 0) {
+ angle = 2 * Math.PI + angle;
+ }
+
+ return unit === 'deg' ? Math.round(L.TrigUtil.radiansToDegrees(angle)) : L.Util.formatNum(angle, 2);
+ },
+ setAngle: function setAngle(angle) {
+ var unit = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'deg';
+ var currentAngle = this.getAngle(unit);
+ var angleToRotateBy = angle - currentAngle;
+ this.rotateBy(angleToRotateBy, unit);
+ return this;
+ },
+ rotateBy: function rotateBy(angle) {
+ var unit = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'deg';
+ var map = this._map;
+ var center = map.project(this.getCenter());
+ var corners = {};
+ var i;
+ var p;
+ var q;
+
+ if (unit === 'deg') {
+ angle = L.TrigUtil.degreesToRadians(angle);
+ }
+
+ for (i = 0; i < 4; i++) {
+ p = map.project(this.getCorner(i)).subtract(center);
+ q = L.point(Math.cos(angle) * p.x - Math.sin(angle) * p.y, Math.sin(angle) * p.x + Math.cos(angle) * p.y);
+ corners[i] = map.unproject(q.add(center));
+ }
+
+ this.setCorners(corners);
+ return this;
+ },
+ dragBy: function dragBy(formerPoint, newPoint) {
+ var map = this._map;
+ var i;
+ var p;
+ var transCorners = {};
+ var delta = map.project(formerPoint).subtract(map.project(newPoint));
+
+ for (i = 0; i < 4; i++) {
+ p = map.project(this.getCorner(i)).subtract(delta);
+ transCorners[i] = map.unproject(p);
+ }
+
+ this.setCorners(transCorners);
+ },
+ restore: function restore() {
+ var map = this._map;
+ var center = this._initialDimensions.center;
+ var offset = this._initialDimensions.offset;
+ var zoom = this._initialDimensions.zoom;
+ var corners = [center.subtract(offset), center.add(L.point(offset.x, -offset.y)), center.add(L.point(-offset.x, offset.y)), center.add(offset)];
+
+ for (var i = 0; i < 4; i++) {
+ if (!map.unproject(corners[i], zoom).equals(this.getCorner(i))) {
+ this.setCorner(i, map.unproject(corners[i], zoom));
+ }
+ }
+
+ this.edited = false;
+ this.fire('restore');
+ return this;
+ },
+
+ /* Copied from Leaflet v0.7 https://github.com/Leaflet/Leaflet/blob/66282f14bcb180ec87d9818d9f3c9f75afd01b30/src/dom/DomUtil.js#L189-L199 */
+
+ /* since L.DomUtil.getTranslateString() is deprecated in Leaflet v1.0 */
+ _getTranslateString: function _getTranslateString(point) {
+ // on WebKit browsers (Chrome/Safari/iOS Safari/Android)
+ // using translate3d instead of translate
+ // makes animation smoother as it ensures HW accel is used.
+ // Firefox 13 doesn't care
+ // (same speed either way), Opera 12 doesn't support translate3d
+ var is3d = L.Browser.webkit3d;
+ var open = 'translate' + (is3d ? '3d' : '') + '(';
+ var close = (is3d ? ',0' : '') + ')';
+ return open + point.x + 'px,' + point.y + 'px' + close;
+ },
+ _reset: function _reset() {
+ var map = this._map;
+ var image = this.getElement();
+ var latLngToLayerPoint = L.bind(map.latLngToLayerPoint, map);
+
+ var transformMatrix = this._calculateProjectiveTransform(latLngToLayerPoint);
+
+ var topLeft = latLngToLayerPoint(this.getCorner(0));
+ var warp = L.DomUtil.getMatrixString(transformMatrix);
+
+ var translation = this._getTranslateString(topLeft);
+ /* See L.DomUtil.setPosition. Mainly for the purposes of L.Draggable. */
+
+
+ image._leaflet_pos = topLeft;
+ image.style[L.DomUtil.TRANSFORM] = [translation, warp].join(' ');
+ /* Set origin to the upper-left corner rather than
+ * the center of the image, which is the default.
+ */
+
+ image.style[L.DomUtil.TRANSFORM + '-origin'] = '0 0 0';
+ this.rotation.deg = this.getAngle();
+ this.rotation.rad = this.getAngle('rad');
+ },
+
+ /*
+ * Calculates the transform string that will be
+ * correct *at the end* of zooming.
+ * Leaflet then generates a CSS3 animation between the current transform and
+ * future transform which makes the transition appear smooth.
+ */
+ _animateZoom: function _animateZoom(event) {
+ var map = this._map;
+ var image = this.getElement();
+
+ var latLngToNewLayerPoint = function latLngToNewLayerPoint(latlng) {
+ return map._latLngToNewLayerPoint(latlng, event.zoom, event.center);
+ };
+
+ var transformMatrix = this._calculateProjectiveTransform(latLngToNewLayerPoint);
+
+ var topLeft = latLngToNewLayerPoint(this.getCorner(0));
+ var warp = L.DomUtil.getMatrixString(transformMatrix);
+
+ var translation = this._getTranslateString(topLeft);
+ /* See L.DomUtil.setPosition. Mainly for the purposes of L.Draggable. */
+
+
+ image._leaflet_pos = topLeft;
+ image.style[L.DomUtil.TRANSFORM] = [translation, warp].join(' ');
+ },
+ getCorners: function getCorners() {
+ return this._corners;
+ },
+ getCorner: function getCorner(i) {
+ return this._corners[i];
+ },
+ // image (vertex) centroid calculation
+ getCenter: function getCenter() {
+ var map = this._map;
+ var reduce = this.getCorners().reduce(function (agg, corner) {
+ return agg.add(map.project(corner));
+ }, L.point(0, 0));
+ return map.unproject(reduce.divideBy(4));
+ },
+ _calculateProjectiveTransform: function _calculateProjectiveTransform(latLngToCartesian) {
+ /* Setting reasonable but made-up image defaults
+ * allow us to place images on the map before
+ * they've finished downloading. */
+ var offset = latLngToCartesian(this.getCorner(0));
+ var w = this.getElement().offsetWidth || 500;
+ var h = this.getElement().offsetHeight || 375;
+ var c = [];
+ var j;
+ /* Convert corners to container points (i.e. cartesian coordinates). */
+
+ for (j = 0; j < 4; j++) {
+ c.push(latLngToCartesian(this.getCorner(j))._subtract(offset));
+ }
+ /*
+ * This matrix describes the action of
+ * the CSS transform on each corner of the image.
+ * It maps from the coordinate system centered
+ * at the upper left corner of the image
+ * to the region bounded by the latlngs in this._corners.
+ * For example:
+ * 0, 0, c[0].x, c[0].y
+ * says that the upper-left corner of the image
+ * maps to the first latlng in this._corners.
+ */
+
+
+ return L.MatrixUtil.general2DProjection(0, 0, c[0].x, c[0].y, w, 0, c[1].x, c[1].y, 0, h, c[2].x, c[2].y, w, h, c[3].x, c[3].y);
+ }
+});
+
+L.distortableImageOverlay = function (id, options) {
+ return new L.DistortableImageOverlay(id, options);
+};
+
+L.Map.addInitHook(function () {
+ if (!L.DomUtil.hasClass(this.getContainer(), 'ldi')) {
+ L.DomUtil.addClass(this.getContainer(), 'ldi');
+ }
+});
+
+/***/ }),
+
+/***/ "./src/components/DistortableImage.Keymapper.js":
+/*!******************************************************!*\
+ !*** ./src/components/DistortableImage.Keymapper.js ***!
+ \******************************************************/
+/***/ (function() {
+
+var _this = this;
+
+L.DomUtil = L.DomUtil || {};
+L.DistortableImage = L.DistortableImage || {};
+L.distortableImage = L.DistortableImage;
+L.DistortableImage.Keymapper = L.Handler.extend({
+ options: {
+ position: 'topright'
+ },
+ initialize: function initialize(map, options) {
+ this._map = map;
+ L.setOptions(this, options);
+ },
+ addHooks: function addHooks() {
+ if (!this._keymapper) {
+ this._container = this._buildContainer();
+ this._scrollWrapper = this._wrap();
+ this._toggler = this._createButton();
+
+ this._setMapper(this._container, this._scrollWrapper, this._toggler);
+
+ L.DomEvent.on(this._toggler, 'click', this._toggleKeymapper, this);
+ L.DomEvent.disableClickPropagation(this._container);
+ L.DomEvent.disableScrollPropagation(this._container);
+ }
+ },
+ removeHooks: function removeHooks() {
+ if (this._keymapper) {
+ L.DomEvent.off(this._toggler, 'click', this._toggleKeymapper, this);
+ L.DomUtil.remove(this._toggler);
+ L.DomUtil.remove(this._scrollWrapper);
+ L.DomUtil.remove(this._container);
+ this._keymapper = false;
+ }
+ },
+ _buildContainer: function _buildContainer() {
+ var container = L.DomUtil.create('div', 'ldi-keymapper-hide');
+ container.setAttribute('id', 'ldi-keymapper');
+ var divider = L.DomUtil.create('br', 'divider');
+ container.appendChild(divider);
+ return container;
+ },
+ _createButton: function _createButton() {
+ var toggler = L.DomUtil.create('a', '');
+ toggler.innerHTML = L.IconUtil.create('keyboard_open');
+ toggler.setAttribute('id', 'toggle-keymapper');
+ toggler.setAttribute('href', '#');
+ toggler.setAttribute('title', 'Show keymap'); // Will force screen readers like VoiceOver to read this as "Show keymap - button"
+
+ toggler.setAttribute('role', 'button');
+ toggler.setAttribute('aria-label', 'Show keymap');
+ return toggler;
+ },
+ _wrap: function _wrap() {
+ var wrap = L.DomUtil.create('div', '');
+ wrap.setAttribute('id', 'keymapper-wrapper');
+ wrap.style.display = 'none';
+ return wrap;
+ },
+ _setMapper: function _setMapper(container, wrap, button) {
+ this._keymapper = L.control({
+ position: this.options.position
+ });
+
+ this._keymapper.onAdd = function () {
+ container.appendChild(wrap);
+ wrap.insertAdjacentHTML('beforeend', '
' + '
' +
+ /* eslint-disable */
+ 'Rotate Mode R |
' + 'RotateScale Mode r |
' + 'Scale Mode s |
' + 'Distort Mode d |
' + 'Drag Mode D |
' + 'Lock (Mode) / Unlock Image l\xa0u |
' + 'Stack up / down q\xa0a |
' + 'Add / Remove Image Border b |
' + 'Toggle Opacity o |
' + 'Deselect All esc |
' + 'Delete Image(s) delete\xa0backspace |
' + 'Export Image(s) e |
' + '
');
+ /* eslint-enable */
+
+ container.appendChild(button);
+ return container;
+ };
+
+ this._keymapper.addTo(this._map);
+ },
+ _toggleKeymapper: function _toggleKeymapper(e) {
+ e.preventDefault();
+ this._container.className = this._container.className === 'ldi-keymapper leaflet-control' ? 'ldi-keymapper-hide leaflet-control' : 'ldi-keymapper leaflet-control';
+ this._scrollWrapper.style.display = this._scrollWrapper.style.display === 'none' ? 'block' : 'none';
+ this._toggler.innerHTML = this._toggler.innerHTML === 'close' ? L.IconUtil.create('keyboard_open') : 'close';
+ L.IconUtil.toggleTitle(this._toggler, 'Show keymap', 'Hide keymap');
+ L.DomUtil.toggleClass(this._toggler, 'close-icon');
+ },
+ _injectIconSet: function _injectIconSet() {
+ if (document.querySelector('#keymapper-iconset')) {
+ return;
+ }
+
+ var el = L.DomUtil.create('div', '');
+ el.id = 'keymapper-iconset';
+ el.setAttribute('hidden', 'hidden');
+ this._iconset = new L.KeymapperIconSet().render();
+ el.innerHTML = this._iconset;
+ document.querySelector('.leaflet-control-container').appendChild(el);
+ }
+});
+L.DistortableImage.Keymapper.addInitHook(function () {
+ L.DistortableImage.Keymapper.prototype._n = L.DistortableImage.Keymapper.prototype._n ? L.DistortableImage.Keymapper.prototype._n + 1 : 1; // dont enable keymapper for mobile
+
+ if (L.DistortableImage.Keymapper.prototype._n === 1 && !L.Browser.mobile) {
+ _this.enable();
+
+ _this._injectIconSet();
+ }
+});
+
+L.distortableImage.keymapper = function (map, options) {
+ return new L.DistortableImage.Keymapper(map, options);
+};
+
+/***/ }),
+
+/***/ "./src/edit/DistortableCollection.Edit.js":
+/*!************************************************!*\
+ !*** ./src/edit/DistortableCollection.Edit.js ***!
+ \************************************************/
+/***/ (function() {
+
+L.DistortableImage = L.DistortableImage || {}; // this class holds the keybindings and toolbar API for an image collection instance
+
+L.DistortableCollection.Edit = L.Handler.extend({
+ options: {
+ keymap: L.distortableImage.group_action_map
+ },
+ initialize: function initialize(group, options) {
+ this._group = group;
+ this._exportOpts = group.options.exportOpts;
+ L.setOptions(this, options);
+ L.distortableImage.group_action_map.Escape = '_decollectAll';
+ },
+ addHooks: function addHooks() {
+ var group = this._group;
+ var map = group._map;
+ this.editActions = this.options.actions;
+ this.runExporter = L.bind(L.Utils.getNestedVal(this, '_exportOpts', 'exporter') || this.startExport, this);
+ L.DomEvent.on(document, 'keydown', this._onKeyDown, this);
+
+ if (!(map.doubleClickZoom.enabled() || map.doubleClickLabels.enabled())) {
+ L.DomEvent.on(map, 'click', this._decollectAll, this);
+ }
+
+ L.DomEvent.on(map, {
+ singleclickon: this._singleClickListeners,
+ singleclickoff: this._resetClickListeners,
+ singleclick: this._singleClick,
+ boxcollectend: this._addCollections
+ }, this);
+ this._group.editable = true;
+
+ this._group.eachLayer(function (layer) {
+ return layer.editing.enable();
+ });
+ },
+ removeHooks: function removeHooks() {
+ var group = this._group;
+ var map = group._map;
+ L.DomEvent.off(document, 'keydown', this._onKeyDown, this);
+
+ if (!(map.doubleClickZoom.enabled() || map.doubleClickLabels.enabled())) {
+ L.DomEvent.off(map, 'click', this._decollectAll, this);
+ }
+
+ L.DomEvent.off(map, {
+ singleclickon: this._singleClickListeners,
+ singleclickoff: this._resetClickListeners,
+ singleclick: this._singleClick,
+ boxcollectend: this._addCollections
+ }, this);
+
+ this._decollectAll();
+
+ this._group.editable = false;
+
+ this._group.eachLayer(function (layer) {
+ return layer.editing.disable();
+ });
+ },
+ enable: function enable() {
+ this._enabled = true;
+ this.addHooks();
+ return this;
+ },
+ disable: function disable() {
+ this._enabled = false;
+ this.removeHooks();
+ return this;
+ },
+ _onKeyDown: function _onKeyDown(e) {
+ var keymap = this.options.keymap;
+ var handlerName = keymap[e.key];
+
+ if (!this[handlerName]) {
+ return;
+ }
+
+ if (this._group.anyCollected()) {
+ this[handlerName].call(this);
+ }
+ },
+ _singleClick: function _singleClick(e) {
+ if (e.type === 'singleclick') {
+ this._decollectAll(e);
+ } else {
+ return;
+ }
+ },
+ _singleClickListeners: function _singleClickListeners() {
+ var map = this._group._map;
+ L.DomEvent.off(map, 'click', this._decollectAll, this);
+ L.DomEvent.on(map, 'singleclick', this._decollectAll, this);
+ },
+ _resetClickListeners: function _resetClickListeners() {
+ var map = this._group._map;
+ L.DomEvent.on(map, 'click', this._decollectAll, this);
+ L.DomEvent.off(map, 'singleclick', this._decollectAll, this);
+ },
+ _decollectAll: function _decollectAll(e) {
+ var oe;
+
+ if (e) {
+ oe = e.originalEvent;
+ }
+ /**
+ * prevents image deselection following the 'boxcollectend' event - note 'shift' must not be released until dragging is complete
+ * also prevents deselection following a click on a disabled img by differentiating it from the map
+ */
+
+
+ if (oe && (oe.shiftKey || oe.target instanceof HTMLImageElement)) {
+ return;
+ }
+
+ this._group.eachLayer(function (layer) {
+ L.DomUtil.removeClass(layer.getElement(), 'collected');
+ layer.deselect();
+ });
+
+ this._removeToolbar();
+
+ if (e) {
+ L.DomEvent.stopPropagation(e);
+ }
+ },
+ _unlockGroup: function _unlockGroup() {
+ var _this = this;
+
+ if (!this.hasTool(L.UnlockAction)) {
+ return;
+ }
+
+ this._group.eachLayer(function (layer) {
+ if (_this._group.isCollected(layer)) {
+ var edit = layer.editing;
+
+ edit._unlock(); // unlock updates the layer's handles; deselect to ensure they're hidden
+
+
+ layer.deselect();
+ }
+ });
+ },
+ _lockGroup: function _lockGroup() {
+ var _this2 = this;
+
+ if (!this.hasTool(L.LockAction)) {
+ return;
+ }
+
+ this._group.eachLayer(function (layer) {
+ if (_this2._group.isCollected(layer)) {
+ var edit = layer.editing;
+
+ edit._lock(); // map.addLayer also deselects the image, so we reselect here
+
+
+ L.DomUtil.addClass(layer.getElement(), 'collected');
+ }
+ });
+ },
+ _addCollections: function _addCollections(e) {
+ var _this3 = this;
+
+ var box = e.boxCollectBounds;
+ var map = this._group._map;
+
+ this._group.eachLayer(function (layer) {
+ var edit = layer.editing;
+
+ if (layer.isSelected()) {
+ layer.deselect();
+ }
+
+ var zoom = map.getZoom();
+ var center = map.getCenter();
+ var imgBounds = L.latLngBounds(layer.getCorner(2), layer.getCorner(1));
+ imgBounds = map._latLngBoundsToNewLayerBounds(imgBounds, zoom, center);
+
+ if (box.intersects(imgBounds) && edit.enabled()) {
+ if (!_this3.toolbar) {
+ _this3._addToolbar();
+ }
+
+ L.DomUtil.addClass(layer.getElement(), 'collected');
+ }
+ });
+ },
+ _removeGroup: function _removeGroup(e) {
+ var _this4 = this;
+
+ if (!this.hasTool(L.DeleteAction)) {
+ return;
+ }
+
+ var layersToRemove = this._group._toRemove();
+
+ var n = layersToRemove.length;
+
+ if (n === 0) {
+ return;
+ }
+
+ var choice = L.DomUtil.confirmDeletes(n);
+
+ if (choice) {
+ layersToRemove.forEach(function (layer) {
+ _this4._group.removeLayer(layer);
+ });
+
+ if (!this._group.anyCollected()) {
+ this._removeToolbar();
+ }
+ }
+
+ if (e) {
+ L.DomEvent.stopPropagation(e);
+ }
+ },
+ cancelExport: function cancelExport() {
+ if (!this.customCollection) {
+ this._exportOpts.collection = undefined;
+ }
+
+ clearInterval(this.updateInterval);
+ },
+ _addToolbar: function _addToolbar() {
+ var group = this._group;
+ var map = group._map;
+
+ if (group.options.suppressToolbar || this.toolbar) {
+ return;
+ }
+
+ this.toolbar = L.distortableImage.controlBar({
+ actions: this.editActions,
+ position: 'topleft'
+ }).addTo(map, group);
+ },
+ _removeToolbar: function _removeToolbar() {
+ var map = this._group._map;
+
+ if (this.toolbar) {
+ map.removeLayer(this.toolbar);
+ this.toolbar = false;
+ } else {
+ return false;
+ }
+ },
+ hasTool: function hasTool(value) {
+ return this.editActions.some(function (action) {
+ return action === value;
+ });
+ },
+ addTool: function addTool(value) {
+ if (value.baseClass === 'leaflet-toolbar-icon' && !this.hasTool(value)) {
+ this._removeToolbar();
+
+ this.editActions.push(value);
+
+ this._addToolbar();
+ }
+
+ return this;
+ },
+ removeTool: function removeTool(value) {
+ var _this5 = this;
+
+ this.editActions.some(function (item, idx) {
+ if (_this5.editActions[idx] === value) {
+ _this5._removeToolbar();
+
+ _this5.editActions.splice(idx, 1);
+
+ _this5._addToolbar();
+
+ return true;
+ } else {
+ return false;
+ }
+ });
+ return this;
+ },
+ startExport: function startExport() {
+ var _this6 = this;
+
+ if (!this.hasTool(L.ExportAction)) {
+ return;
+ }
+
+ return new Promise(function (resolve) {
+ var opts = _this6._exportOpts;
+ opts.resolve = resolve; // allow resolving promise in user-defined functions, to stop spinner on completion
+
+ var statusUrl;
+ _this6.updateInterval = null; // this may be overridden to update the UI to show export progress or completion
+
+ var _defaultUpdater = function _defaultUpdater(data) {
+ data = JSON.parse(data); // optimization: fetch status directly from google storage:
+
+ if (data.status_url) {
+ if (statusUrl !== data.status_url && data.status_url.match('.json')) {
+ // if (data.status_url && data.status_url.substr(0,1) === "/") {
+ // opts.statusUrl = opts.statusUrl + data.status_url;
+ // } else {
+ statusUrl = data.status_url; // }
}
- },
- getAngle: function () {
- var t =
- arguments.length > 0 && void 0 !== arguments[0]
- ? arguments[0]
- : "deg",
- e = this.getElement()
- .style[L.DomUtil.TRANSFORM].split("matrix3d")[1]
- .slice(1, -1)
- .split(","),
- i = e[0],
- o = e[1],
- n = e[4],
- a = e[5],
- s = i * a - o * n,
- r = L.TrigUtil.calcAngle(i, o, "rad");
- return (
- s < 0 && (r += r < 0 ? Math.PI : -Math.PI),
- r < 0 && (r = 2 * Math.PI + r),
- "deg" === t
- ? Math.round(L.TrigUtil.radiansToDegrees(r))
- : L.Util.formatNum(r, 2)
- );
- },
- setAngle: function (t) {
- var e =
- arguments.length > 1 && void 0 !== arguments[1]
- ? arguments[1]
- : "deg",
- i = this.getAngle(e),
- o = t - i;
- return this.rotateBy(o, e), this;
- },
- rotateBy: function (t) {
- var e,
- i,
- o,
- n =
- arguments.length > 1 && void 0 !== arguments[1]
- ? arguments[1]
- : "deg",
- a = this._map,
- s = a.project(this.getCenter()),
- r = {};
- for (
- "deg" === n && (t = L.TrigUtil.degreesToRadians(t)), e = 0;
- e < 4;
- e++
- )
- (i = a.project(this.getCorner(e)).subtract(s)),
- (o = L.point(
- Math.cos(t) * i.x - Math.sin(t) * i.y,
- Math.sin(t) * i.x + Math.cos(t) * i.y
- )),
- (r[e] = a.unproject(o.add(s)));
- return this.setCorners(r), this;
- },
- dragBy: function (t, e) {
- var i,
- o,
- n = this._map,
- a = {},
- s = n.project(t).subtract(n.project(e));
- for (i = 0; i < 4; i++)
- (o = n.project(this.getCorner(i)).subtract(s)),
- (a[i] = n.unproject(o));
- this.setCorners(a);
- },
- restore: function () {
- for (
- var t = this._map,
- e = this._initialDimensions.center,
- i = this._initialDimensions.offset,
- o = this._initialDimensions.zoom,
- n = [
- e.subtract(i),
- e.add(L.point(i.x, -i.y)),
- e.add(L.point(-i.x, i.y)),
- e.add(i),
- ],
- a = 0;
- a < 4;
- a++
- )
- t.unproject(n[a], o).equals(this.getCorner(a)) ||
- this.setCorner(a, t.unproject(n[a], o));
- return (this.edited = !1), this.fire("restore"), this;
- },
- _getTranslateString: function (t) {
- var e = L.Browser.webkit3d,
- i = (e ? ",0" : "") + ")";
- return (
- "translate" + (e ? "3d" : "") + "(" + t.x + "px," + t.y + "px" + i
- );
- },
- _reset: function () {
- var t = this._map,
- e = this.getElement(),
- i = L.bind(t.latLngToLayerPoint, t),
- o = this._calculateProjectiveTransform(i),
- n = i(this.getCorner(0)),
- a = L.DomUtil.getMatrixString(o),
- s = this._getTranslateString(n);
- (e._leaflet_pos = n),
- (e.style[L.DomUtil.TRANSFORM] = [s, a].join(" ")),
- (e.style[L.DomUtil.TRANSFORM + "-origin"] = "0 0 0"),
- (this.rotation.deg = this.getAngle()),
- (this.rotation.rad = this.getAngle("rad"));
- },
- _animateZoom: function (t) {
- var e = this._map,
- i = this.getElement(),
- o = function (i) {
- return e._latLngToNewLayerPoint(i, t.zoom, t.center);
- },
- n = this._calculateProjectiveTransform(o),
- a = o(this.getCorner(0)),
- s = L.DomUtil.getMatrixString(n),
- r = this._getTranslateString(a);
- (i._leaflet_pos = a),
- (i.style[L.DomUtil.TRANSFORM] = [r, s].join(" "));
- },
- getCorners: function () {
- return this._corners;
- },
- getCorner: function (t) {
- return this._corners[t];
- },
- getCenter: function () {
- var t = this._map,
- e = this.getCorners().reduce(function (e, i) {
- return e.add(t.project(i));
- }, L.point(0, 0));
- return t.unproject(e.divideBy(4));
- },
- _calculateProjectiveTransform: function (t) {
- var e,
- i = t(this.getCorner(0)),
- o = this.getElement().offsetWidth || 500,
- n = this.getElement().offsetHeight || 375,
- a = [];
- for (e = 0; e < 4; e++) a.push(t(this.getCorner(e))._subtract(i));
- return L.MatrixUtil.general2DProjection(
- 0,
- 0,
- a[0].x,
- a[0].y,
- o,
- 0,
- a[1].x,
- a[1].y,
- 0,
- n,
- a[2].x,
- a[2].y,
- o,
- n,
- a[3].x,
- a[3].y
- );
- },
- })),
- (L.distortableImageOverlay = function (t, e) {
- return new L.DistortableImageOverlay(t, e);
- }),
- L.Map.addInitHook(function () {
- L.DomUtil.hasClass(this.getContainer(), "ldi") ||
- L.DomUtil.addClass(this.getContainer(), "ldi");
- });
- },
- 782: function () {
- var t = this;
- (L.DomUtil = L.DomUtil || {}),
- (L.DistortableImage = L.DistortableImage || {}),
- (L.distortableImage = L.DistortableImage),
- (L.DistortableImage.Keymapper = L.Handler.extend({
- options: { position: "topright" },
- initialize: function (t, e) {
- (this._map = t), L.setOptions(this, e);
- },
- addHooks: function () {
- this._keymapper ||
- ((this._container = this._buildContainer()),
- (this._scrollWrapper = this._wrap()),
- (this._toggler = this._createButton()),
- this._setMapper(
- this._container,
- this._scrollWrapper,
- this._toggler
- ),
- L.DomEvent.on(
- this._toggler,
- "click",
- this._toggleKeymapper,
- this
- ),
- L.DomEvent.disableClickPropagation(this._container),
- L.DomEvent.disableScrollPropagation(this._container));
- },
- removeHooks: function () {
- this._keymapper &&
- (L.DomEvent.off(
- this._toggler,
- "click",
- this._toggleKeymapper,
- this
- ),
- L.DomUtil.remove(this._toggler),
- L.DomUtil.remove(this._scrollWrapper),
- L.DomUtil.remove(this._container),
- (this._keymapper = !1));
- },
- _buildContainer: function () {
- var t = L.DomUtil.create("div", "ldi-keymapper-hide");
- t.setAttribute("id", "ldi-keymapper");
- var e = L.DomUtil.create("br", "divider");
- return t.appendChild(e), t;
- },
- _createButton: function () {
- var t = L.DomUtil.create("a", "");
- return (
- (t.innerHTML = L.IconUtil.create("keyboard_open")),
- t.setAttribute("id", "toggle-keymapper"),
- t.setAttribute("href", "#"),
- t.setAttribute("title", "Show keymap"),
- t.setAttribute("role", "button"),
- t.setAttribute("aria-label", "Show keymap"),
- t
- );
- },
- _wrap: function () {
- var t = L.DomUtil.create("div", "");
- return (
- t.setAttribute("id", "keymapper-wrapper"),
- (t.style.display = "none"),
- t
- );
- },
- _setMapper: function (t, e, i) {
- (this._keymapper = L.control({ position: this.options.position })),
- (this._keymapper.onAdd = function () {
- return (
- t.appendChild(e),
- e.insertAdjacentHTML(
- "beforeend",
- '
Rotate Mode R |
RotateScale Mode r |
Scale Mode s |
Distort Mode d |
Drag Mode D |
Lock (Mode) / Unlock Image l u |
Stack up / down q a |
Add / Remove Image Border b |
Toggle Opacity o |
Deselect All esc |
Delete Image(s) delete backspace |
Export Image(s) e |
'
- ),
- t.appendChild(i),
- t
- );
- }),
- this._keymapper.addTo(this._map);
- },
- _toggleKeymapper: function (t) {
- t.preventDefault(),
- (this._container.className =
- "ldi-keymapper leaflet-control" === this._container.className
- ? "ldi-keymapper-hide leaflet-control"
- : "ldi-keymapper leaflet-control"),
- (this._scrollWrapper.style.display =
- "none" === this._scrollWrapper.style.display
- ? "block"
- : "none"),
- (this._toggler.innerHTML =
- "close" === this._toggler.innerHTML
- ? L.IconUtil.create("keyboard_open")
- : "close"),
- L.IconUtil.toggleTitle(
- this._toggler,
- "Show keymap",
- "Hide keymap"
- ),
- L.DomUtil.toggleClass(this._toggler, "close-icon");
- },
- _injectIconSet: function () {
- if (!document.querySelector("#keymapper-iconset")) {
- var t = L.DomUtil.create("div", "");
- (t.id = "keymapper-iconset"),
- t.setAttribute("hidden", "hidden"),
- (this._iconset = new L.KeymapperIconSet().render()),
- (t.innerHTML = this._iconset),
- document
- .querySelector(".leaflet-control-container")
- .appendChild(t);
+
+ if (data.status === 'complete') {
+ clearInterval(_this6.updateInterval);
+
+ if (!_this6.customCollection) {
+ _this6._exportOpts.collection = undefined;
}
- },
- })),
- L.DistortableImage.Keymapper.addInitHook(function () {
- (L.DistortableImage.Keymapper.prototype._n = L.DistortableImage
- .Keymapper.prototype._n
- ? L.DistortableImage.Keymapper.prototype._n + 1
- : 1),
- 1 !== L.DistortableImage.Keymapper.prototype._n ||
- L.Browser.mobile ||
- (t.enable(), t._injectIconSet());
- }),
- (L.distortableImage.keymapper = function (t, e) {
- return new L.DistortableImage.Keymapper(t, e);
- });
- },
- 428: function () {
- (L.DistortableImage = L.DistortableImage || {}),
- (L.DistortableCollection.Edit = L.Handler.extend({
- options: { keymap: L.distortableImage.group_action_map },
- initialize: function (t, e) {
- (this._group = t),
- (this._exportOpts = t.options.exportOpts),
- L.setOptions(this, e),
- (L.distortableImage.group_action_map.Escape = "_decollectAll");
- },
- addHooks: function () {
- var t = this._group._map;
- (this.editActions = this.options.actions),
- (this.runExporter = L.bind(
- L.Utils.getNestedVal(this, "_exportOpts", "exporter") ||
- this.startExport,
- this
- )),
- L.DomEvent.on(document, "keydown", this._onKeyDown, this),
- t.doubleClickZoom.enabled() ||
- t.doubleClickLabels.enabled() ||
- L.DomEvent.on(t, "click", this._decollectAll, this),
- L.DomEvent.on(
- t,
- {
- singleclickon: this._singleClickListeners,
- singleclickoff: this._resetClickListeners,
- singleclick: this._singleClick,
- boxcollectend: this._addCollections,
- },
- this
- ),
- (this._group.editable = !0),
- this._group.eachLayer(function (t) {
- return t.editing.enable();
- });
- },
- removeHooks: function () {
- var t = this._group._map;
- L.DomEvent.off(document, "keydown", this._onKeyDown, this),
- t.doubleClickZoom.enabled() ||
- t.doubleClickLabels.enabled() ||
- L.DomEvent.off(t, "click", this._decollectAll, this),
- L.DomEvent.off(
- t,
- {
- singleclickon: this._singleClickListeners,
- singleclickoff: this._resetClickListeners,
- singleclick: this._singleClick,
- boxcollectend: this._addCollections,
- },
- this
- ),
- this._decollectAll(),
- (this._group.editable = !1),
- this._group.eachLayer(function (t) {
- return t.editing.disable();
- });
- },
- enable: function () {
- return (this._enabled = !0), this.addHooks(), this;
- },
- disable: function () {
- return (this._enabled = !1), this.removeHooks(), this;
- },
- _onKeyDown: function (t) {
- var e = this.options.keymap[t.key];
- this[e] && this._group.anyCollected() && this[e].call(this);
- },
- _singleClick: function (t) {
- "singleclick" === t.type && this._decollectAll(t);
- },
- _singleClickListeners: function () {
- var t = this._group._map;
- L.DomEvent.off(t, "click", this._decollectAll, this),
- L.DomEvent.on(t, "singleclick", this._decollectAll, this);
- },
- _resetClickListeners: function () {
- var t = this._group._map;
- L.DomEvent.on(t, "click", this._decollectAll, this),
- L.DomEvent.off(t, "singleclick", this._decollectAll, this);
- },
- _decollectAll: function (t) {
- var e;
- t && (e = t.originalEvent),
- (e && (e.shiftKey || e.target instanceof HTMLImageElement)) ||
- (this._group.eachLayer(function (t) {
- L.DomUtil.removeClass(t.getElement(), "collected"),
- t.deselect();
- }),
- this._removeToolbar(),
- t && L.DomEvent.stopPropagation(t));
- },
- _unlockGroup: function () {
- var t = this;
- this.hasTool(L.UnlockAction) &&
- this._group.eachLayer(function (e) {
- t._group.isCollected(e) && (e.editing._unlock(), e.deselect());
- });
- },
- _lockGroup: function () {
- var t = this;
- this.hasTool(L.LockAction) &&
- this._group.eachLayer(function (e) {
- t._group.isCollected(e) &&
- (e.editing._lock(),
- L.DomUtil.addClass(e.getElement(), "collected"));
- });
- },
- _addCollections: function (t) {
- var e = this,
- i = t.boxCollectBounds,
- o = this._group._map;
- this._group.eachLayer(function (t) {
- var n = t.editing;
- t.isSelected() && t.deselect();
- var a = o.getZoom(),
- s = o.getCenter(),
- r = L.latLngBounds(t.getCorner(2), t.getCorner(1));
- (r = o._latLngBoundsToNewLayerBounds(r, a, s)),
- i.intersects(r) &&
- n.enabled() &&
- (e.toolbar || e._addToolbar(),
- L.DomUtil.addClass(t.getElement(), "collected"));
- });
- },
- _removeGroup: function (t) {
- var e = this;
- if (this.hasTool(L.DeleteAction)) {
- var i = this._group._toRemove(),
- o = i.length;
- 0 !== o &&
- (L.DomUtil.confirmDeletes(o) &&
- (i.forEach(function (t) {
- e._group.removeLayer(t);
- }),
- this._group.anyCollected() || this._removeToolbar()),
- t && L.DomEvent.stopPropagation(t));
- }
- },
- cancelExport: function () {
- this.customCollection || (this._exportOpts.collection = void 0),
- clearInterval(this.updateInterval);
- },
- _addToolbar: function () {
- var t = this._group,
- e = t._map;
- t.options.suppressToolbar ||
- this.toolbar ||
- (this.toolbar = L.distortableImage
- .controlBar({ actions: this.editActions, position: "topleft" })
- .addTo(e, t));
- },
- _removeToolbar: function () {
- var t = this._group._map;
- if (!this.toolbar) return !1;
- t.removeLayer(this.toolbar), (this.toolbar = !1);
- },
- hasTool: function (t) {
- return this.editActions.some(function (e) {
- return e === t;
- });
- },
- addTool: function (t) {
- return (
- "leaflet-toolbar-icon" !== t.baseClass ||
- this.hasTool(t) ||
- (this._removeToolbar(),
- this.editActions.push(t),
- this._addToolbar()),
- this
- );
- },
- removeTool: function (t) {
- var e = this;
- return (
- this.editActions.some(function (i, o) {
- return (
- e.editActions[o] === t &&
- (e._removeToolbar(),
- e.editActions.splice(o, 1),
- e._addToolbar(),
- !0)
- );
- }),
- this
- );
- },
- startExport: function () {
- var t = this;
- if (this.hasTool(L.ExportAction))
- return new Promise(function (e) {
- var i,
- o = t._exportOpts;
- (o.resolve = e),
- (t.updateInterval = null),
- (t.customCollection = !!o.collection),
- t.customCollection ||
- (o.collection = t._group.generateExportJson().images),
- (o.frequency = o.frequency || 3e3),
- (o.scale = o.scale || 100),
- (o.updater =
- o.updater ||
- function (n) {
- (n = JSON.parse(n)).status_url &&
- (i !== n.status_url &&
- n.status_url.match(".json") &&
- (i = n.status_url),
- "complete" === n.status &&
- (clearInterval(t.updateInterval),
- t.customCollection ||
- (t._exportOpts.collection = void 0),
- e(),
- null !== n.jpg &&
- alert("Export succeeded. " + o.exportUrl + n.jpg)),
- console.log(n));
- }),
- (o.handleStatusRes =
- o.handleStatusRes ||
- function (e) {
- (i = o.statusUrl + e),
- (t.updateInterval = setInterval(function () {
- var t = new Request(
- "".concat(i, "?").concat(Date.now()),
- { method: "GET" }
- );
- fetch(t)
- .then(function (t) {
- if (t.ok) return t.text();
- })
- .then(o.updater);
- }, o.frequency));
- }),
- (o.fetchStatusUrl =
- o.fetchStatusUrl ||
- function (t) {
- var e = new FormData();
- e.append("collection", JSON.stringify(t.collection)),
- e.append("scale", t.scale),
- e.append("upload", !0);
- var i = { method: "POST", body: e },
- o = new Request(t.exportStartUrl, i);
- fetch(o)
- .then(function (t) {
- if (t.ok) return t.text();
- })
- .then(t.handleStatusRes);
- }),
- o.fetchStatusUrl(o);
- });
- },
- })),
- (L.distortableCollection.edit = function (t, e) {
- return new L.DistortableCollection.Edit(t, e);
- });
- },
- 397: function () {
- (L.DistortableImage = L.DistortableImage || {}),
- (L.DistortableImage.Edit = L.Handler.extend({
- options: {
- opacity: 0.7,
- outline: "1px solid red",
- keymap: L.distortableImage.action_map,
- },
- initialize: function (t, e) {
- (this._overlay = t),
- (this._toggledImage = !1),
- (this._mode = t.options.mode),
- (this._transparent = !1),
- (this._outlined = !1),
- L.setOptions(this, e),
- (L.distortableImage.action_map.Escape = "_deselect");
- },
- addHooks: function () {
- var t = this._overlay;
- (this.editActions = this.options.actions),
- t.bringToFront(),
- this._initModes(),
- this._initHandles(),
- this._appendHandlesandDragable(),
- t.isSelected() &&
- !t.options.suppressToolbar &&
- this._addToolbar(),
- (this.parentGroup = !!t.eP && t.eP),
- L.DomEvent.on(t.getElement(), { dblclick: this.nextMode }, this),
- L.DomEvent.on(window, "keydown", this._onKeyDown, this);
- },
- removeHooks: function () {
- var t = this._overlay,
- e = this.parentGroup;
- for (var i in (this._disableDragging(),
- this.toolbar && this._removeToolbar(),
- this._handles))
- L.DomUtil.remove(i);
- L.DomUtil.hasClass(t.getElement(), "collected") &&
- L.DomUtil.removeClass(t.getElement(), "collected"),
- e &&
- !e.anyCollected() &&
- e.editing.toolbar &&
- e.editing._removeToolbar(),
- L.DomEvent.off(t.getElement(), { dblclick: this.nextMode }, this),
- L.DomEvent.off(window, "keydown", this._onKeyDown, this);
- },
- disable: function () {
- return this._enabled
- ? (this._overlay.deselect(),
- (this._enabled = !1),
- this.removeHooks(),
- this)
- : this;
- },
- _initModes: function () {
- for (var t in ((this._modes = {}), L.DistortableImage.Edit.MODES)) {
- var e = L.DistortableImage.Edit.MODES[t];
- -1 !== this.editActions.indexOf(e) && (this._modes[t] = e);
- }
- this._modes[this._mode] ||
- (this._mode = Object.keys(this._modes)[0]);
- },
- _initHandles: function () {
- var t,
- e = this._overlay;
- for (this._dragHandles = L.layerGroup(), t = 0; t < 4; t++)
- this._dragHandles.addLayer(L.dragHandle(e, t));
- for (this._scaleHandles = L.layerGroup(), t = 0; t < 4; t++)
- this._scaleHandles.addLayer(L.scaleHandle(e, t));
- for (this._distortHandles = L.layerGroup(), t = 0; t < 4; t++)
- this._distortHandles.addLayer(L.distortHandle(e, t));
- for (this._rotateHandles = L.layerGroup(), t = 0; t < 4; t++)
- this._rotateHandles.addLayer(L.rotateHandle(e, t));
- for (this._freeRotateHandles = L.layerGroup(), t = 0; t < 4; t++)
- this._freeRotateHandles.addLayer(L.freeRotateHandle(e, t));
- for (this._lockHandles = L.layerGroup(), t = 0; t < 4; t++)
- this._lockHandles.addLayer(L.lockHandle(e, t, { draggable: !1 }));
- this._handles = {
- drag: this._dragHandles,
- scale: this._scaleHandles,
- distort: this._distortHandles,
- rotate: this._rotateHandles,
- freeRotate: this._freeRotateHandles,
- lock: this._lockHandles,
- };
- },
- _appendHandlesandDragable: function () {
- var t = this._overlay;
- this._mode
- ? (this._updateHandle(),
- !t.isSelected() &&
- this.currentHandle &&
- this.currentHandle.eachLayer(function (t) {
- t.setOpacity(0), t.dragging && t.dragging.disable();
- }),
- this.isMode("lock") || this._enableDragging())
- : this._enableDragging();
- },
- _onKeyDown: function (t) {
- var e = this.options.keymap[t.key],
- i = this._overlay,
- o = this.parentGroup;
- (o && o.anyCollected()) ||
- void 0 === this[e] ||
- i.options.suppressToolbar ||
- (i.isSelected() && this.toolbar && this[e].call(this));
- },
- replaceTool: function (t, e) {
- var i = this;
- return (
- "leaflet-toolbar-icon" !== e.baseClass ||
- this.hasTool(e) ||
- this.editActions.some(function (o, n) {
- if (o === t) {
- for (var a in (i._removeToolbar(),
- (i.editActions[n] = e),
- i._addToolbar(),
- L.DistortableImage.Edit.MODES))
- L.DistortableImage.Edit.MODES[a] === t
- ? (delete i._modes[a], i._nextOrNone(a))
- : L.DistortableImage.Edit.MODES[a] === e &&
- (i._modes[a] = e);
- return !0;
- }
- }),
- this
- );
- },
- addTool: function (t) {
- if ("leaflet-toolbar-icon" === t.baseClass && !this.hasTool(t)) {
- for (var e in (this._removeToolbar(),
- this.editActions.push(t),
- this._addToolbar(),
- L.DistortableImage.Edit.MODES))
- L.DistortableImage.Edit.MODES[e] === t && (this._modes[e] = t);
- this._overlay.isSelected() || this._removeToolbar();
- }
- return this;
- },
- hasTool: function (t) {
- return this.editActions.some(function (e) {
- return e === t;
- });
- },
- removeTool: function (t) {
- var e = this;
- return (
- this.editActions.some(function (i, o) {
- if (i === t) {
- for (var n in (e._removeToolbar(),
- e.editActions.splice(o, 1),
- e._addToolbar(),
- L.DistortableImage.Edit.MODES))
- L.DistortableImage.Edit.MODES[n] === t &&
- (delete e._modes[n], e._nextOrNone(n));
- return !0;
- }
- }),
- this._overlay.isSelected() || this._removeToolbar(),
- this
- );
- },
- _nextOrNone: function (t) {
- this.isMode(t) &&
- (Object.keys(this.getModes()).length >= 1
- ? this.nextMode()
- : ("lock" === t && this._enableDragging(),
- (this._mode = ""),
- this._updateHandle()));
- },
- _removeToolbar: function () {
- var t = this._overlay._map;
- this.toolbar && (t.removeLayer(this.toolbar), (this.toolbar = !1));
- },
- _enableDragging: function () {
- var t = this,
- e = this._overlay,
- i = e._map;
- (this.dragging = new L.Draggable(e.getElement())),
- this.dragging.enable(),
- this.dragging.on("dragstart", function () {
- e.fire("dragstart"), t._removeToolbar();
- }),
- (this.dragging._updatePosition = function () {
- var t,
- o,
- n = e.getCorner(0),
- a = this._newPos.subtract(i.latLngToLayerPoint(n)),
- s = {};
- for (this.fire("predrag"), o = 0; o < 4; o++)
- (t = i.latLngToLayerPoint(e.getCorner(o))),
- (s[o] = i.layerPointToLatLng(t.add(a)));
- e.setCorners(s), e.fire("drag"), this.fire("drag");
- }),
- this.dragging.on("dragend", function () {
- e.fire("dragend");
- });
- },
- _disableDragging: function () {
- this.dragging && (this.dragging.disable(), delete this.dragging);
- },
- _dragMode: function () {
- this.setMode("drag");
- },
- _scaleMode: function () {
- this.setMode("scale");
- },
- _distortMode: function () {
- this.setMode("distort");
- },
- _rotateMode: function () {
- this.setMode("rotate");
- },
- _freeRotateMode: function () {
- this.setMode("freeRotate");
- },
- _toggleLockMode: function () {
- this.isMode("lock") ? this._unlock() : this._lock();
- },
- _toggleOpacity: function () {
- var t,
- e = this._overlay.getElement();
- this.hasTool(L.OpacityAction) &&
- ((this._transparent = !this._transparent),
- (t = this._transparent ? this.options.opacity : 1),
- L.DomUtil.setOpacity(e, t),
- e.setAttribute("opacity", t),
- this._refresh());
- },
- _toggleBorder: function () {
- var t,
- e = this._overlay.getElement();
- this.hasTool(L.BorderAction) &&
- ((this._outlined = !this._outlined),
- (t = this._outlined ? this.options.outline : "none"),
- (e.style.outline = t),
- this._refresh());
- },
- _toggleOrder: function () {
- this._toggledImage ? this._stackUp() : this._stackDown();
- },
- _removeOverlay: function () {
- var t = this._overlay,
- e = this.parentGroup;
- !this.isMode("lock") &&
- this.hasTool(L.DeleteAction) &&
- L.DomUtil.confirmDelete() &&
- (this._removeToolbar(),
- e ? e.removeLayer(t) : t._map.removeLayer(t));
- },
- _getExport: function () {
- var t = this._overlay,
- e = t._map,
- i = t.getElement();
- if (this.hasTool(L.ExportAction)) {
- var o = new Image();
- (o.id = o.id || "tempId12345"),
- document.body.appendChild(o),
- (o.onload = function () {
- var i = o.height,
- n = o.width,
- a = e.latLngToLayerPoint(t.getCorner(0)),
- s = e.latLngToLayerPoint(t.getCorner(1)),
- r = e.latLngToLayerPoint(t.getCorner(2)),
- l = e.latLngToLayerPoint(t.getCorner(3));
- (o.onload = function () {
- L.DomUtil.remove(o);
- }),
- window &&
- window.hasOwnProperty("warpWebGl") &&
- warpWebGl(
- o.id,
- [0, 0, n, 0, n, i, 0, i],
- [a.x, a.y, s.x, s.y, l.x, l.y, r.x, r.y],
- !0
- );
- }),
- (o.src = t.options.fullResolutionSrc || i.src);
+
+ resolve();
+
+ if (data.jpg !== null) {
+ alert('Export succeeded. ' + opts.exportUrl + data.jpg);
}
- },
- _stackUp: function () {
- this._toggledImage &&
- this.hasTool(L.StackAction) &&
- ((this._toggledImage = !1),
- this._overlay.bringToFront(),
- this._refresh());
- },
- _stackDown: function () {
- !this._toggledImage &&
- this.hasTool(L.StackAction) &&
- ((this._toggledImage = !0),
- this._overlay.bringToBack(),
- this._refresh());
- },
- _unlock: function () {
- var t = this._overlay,
- e = t._map,
- i = this.parentGroup;
- this.isMode("lock") &&
- (((!i || i.isCollected(t)) && i) || this.hasTool(L.LockAction)) &&
- (this.currentHandle && e.removeLayer(this.currentHandle),
- "lock" !== t.options.mode && this.hasMode(t.options.mode)
- ? (this._mode = t.options.mode)
- : ((this._mode = ""), (this.currentHandle = "")),
- this._updateHandle(),
- this._enableDragging(),
- this._refresh());
- },
- _lock: function () {
- var t = this._overlay,
- e = t._map,
- i = this.parentGroup;
- this.isMode("lock") ||
- ((((!i || i.isCollected(t)) && i) ||
- this.hasTool(L.LockAction)) &&
- (this.currentHandle && e.removeLayer(this.currentHandle),
- (this._mode = "lock"),
- this._updateHandle(),
- this._disableDragging(),
- this._refresh()));
- },
- _deselect: function () {
- this._overlay.deselect();
- },
- _showMarkers: function (t) {
- var e = this.parentGroup;
- this.currentHandle &&
- ((!this.isMode("lock") && e && e.anyCollected()) ||
- this.currentHandle.eachLayer(function (t) {
- t.setOpacity(1),
- t.dragging && t.dragging.enable(),
- L.DomUtil.addClass(t.getElement(), "leaflet-interactive");
- }));
- },
- _hideMarkers: function () {
- var t = this._overlay,
- e = this.parentGroup;
- this._handles || this._initHandles(),
- this.currentHandle &&
- ((this.isMode("lock") && e && e.isCollected(t)) ||
- this.currentHandle.eachLayer(function (t) {
- t.setOpacity(0),
- t.dragging && t.dragging.disable(),
- L.DomUtil.removeClass(
- t.getElement(),
- "leaflet-interactive"
- );
- }));
- },
- _updateHandle: function () {
- var t = this._overlay._map,
- e = this.getMode();
- this.currentHandle && t.removeLayer(this.currentHandle),
- (this.currentHandle = "" === e ? "" : this._handles[e]),
- "" !== this.currentHandle && t.addLayer(this.currentHandle);
- },
- _addToolbar: function () {
- var t = this._overlay,
- e = this.parentGroup,
- i = t._map,
- o = t.getCorners(),
- n = -1 / 0;
- if (e && e.anyCollected()) e.editing._addToolbar();
- else if (!t.options.suppressToolbar && !this.toolbar) {
- for (var a = 0; a < o.length; a++) o[a].lat > n && (n = o[a].lat);
- var s = t.getCenter();
- (s.lat = n),
- (this.toolbar = L.distortableImage
- .popupBar(s, { actions: this.editActions })
- .addTo(i, t)),
- t.fire("toolbar:created");
- }
- },
- _refresh: function () {
- this.toolbar && this._removeToolbar(), this._addToolbar();
- },
- _updateToolbarPos: function () {
- var t = this._overlay,
- e = t.getCorners(),
- i = this.toolbar,
- o = -1 / 0;
- if (i && i instanceof L.DistortableImage.PopupBar) {
- for (var n = 0; n < e.length; n++) e[n].lat > o && (o = e[n].lat);
- var a = t.getCenter();
- (a.lat = o),
- t.options.suppressToolbar || this.toolbar.setLatLng(a);
- }
- },
- hasMode: function (t) {
- return !!this._modes[t];
- },
- getMode: function () {
- if (this.enabled()) return this._mode;
- },
- getModes: function () {
- return this._modes;
- },
- isMode: function (t) {
- return !!this.enabled() && this._mode === t;
- },
- setMode: function (t) {
- var e = this._overlay,
- i = this.parentGroup;
- if (this.getMode() !== t && this.hasMode(t) && this.enabled())
- return (
- this.toolbar && this.toolbar.clickTool(t),
- this.isMode("lock") && !this.dragging && this._enableDragging(),
- (this._mode = t),
- this.isMode("lock") && this._disableDragging(),
- this._updateHandle(),
- this._refresh(),
- i && i.isCollected(e) && e.deselect(),
- this
- );
- },
- nextMode: function (t) {
- var e = this.getMode(),
- i = this.parentGroup,
- o = Object.keys(this.getModes()),
- n = o.indexOf(e),
- a = o[(n + 1) % o.length];
- if (t) {
- if (i && i.anyCollected()) return;
- L.DomEvent.stop(t);
- }
- return this.setMode(a);
- },
- })),
- (L.distortableImage.edit = function (t, e) {
- return new L.DistortableImage.Edit(t, e);
- });
- },
- 426: function () {
- L.BorderAction = L.EditAction.extend({
- initialize: function (t, e, i) {
- var o,
- n,
- a = e.editing,
- s = a._mode;
- a._outlined
- ? ((o = "border_outer"), (n = e.options.translation.removeBorder))
- : ((o = "border_clear"), (n = e.options.translation.addBorder)),
- ((i = i || {}).toolbarIcon = {
- svg: !0,
- html: o,
- tooltip: n,
- className: "lock" === s ? "disabled" : "",
- }),
- (L.DistortableImage.action_map.b =
- "lock" === s ? "" : "_toggleBorder"),
- L.EditAction.prototype.initialize.call(this, t, e, i);
- },
- addHooks: function () {
- var t = this._overlay.editing;
- L.IconUtil.toggleXlink(this._link, "border_clear", "border_outer"),
- L.IconUtil.toggleTitle(this._link, "Remove Border", "Add Border"),
- t._toggleBorder();
- },
- });
- },
- 114: function () {
- L.DeleteAction = L.EditAction.extend({
- initialize: function (t, e, i) {
- var o,
- n = e.editing;
- n instanceof L.DistortableImage.Edit
- ? ((o = e.options.translation.deleteImage),
- (L.DistortableImage.action_map.Backspace =
- "lock" === n._mode ? "" : "_removeOverlay"))
- : ((o = e.options.translation.deleteImages),
- (L.DistortableImage.group_action_map.Backspace =
- "lock" === n._mode ? "" : "_removeGroup")),
- ((i = i || {}).toolbarIcon = {
- svg: !0,
- html: "delete_forever",
- tooltip: o,
- className: "lock" === n._mode ? "disabled" : "",
- }),
- L.EditAction.prototype.initialize.call(this, t, e, i);
- },
- addHooks: function () {
- var t = this._overlay.editing;
- t instanceof L.DistortableImage.Edit
- ? t._removeOverlay()
- : t._removeGroup();
- },
- });
- },
- 231: function () {
- L.DistortAction = L.EditAction.extend({
- initialize: function (t, e, i) {
- ((i = i || {}).toolbarIcon = {
- svg: !0,
- html: "distort",
- tooltip: e.options.translation.distortImage,
- className: "distort",
- }),
- (L.DistortableImage.action_map.d = "_distortMode"),
- L.EditAction.prototype.initialize.call(this, t, e, i);
- },
- addHooks: function () {
- this._overlay.editing._distortMode();
- },
- });
- },
- 541: function () {
- L.DragAction = L.EditAction.extend({
- initialize: function (t, e, i) {
- ((i = i || {}).toolbarIcon = {
- svg: !0,
- html: "drag",
- tooltip: e.options.translation.dragImage,
- className: "drag",
- }),
- (L.DistortableImage.action_map.D = "_dragMode"),
- L.EditAction.prototype.initialize.call(this, t, e, i);
- },
- addHooks: function () {
- this._overlay.editing._dragMode();
- },
- });
- },
- 280: function () {
- (L.DistortableImage = L.DistortableImage || {}),
- (L.distortableImage = L.DistortableImage),
- (L.DistortableImage.action_map = {}),
- (L.EditAction = L.Toolbar2.Action.extend({
- options: {
- toolbarIcon: { svg: !1, html: "", className: "", tooltip: "" },
- },
- initialize: function (t, e, i) {
- (this._overlay = e),
- (this._map = t),
- L.setOptions(this, i),
- L.Toolbar2.Action.prototype.initialize.call(this, i),
- this._injectIconSet();
- },
- _createIcon: function (t, e, i) {
- var o = this,
- n = this.options.toolbarIcon,
- a = n.className,
- s = this._overlay.editing;
- (this.toolbar = t),
- (this._icon = L.DomUtil.create("li", "", e)),
- (this._link = L.DomUtil.create("a", "", this._icon)),
- n.svg
- ? (this._link.innerHTML = L.IconUtil.create(n.html))
- : (this._link.innerHTML = n.html),
- this._link.setAttribute("href", "#"),
- this._link.setAttribute("title", n.tooltip),
- this._link.setAttribute("role", "button"),
- L.DomUtil.addClass(this._link, this.constructor.baseClass),
- a &&
- (L.DomUtil.addClass(this._link, a),
- "disabled" === a && L.DomUtil.addClass(this._icon, a),
- a === s._mode
- ? L.DomUtil.addClass(this._link, "selected-mode")
- : L.DomUtil.removeClass(this._link, "selected-mode")),
- L.DomEvent.on(this._link, "click", this.enable, this),
- L.DomEvent.on(this._overlay, "update", function () {
- var t = o._link.innerHTML.match(/xlink:href="#restore"/);
- t && 1 === t.length && o._enableAction();
- }),
- this._addSubToolbar(t, this._icon, i);
- },
- _injectIconSet: function () {
- if (!document.querySelector("#iconset")) {
- var t = document.createElement("div");
- (t.id = "iconset"),
- t.setAttribute("hidden", "hidden"),
- (t.innerHTML = new L.ToolbarIconSet().render()),
- document.querySelector(".leaflet-marker-pane").appendChild(t);
+ } // TODO: update to clearInterval when status == "failed" if we update that in this file:
+ // https://github.com/publiclab/mapknitter-exporter/blob/main/lib/mapknitterExporter.rb
+
+
+ console.log(data);
+ }
+ }; // receives the URL of status.json, and starts running the updater to repeatedly fetch from status.json;
+ // this may be overridden to integrate with any UI
+
+
+ var _defaultHandleStatusRes = function _defaultHandleStatusRes(data) {
+ statusUrl = opts.statusUrl + data; // repeatedly fetch the status.json
+
+ _this6.updateInterval = setInterval(function () {
+ var reqOpts = {
+ method: 'GET'
+ };
+ var req = new Request("".concat(statusUrl, "?").concat(Date.now()), reqOpts);
+ fetch(req).then(function (res) {
+ if (res.ok) {
+ return res.text();
}
- },
- _enableAction: function () {
- L.DomUtil.removeClass(this._link.parentElement, "disabled"),
- L.DomUtil.removeClass(this._link, "disabled");
- },
- _disableAction: function () {
- L.DomUtil.addClass(this._link.parentElement, "disabled"),
- L.DomUtil.addClass(this._link, "disabled");
- },
- })),
- (L.editAction = function (t, e, i) {
- return new L.EditAction(t, e, i);
- });
- },
- 149: function () {
- L.ExportAction = L.EditAction.extend({
- initialize: function (t, e, i) {
- var o,
- n = e.editing;
- (this.isExporting = !1),
- (this.mouseLeaveSkip = !0),
- (this.isHooksExecuted = !1),
- n instanceof L.DistortableImage.Edit
- ? ((L.DistortableImage.action_map.e = "_getExport"),
- (o = e.options.translation.exportImage))
- : ((L.DistortableImage.group_action_map.e = "runExporter"),
- (o = e.options.translation.exportImages)),
- ((i = i || {}).toolbarIcon = {
- svg: !0,
- html: "get_app",
- tooltip: o,
- }),
- L.EditAction.prototype.initialize.call(this, t, e, i);
- },
- addHooks: function () {
- var t = this._overlay.editing;
- if (t instanceof L.DistortableImage.Edit) t._getExport();
- else if (!this.isHooksExecuted) {
- this.isHooksExecuted = !0;
- var e = this._link.parentElement;
- (this.mouseEnterHandler = this.handleMouseEnter.bind(this)),
- (this.mouseLeaveHandler = this.handleMouseLeave.bind(this)),
- L.DomEvent.on(
- e,
- "click",
- function () {
- if (this.isExporting) {
- if (this.mouseLeaveSkip) return;
- this.resetState(),
- this.detachMouseEventListeners(e),
- t.cancelExport();
- } else
- (this.isExporting = !0),
- this.renderExportIcon(),
- setTimeout(
- this.attachMouseEventListeners.bind(this, e),
- 100
- ),
- t.runExporter().then(
- function () {
- this.resetState(), this.detachMouseEventListeners(e);
- }.bind(this)
- );
- },
- this
- );
+ }).then(opts.updater);
+ }, opts.frequency);
+ }; // initiate the export
+
+
+ var _defaultFetchStatusUrl = function _defaultFetchStatusUrl(mergedOpts) {
+ var form = new FormData();
+ form.append('collection', JSON.stringify(mergedOpts.collection));
+ form.append('scale', mergedOpts.scale);
+ form.append('upload', true);
+ var reqOpts = {
+ method: 'POST',
+ body: form
+ };
+ var req = new Request(mergedOpts.exportStartUrl, reqOpts);
+ fetch(req).then(function (res) {
+ if (res.ok) {
+ return res.text();
}
- },
- resetState: function () {
- this.renderDownloadIcon(),
- (this.isExporting = !1),
- (this.mouseLeaveSkip = !0);
- },
- attachMouseEventListeners: function (t) {
- t.addEventListener("mouseenter", this.mouseEnterHandler),
- t.addEventListener("mouseleave", this.mouseLeaveHandler);
- },
- detachMouseEventListeners: function (t) {
- t.removeEventListener("mouseenter", this.mouseEnterHandler),
- t.removeEventListener("mouseleave", this.mouseLeaveHandler);
- },
- handleMouseEnter: function () {
- this.renderCancelIcon();
- },
- handleMouseLeave: function () {
- this.mouseLeaveSkip
- ? (this.mouseLeaveSkip = !1)
- : this.renderExportIcon();
- },
- renderDownloadIcon: function () {
- L.IconUtil.toggleXlink(this._link, "get_app", "spinner"),
- L.IconUtil.toggleTitle(this._link, "Export Images", "Loading..."),
- L.DomUtil.removeClass(this._link.firstChild, "loader");
- },
- renderExportIcon: function () {
- L.IconUtil.toggleXlink(this._link, "spinner"),
- L.IconUtil.toggleTitle(this._link, "Export Images", "Loading..."),
- L.IconUtil.addClassToSvg(this._link, "loader");
- },
- renderCancelIcon: function () {
- L.IconUtil.toggleXlink(this._link, "cancel"),
- L.IconUtil.toggleTitle(this._link, "Cancel Export", "Loading..."),
- L.DomUtil.removeClass(this._link.firstChild, "loader");
- },
- });
- },
- 74: function () {
- L.FreeRotateAction = L.EditAction.extend({
- initialize: function (t, e, i) {
- ((i = i || {}).toolbarIcon = {
- svg: !0,
- html: "crop_rotate",
- tooltip: e.options.translation.freeRotateImage,
- className: "freeRotate",
- }),
- (L.DistortableImage.action_map.f = "_freeRotateMode"),
- L.EditAction.prototype.initialize.call(this, t, e, i);
- },
- addHooks: function () {
- this._overlay.editing._freeRotateMode();
- },
- });
- },
- 691: function () {
- L.GeolocateAction = L.EditAction.extend({
- initialize: function (t, e, i) {
- var o = e.editing;
- ((i = i || {}).toolbarIcon = {
- svg: !0,
- html: "explore",
- tooltip: e.options.translation.geolocateImage,
- className: "lock" === o._mode ? "disabled" : "",
- }),
- L.EditAction.prototype.initialize.call(this, t, e, i);
- },
- addHooks: function () {
- var t = this._overlay.getElement();
- EXIF.getData(t, L.EXIF(t));
- },
- });
- },
- 105: function () {
- L.LockAction = L.EditAction.extend({
- initialize: function (t, e, i) {
- var o,
- n,
- a = e.editing;
- a instanceof L.DistortableImage.Edit
- ? ((L.DistortableImage.action_map.u = "_unlock"),
- (L.DistortableImage.action_map.l = "_lock"),
- (n = e.options.translation.lockMode),
- (o = a.isMode("lock") ? "lock" : "unlock"))
- : ((L.DistortableImage.group_action_map.l = "_lockGroup"),
- (n = e.options.translation.lockImages),
- (o = "lock")),
- ((i = i || {}).toolbarIcon = {
- svg: !0,
- html: o,
- tooltip: n,
- className: "lock",
- }),
- L.EditAction.prototype.initialize.call(this, t, e, i);
- },
- addHooks: function () {
- var t = this._overlay.editing;
- t instanceof L.DistortableImage.Edit
- ? t._toggleLockMode()
- : t._lockGroup();
- },
- });
- },
- 944: function () {
- L.OpacityAction = L.EditAction.extend({
- initialize: function (t, e, i) {
- var o,
- n,
- a = e.editing,
- s = a._mode;
- a._transparent
- ? ((o = "opacity_empty"),
- (n = e.options.translation.makeImageOpaque))
- : ((o = "opacity"),
- (n = e.options.translation.makeImageTransparent)),
- ((i = i || {}).toolbarIcon = {
- svg: !0,
- html: o,
- tooltip: n,
- className: "lock" === s ? "disabled" : "",
- }),
- (L.DistortableImage.action_map.o =
- "lock" === s ? "" : "_toggleOpacity"),
- L.EditAction.prototype.initialize.call(this, t, e, i);
- },
- addHooks: function () {
- var t = this._overlay.editing,
- e = this._link;
- L.IconUtil.toggleXlink(e, "opacity", "opacity_empty"),
- L.IconUtil.toggleTitle(
- e,
- "Make Image Transparent",
- "Make Image Opaque"
- ),
- t._toggleOpacity();
- },
- });
- },
- 954: function () {
- L.RestoreAction = L.EditAction.extend({
- initialize: function (t, e, i) {
- var o = L.Utils.getNestedVal(e, "editing", "_mode"),
- n = e.edited;
- ((i = i || {}).toolbarIcon = {
- svg: !0,
- html: "restore",
- tooltip: e.options.translation.restoreImage,
- className: n && "lock" !== o ? "" : "disabled",
- }),
- L.EditAction.prototype.initialize.call(this, t, e, i);
- },
- addHooks: function () {
- var t = this._overlay;
- L.DomEvent.on(
- t,
- { edit: this._enableAction, restore: this._disableAction },
- this
- ),
- t.restore();
- },
- });
- },
- 178: function () {
- L.RotateAction = L.EditAction.extend({
- initialize: function (t, e, i) {
- ((i = i || {}).toolbarIcon = {
- svg: !0,
- html: "rotate",
- tooltip: e.options.translation.rotateImage,
- className: "rotate",
- }),
- (L.DistortableImage.action_map.r = "_rotateMode"),
- L.EditAction.prototype.initialize.call(this, t, e, i);
- },
- addHooks: function () {
- this._overlay.editing._rotateMode();
- },
- });
- },
- 547: function () {
- L.ScaleAction = L.EditAction.extend({
- initialize: function (t, e, i) {
- ((i = i || {}).toolbarIcon = {
- svg: !0,
- html: "scale",
- tooltip: e.options.translation.scaleImage,
- className: "scale",
- }),
- (L.DistortableImage.action_map.s = "_scaleMode"),
- L.EditAction.prototype.initialize.call(this, t, e, i);
- },
- addHooks: function () {
- this._overlay.editing._scaleMode();
- },
- });
- },
- 886: function () {
- L.StackAction = L.EditAction.extend({
- initialize: function (t, e, i) {
- var o,
- n,
- a = e.editing;
- a._toggledImage
- ? ((o = "flip_to_back"), (n = e.options.translation.stackToFront))
- : ((o = "flip_to_front"), (n = e.options.translation.stackToBack)),
- ((i = i || {}).toolbarIcon = {
- svg: !0,
- html: o,
- tooltip: n,
- className: "lock" === a._mode ? "disabled" : "",
- }),
- (L.DistortableImage.action_map.q =
- "lock" === a._mode ? "" : "_stackUp"),
- (L.DistortableImage.action_map.a =
- "lock" === a._mode ? "" : "_stackDown"),
- L.EditAction.prototype.initialize.call(this, t, e, i);
- },
- addHooks: function () {
- var t = this._overlay.editing;
- L.IconUtil.toggleXlink(this._link, "flip_to_front", "flip_to_back"),
- L.IconUtil.toggleTitle(
- this._link,
- "Stack to Front",
- "Stack to Back"
- ),
- t._toggleOrder();
- },
- });
- },
- 129: function () {
- L.UnlockAction = L.EditAction.extend({
- initialize: function (t, e, i) {
- ((i = i || {}).toolbarIcon = {
- svg: !0,
- html: "unlock",
- tooltip: e.options.translation.unlockImages,
- }),
- (L.DistortableImage.group_action_map.u = "_unlockGroup"),
- L.EditAction.prototype.initialize.call(this, t, e, i);
- },
- addHooks: function () {
- this._overlay.editing._unlockGroup();
- },
- });
- },
- 743: function () {
- L.EXIF = function (t) {
- if (0 !== Object.keys(EXIF.getAllTags(t)).length) {
- console.log(EXIF.getAllTags(t));
- var e = EXIF.getAllTags(t);
- void 0 !== e.GPSLatitude &&
- void 0 !== e.GPSLongitude &&
- (e.GPSLatitude[0],
- e.GPSLatitude[1],
- e.GPSLatitude[2],
- e.GPSLongitude[0],
- e.GPSLongitude[1],
- e.GPSLongitude[2],
- e.GPSLatitudeRef,
- e.GPSLongitudeRef),
- "T" === e.GPSImgDirectionRef || "M" === e.GPSImgDirectionRef
- ? (Math.PI,
- e.GPSImgDirection.numerator,
- e.GPSImgDirection.denominator)
- : console.log("No compass data found"),
- console.log("Orientation:", e.Orientation),
- (6 === e.Orientation ||
- 8 === e.Orientation ||
- 3 === e.Orientation) &&
- Math.PI,
- void 0 !== e.GPSAltitude &&
- void 0 !== e.GPSAltitudeRef &&
- void 0 !== e.GPSAltitude &&
- void 0 !== e.GPSAltitudeRef &&
- (e.GPSAltitude.numerator,
- e.GPSAltitude.denominator,
- e.GPSAltitudeRef);
- } else alert("EXIF initialized. Press again to view data in console.");
- };
- },
- 92: function () {
- (L.DistortHandle = L.EditHandle.extend({
- options: {
- TYPE: "distort",
- icon: L.icon({
- iconUrl:
- "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAklEQVR4AewaftIAAAChSURBVO3BIU4DURgGwNkvL2B6AkQTLBqP4QCoSm7DDXoBLBZHDbfgICAIZjEV3YTn9uVHdMZZtcnCfI13bIzxg0emg6Nm6QVbYz3jylEsXRrvwommb49X67jFkz80fR9Mb1YxTzqiWBSLYlEsikWxKBbFolgUi2JRLIpFsSgWxaJY03fHHOu40dH07bAzWCx9Ge/TiWbpHgdsjPGNB2f/yS+7xRCyiiZPJQAAAABJRU5ErkJggg==",
- iconSize: [32, 32],
- iconAnchor: [16, 16],
- }),
- },
- _onHandleDrag: function () {
- this._handled.setCorner(this._corner, this.getLatLng());
- },
- updateHandle: function () {
- this.setLatLng(this._handled.getCorner(this._corner));
- },
- })),
- (L.distortHandle = function (t, e, i) {
- return new L.DistortHandle(t, e, i);
- });
- },
- 194: function () {
- (L.DragHandle = L.EditHandle.extend({
- options: {
- TYPE: "drag",
- icon: L.icon({
- iconUrl:
- "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAsVJREFUeNrMVztLXEEUvnNVFAVBAhY2aRKbTZEHJNpYabuNjSgYg/GxdsmPSJkUAa/ZdVEX8mgWYVutbHxAHkVskjQBuUUgBISVhCQk3wnfwMlk1rusN1wHPubOzJlzvjlz5sxc01Ma/hUEwQnwDIjqc7uvgv9YYO86qgIwCXQbdNTlQ8kcCBHgBch8TcloF6oJGr6phk6EQAkfdz3zvgDr9Mr7Fg1fptEZoM8jsmrokpfsiIFO4IIjuE2v1EDmR4LRdlR5Gh51hj8D34ABtm8YTtqna0TgklIw5CgQguKxIojEjmFROg/MKQO27NkFAB+4wAPouGUJiIvWKHwbAxX2XyWRKWkqhT+pbJntJZJuUzISW0+5hW+obxrVBsfvoH/dqCCJuU97GBh2VteLSiYvArmErT8EVoAK9Bw7enbpVYmvAQlyowYforrH5jXL2rPHI/TKONDB7u9AlavdaTBPvPmazUeQuy8f7UomUgTEwIJPEQ3sQGE/6ll2l9H/KcEzBcfWn2IclluM3DpddJxSHujlFkscbUPvmB0LHVnLrId7nlaZVkEc6QGXQI1MAwZcWmVRHeNaQwJMMiU2cwy4s7p/RJ2ckpvIQs+cIs+5GzitloLKHUV3MPREuXbTOKO91dX387gGTONxIgEWm+E61FFrpcyqXLHsEwiDjEsjAksqw5XPoL9MHVrn6QR4q+XZrDaR4RoWzq2ymafuRA/Mq1stSsHLVkcbdf9VjOcx8ZH3+SFWcCWlVPyWuUBOwUWdC1wP5NVjYiXFWLO69PZ6CRTUY6KSIoEKdf6T3IzzgHxnsyHctNBEkmn6Oob8ExUDg/ahGybd177cDjzH5xHwgDiSvoS7I/LZyvxJZj0wod7tkX5G0XVC7rEyLhfLJjBGbKoLLEfZWObyKeZ6oY82g+yf5Zn/mJyHX7PMf04z/T3/LcAAu4E6iiyJqf0AAAAASUVORK5CYII=",
- iconSize: [32, 32],
- iconAnchor: [16, 16],
- }),
- },
- _onHandleDrag: function () {
- var t = this._handled,
- e = t.getCorner(this._corner),
- i = this.getLatLng();
- t.dragBy(e, i);
- },
- updateHandle: function () {
- this.setLatLng(this._handled.getCorner(this._corner));
- },
- })),
- (L.dragHandle = function (t, e, i) {
- return new L.DragHandle(t, e, i);
- });
- },
- 988: function () {
- L.EditHandle = L.Marker.extend({
- initialize: function (t, e, i) {
- var o = t.getCorner(e);
- L.setOptions(this, i), (this._handled = t), (this._corner = e);
- var n = { draggable: !0, zIndexOffset: 10 };
- i && i.hasOwnProperty("draggable") && (n.draggable = i.draggable),
- L.Marker.prototype.initialize.call(this, o, n);
- },
- onAdd: function (t) {
- L.Marker.prototype.onAdd.call(this, t),
- this._bindListeners(),
- this.updateHandle();
- },
- onRemove: function (t) {
- this._unbindListeners(), L.Marker.prototype.onRemove.call(this, t);
- },
- _onHandleDragStart: function () {
- this._handled.fire("editstart");
- },
- _onHandleDragEnd: function () {
- this._fireEdit();
- },
- _fireEdit: function () {
- (this._handled.edited = !0), this._handled.fire("edit");
- },
- _bindListeners: function () {
- this.on(
- {
- contextmenu: L.DomEvent.stop,
- dragstart: this._onHandleDragStart,
- drag: this._onHandleDrag,
- dragend: this._onHandleDragEnd,
- },
- this
- ),
- this._handled._map.on("zoomend", this.updateHandle, this),
- this._handled.on("update", this.updateHandle, this);
- },
- _unbindListeners: function () {
- this.off(
- {
- contextmenu: L.DomEvent.stop,
- dragstart: this._onHandleDragStart,
- drag: this._onHandleDrag,
- dragend: this._onHandleDragEnd,
- },
- this
- ),
- this._handled._map.off("zoomend", this.updateHandle, this),
- this._handled.off("update", this.updateHandle, this);
- },
- _calculateScalingFactor: function (t, e) {
- var i = this._handled,
- o = i._map,
- n = o.latLngToLayerPoint(i.getCenter()),
- a = o.latLngToLayerPoint(t),
- s = o.latLngToLayerPoint(e),
- r = this._d2(n, a),
- l = this._d2(n, s);
- return Math.sqrt(l / r);
- },
- _d2: function (t, e) {
- var i = t.x - e.x,
- o = t.y - e.y;
- return Math.pow(i, 2) + Math.pow(o, 2);
- },
- calculateAngleDelta: function (t, e) {
- var i = this._handled,
- o = i._map,
- n = o.latLngToLayerPoint(i.getCenter()),
- a = o.latLngToLayerPoint(t),
- s = o.latLngToLayerPoint(e),
- r = Math.atan2(n.y - a.y, n.x - a.x);
- return Math.atan2(n.y - s.y, n.x - s.x) - r;
- },
+ }).then(mergedOpts.handleStatusRes);
+ }; // If the user has passed collection property
+
+
+ _this6.customCollection = !!opts.collection;
+
+ if (!_this6.customCollection) {
+ opts.collection = _this6._group.generateExportJson().images;
+ }
+
+ opts.frequency = opts.frequency || 3000;
+ opts.scale = opts.scale || 100; // switch it to _getAvgCmPerPixel !
+
+ opts.updater = opts.updater || _defaultUpdater;
+ opts.handleStatusRes = opts.handleStatusRes || _defaultHandleStatusRes;
+ opts.fetchStatusUrl = opts.fetchStatusUrl || _defaultFetchStatusUrl;
+ opts.fetchStatusUrl(opts);
+ });
+ }
+});
+
+L.distortableCollection.edit = function (group, options) {
+ return new L.DistortableCollection.Edit(group, options);
+};
+
+/***/ }),
+
+/***/ "./src/edit/DistortableImage.Edit.js":
+/*!*******************************************!*\
+ !*** ./src/edit/DistortableImage.Edit.js ***!
+ \*******************************************/
+/***/ (function() {
+
+L.DistortableImage = L.DistortableImage || {}; // holds the keybindings & toolbar API for an individual image instance
+
+L.DistortableImage.Edit = L.Handler.extend({
+ options: {
+ opacity: 0.7,
+ outline: '1px solid red',
+ keymap: L.distortableImage.action_map
+ },
+ initialize: function initialize(overlay, options) {
+ this._overlay = overlay;
+ this._toggledImage = false;
+ this._mode = overlay.options.mode;
+ this._transparent = false;
+ this._outlined = false;
+ L.setOptions(this, options);
+ L.distortableImage.action_map.Escape = '_deselect';
+ },
+
+ /* Run on image selection. */
+ addHooks: function addHooks() {
+ var overlay = this._overlay;
+ this.editActions = this.options.actions;
+ /* bring the selected image into view */
+
+ overlay.bringToFront();
+
+ this._initModes();
+
+ this._initHandles();
+
+ this._appendHandlesandDragable();
+
+ if (overlay.isSelected() && !overlay.options.suppressToolbar) {
+ this._addToolbar();
+ }
+
+ this.parentGroup = overlay.eP ? overlay.eP : false;
+ L.DomEvent.on(overlay.getElement(), {
+ dblclick: this.nextMode
+ }, this);
+ L.DomEvent.on(window, 'keydown', this._onKeyDown, this);
+ },
+
+ /* Run on image deselection. */
+ removeHooks: function removeHooks() {
+ var overlay = this._overlay;
+ var eP = this.parentGroup; // First, check if dragging exists - it may be off due to locking
+
+ this._disableDragging();
+
+ if (this.toolbar) {
+ this._removeToolbar();
+ }
+
+ for (var handle in this._handles) {
+ L.DomUtil.remove(handle);
+ }
+ /**
+ * ensures if you disable an image while it is multi-selected
+ * additional deselection logic is run
+ */
+
+
+ if (L.DomUtil.hasClass(overlay.getElement(), 'collected')) {
+ L.DomUtil.removeClass(overlay.getElement(), 'collected');
+ }
+
+ if (eP && !eP.anyCollected() && eP.editing.toolbar) {
+ eP.editing._removeToolbar();
+ }
+
+ L.DomEvent.off(overlay.getElement(), {
+ dblclick: this.nextMode
+ }, this);
+ L.DomEvent.off(window, 'keydown', this._onKeyDown, this);
+ },
+ disable: function disable() {
+ if (!this._enabled) {
+ return this;
+ }
+
+ this._overlay.deselect();
+
+ this._enabled = false;
+ this.removeHooks();
+ return this;
+ },
+ _initModes: function _initModes() {
+ this._modes = {}; // passed from L.DistortablImage.PopupBar. If the mode is one
+ // of the current toolbar actions, adds it to this._modes
+
+ for (var mode in L.DistortableImage.Edit.MODES) {
+ var action = L.DistortableImage.Edit.MODES[mode];
+
+ if (this.editActions.indexOf(action) !== -1) {
+ this._modes[mode] = action;
+ }
+ } // sets the current mode to the 1st available one if the one selected
+ // during initialization is not available
+
+
+ if (!this._modes[this._mode]) {
+ this._mode = Object.keys(this._modes)[0];
+ }
+ },
+ _initHandles: function _initHandles() {
+ var overlay = this._overlay;
+ var i;
+ this._dragHandles = L.layerGroup();
+
+ for (i = 0; i < 4; i++) {
+ this._dragHandles.addLayer(L.dragHandle(overlay, i));
+ }
+
+ this._scaleHandles = L.layerGroup();
+
+ for (i = 0; i < 4; i++) {
+ this._scaleHandles.addLayer(L.scaleHandle(overlay, i));
+ }
+
+ this._distortHandles = L.layerGroup();
+
+ for (i = 0; i < 4; i++) {
+ this._distortHandles.addLayer(L.distortHandle(overlay, i));
+ }
+
+ this._rotateHandles = L.layerGroup(); // individual rotate
+
+ for (i = 0; i < 4; i++) {
+ this._rotateHandles.addLayer(L.rotateHandle(overlay, i));
+ } // handle includes rotate AND scale
+
+
+ this._freeRotateHandles = L.layerGroup();
+
+ for (i = 0; i < 4; i++) {
+ this._freeRotateHandles.addLayer(L.freeRotateHandle(overlay, i));
+ }
+
+ this._lockHandles = L.layerGroup();
+
+ for (i = 0; i < 4; i++) {
+ this._lockHandles.addLayer(L.lockHandle(overlay, i, {
+ draggable: false
+ }));
+ }
+
+ this._handles = {
+ drag: this._dragHandles,
+ scale: this._scaleHandles,
+ distort: this._distortHandles,
+ rotate: this._rotateHandles,
+ freeRotate: this._freeRotateHandles,
+ lock: this._lockHandles
+ };
+ },
+ _appendHandlesandDragable: function _appendHandlesandDragable() {
+ var ov = this._overlay; // won't throw error if user adds 0 mode actions to toolbar
+
+ if (!this._mode) {
+ this._enableDragging();
+
+ return;
+ }
+
+ this._updateHandle();
+
+ if (!ov.isSelected() && this.currentHandle) {
+ this.currentHandle.eachLayer(function (handle) {
+ handle.setOpacity(0);
+
+ if (handle.dragging) {
+ handle.dragging.disable();
+ }
});
- },
- 206: function () {
- (L.FreeRotateHandle = L.EditHandle.extend({
- options: {
- TYPE: "freeRotate",
- icon: L.icon({
- iconUrl:
- "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAklEQVR4AewaftIAAAHiSURBVMXBa3HbShgA0PMp/1sCCo8oCEpgTaCXgIXAJiDzyCJoAUTm4UVQAns1Y8+snWnTvJyeE16hkjDgDrfoNTMKcpC9UPiLSo8JyetkjEHxjPCMyoS199kFoz8Iv1HpMaN3qWDCHoegOKkkRwnJpRmroHgiPFEZ8IBekzEGxQtUEhKSS/fB7Ew4U+lxcGkVZG9QWWPSFAxBcdK59KApuA+yNwp2uEdx1GN25sZJZULSfAtm77SlbNjju6MvG75u+WHRWVR6rDVjMPsgwYyVZl3pLTpHkyYHOx8syMiayaJzlDTZ9YyaZNFVkiYH2ZUEBcVJJXVImuz6Js3Qofe59pq7DoOTILu+g+a288mCouk7/1iH4qTS+2QdDppbV1ZJmrnDXnPnc5UOs2Z0fUmTuyBr+krvSioJyUmQO0dZM7mepMkWnaNRkyrJB6uskTSjxY3Fll8bvmJwlDb83FJ8gMqAB80uyBY3Trb82PAfvjj6vuHnluIdKgMeNXOwctK5NKBoHitrb1RJeHRp5Ux4ojLg0aWMHGQvUOkxIWkKVsHsTPiNSo8HDC5lZIsgO6n0uMUdRvQuFQxB8UR4RmXC2vvsgtEfhL+o9JiQvE7GGBTPCK9QSUjoMWgKDthjDrIX+h/k0I7gth6N5gAAAABJRU5ErkJggg==",
- iconSize: [32, 32],
- iconAnchor: [16, 16],
- }),
- },
- _onHandleDrag: function () {
- var t = this._handled,
- e = t._map,
- i = t.getCorner(this._corner),
- o = this.getLatLng(),
- n = this.calculateAngleDelta(i, o),
- a = this._calculateScalingFactor(i, o);
- 0 !== n && t.rotateBy(n, "rad");
- var s = t.edgeMinWidth;
- s || (s = 50);
- var r = e.latLngToContainerPoint(t.getCorner(0)),
- l = e.latLngToContainerPoint(t.getCorner(1)),
- c = Math.abs(r.x - l.x),
- d = Math.abs(r.y - l.y);
- Math.sqrt(c * c + d * d) > s || a > 1 ? t.scaleBy(a) : t.scaleBy(1);
- },
- updateHandle: function () {
- this.setLatLng(this._handled.getCorner(this._corner));
- },
- })),
- (L.freeRotateHandle = function (t, e, i) {
- return new L.FreeRotateHandle(t, e, i);
- });
- },
- 789: function () {
- (L.LockHandle = L.EditHandle.extend({
- options: {
- TYPE: "lock",
- interactive: !1,
- icon: L.icon({
- iconUrl:
- "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAklEQVR4AewaftIAAAD8SURBVO3BPU7CYAAA0AdfjIcQlRCQBG7C3gk2uIPG2RC3Dk16Gz0FTO1WZs/gwGCMP/2+xsSl7+n1er1Iz9LtRQjaPeMeO+TinLDCJV78YqjdA04YodKuxhUaPGoRxMmxwRQZSt87Yo4KExGCeAUyLLFB4bMacxywEClIU2KDKXbInTUYo8JCgoFuGoxQO5uiwY1EA91VmDqrcKeDoX8WdNNgjApvmGGLXKIgXY0xGkxQYItrrFFIEKQ5Yo4KEx9yrDFDhlKkIF6NOQ5Y+KpAhiXWKEQI4pxwiwoLPyuxwQw75FoE7fZYocFEuwI7jHCBV39gL92TXq/Xi/AOcmczZmaIMScAAAAASUVORK5CYII=",
- iconSize: [32, 32],
- iconAnchor: [16, 16],
- }),
- },
- onRemove: function (t) {
- this.unbindTooltip(), L.EditHandle.prototype.onRemove.call(this, t);
- },
- _bindListeners: function () {
- var t = this.getElement();
- L.EditHandle.prototype._bindListeners.call(this),
- L.DomEvent.on(
- t,
- { mousedown: this._tooltipOn, mouseup: this._tooltipOff },
- this
- ),
- L.DomEvent.on(document, "pointerleave", this._tooltipOff, this);
- },
- _unbindListeners: function () {
- var t = this.getElement();
- L.EditHandle.prototype._bindListeners.call(this),
- L.DomEvent.off(
- t,
- { mousedown: this._tooltipOn, mouseup: this._tooltipOff },
- this
- ),
- L.DomEvent.off(document, "pointerleave", this._tooltipOff, this);
- },
- _onHandleDrag: function () {},
- updateHandle: function () {
- this.setLatLng(this._handled.getCorner(this._corner));
- },
- _tooltipOn: function (t) {
- var e = this._handled.parentGroup,
- i = e ? e.editing : this._handled.editing;
- if (
- !t.shiftKey &&
- (this._handled.isSelected() || !e || e.isCollected(this._handled))
- ) {
- var o = i._lockHandles;
- this._timer = setTimeout(
- L.bind(function () {
- this._timeout && clearTimeout(this._timeout),
- this.getTooltip()
- ? o.eachLayer(function (t) {
- this !== t && t.closeTooltip();
- })
- : this.bindTooltip("Locked!", { permanent: !0 }),
- this.openTooltip();
- }, this),
- 500
- );
+ }
+
+ if (!this.isMode('lock')) {
+ this._enableDragging();
+ }
+ },
+ _onKeyDown: function _onKeyDown(e) {
+ var keymap = this.options.keymap;
+ var handlerName = keymap[e.key];
+ var ov = this._overlay;
+ var eP = this.parentGroup;
+
+ if (eP && eP.anyCollected()) {
+ return;
+ }
+
+ if (this[handlerName] !== undefined && !ov.options.suppressToolbar) {
+ if (ov.isSelected() && this.toolbar) {
+ this[handlerName].call(this);
+ }
+ }
+ },
+ replaceTool: function replaceTool(old, next) {
+ var _this = this;
+
+ if (next.baseClass !== 'leaflet-toolbar-icon' || this.hasTool(next)) {
+ return this;
+ }
+
+ this.editActions.some(function (item, idx) {
+ if (item === old) {
+ _this._removeToolbar();
+
+ _this.editActions[idx] = next;
+
+ _this._addToolbar();
+
+ for (var mode in L.DistortableImage.Edit.MODES) {
+ if (L.DistortableImage.Edit.MODES[mode] === old) {
+ delete _this._modes[mode];
+
+ _this._nextOrNone(mode);
+ } else if (L.DistortableImage.Edit.MODES[mode] === next) {
+ _this._modes[mode] = next;
}
- },
- _tooltipOff: function (t) {
- var e = this._handled.parentGroup,
- i = e ? e.editing : this._handled.editing;
- if (
- !t.shiftKey &&
- (this._handled.isSelected() || !e || e.isCollected(this._handled))
- ) {
- var o = i._lockHandles;
- t.currentTarget === document &&
- o.eachLayer(function (t) {
- t.closeTooltip();
- }),
- this._timer && clearTimeout(this._timer),
- (this._timeout = setTimeout(
- L.bind(function () {
- this.closeTooltip();
- }, this),
- 400
- ));
+ }
+
+ return true;
+ }
+ });
+ return this;
+ },
+ addTool: function addTool(value) {
+ if (value.baseClass === 'leaflet-toolbar-icon' && !this.hasTool(value)) {
+ this._removeToolbar();
+
+ this.editActions.push(value);
+
+ this._addToolbar();
+
+ for (var mode in L.DistortableImage.Edit.MODES) {
+ if (L.DistortableImage.Edit.MODES[mode] === value) {
+ this._modes[mode] = value;
+ }
+ }
+
+ if (!this._overlay.isSelected()) {
+ this._removeToolbar();
+ }
+ }
+
+ return this;
+ },
+ hasTool: function hasTool(value) {
+ return this.editActions.some(function (action) {
+ return action === value;
+ });
+ },
+ removeTool: function removeTool(value) {
+ var _this2 = this;
+
+ this.editActions.some(function (item, idx) {
+ if (item === value) {
+ _this2._removeToolbar();
+
+ _this2.editActions.splice(idx, 1);
+
+ _this2._addToolbar();
+
+ for (var mode in L.DistortableImage.Edit.MODES) {
+ if (L.DistortableImage.Edit.MODES[mode] === value) {
+ delete _this2._modes[mode];
+
+ _this2._nextOrNone(mode);
}
- },
- })),
- (L.lockHandle = function (t, e, i) {
- return new L.LockHandle(t, e, i);
- });
- },
- 337: function () {
- (L.RotateHandle = L.EditHandle.extend({
- options: {
- TYPE: "rotate",
- icon: L.icon({
- iconUrl:
- "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAklEQVR4AewaftIAAAHiSURBVMXBa3HbShgA0PMp/1sCCo8oCEpgTaCXgIXAJiDzyCJoAUTm4UVQAns1Y8+snWnTvJyeE16hkjDgDrfoNTMKcpC9UPiLSo8JyetkjEHxjPCMyoS199kFoz8Iv1HpMaN3qWDCHoegOKkkRwnJpRmroHgiPFEZ8IBekzEGxQtUEhKSS/fB7Ew4U+lxcGkVZG9QWWPSFAxBcdK59KApuA+yNwp2uEdx1GN25sZJZULSfAtm77SlbNjju6MvG75u+WHRWVR6rDVjMPsgwYyVZl3pLTpHkyYHOx8syMiayaJzlDTZ9YyaZNFVkiYH2ZUEBcVJJXVImuz6Js3Qofe59pq7DoOTILu+g+a288mCouk7/1iH4qTS+2QdDppbV1ZJmrnDXnPnc5UOs2Z0fUmTuyBr+krvSioJyUmQO0dZM7mepMkWnaNRkyrJB6uskTSjxY3Fll8bvmJwlDb83FJ8gMqAB80uyBY3Trb82PAfvjj6vuHnluIdKgMeNXOwctK5NKBoHitrb1RJeHRp5Ux4ojLg0aWMHGQvUOkxIWkKVsHsTPiNSo8HDC5lZIsgO6n0uMUdRvQuFQxB8UR4RmXC2vvsgtEfhL+o9JiQvE7GGBTPCK9QSUjoMWgKDthjDrIX+h/k0I7gth6N5gAAAABJRU5ErkJggg==",
- iconSize: [32, 32],
- iconAnchor: [16, 16],
- }),
- },
- _onHandleDrag: function () {
- var t = this._handled,
- e = t.getCorner(this._corner),
- i = this.getLatLng(),
- o = this.calculateAngleDelta(e, i);
- t.rotateBy(o, "rad");
- },
- updateHandle: function () {
- this.setLatLng(this._handled.getCorner(this._corner));
- },
- })),
- (L.rotateHandle = function (t, e, i) {
- return new L.RotateHandle(t, e, i);
- });
- },
- 350: function () {
- (L.ScaleHandle = L.EditHandle.extend({
- options: {
- TYPE: "scale",
- icon: L.icon({
- iconUrl:
- "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB2ZXJzaW9uPSIxLjEiIHdpZHRoPSI0NTkiIGhlaWdodD0iNDY0IiBlbmFibGUtYmFja2dyb3VuZD0ibmV3IDAgMCA1MTIgNTEyIiB4bWw6c3BhY2U9InByZXNlcnZlIiBzdHlsZT0iIj48cmVjdCBpZD0iYmFja2dyb3VuZHJlY3QiIHdpZHRoPSIxMDAlIiBoZWlnaHQ9IjEwMCUiIHg9IjAiIHk9IjAiIGZpbGw9Im5vbmUiIHN0cm9rZT0ibm9uZSIgY2xhc3M9IiIgc3R5bGU9IiIvPjxnIGNsYXNzPSJjdXJyZW50TGF5ZXIiIHN0eWxlPSIiPjx0aXRsZT5MYXllciAxPC90aXRsZT48cGF0aCBkPSJNNDU5LjA0OTE1OTUzMDQ3MTM0LDg2LjkyNjIzNDUxMjU1MDAyIFYwIGgtODUuNzE0NTczMzU2MzEyMDkgdjI3LjA0MzcxNzQwMzkwNDQ1MiBIODUuNzE0NTczMzU2MzEyMDMgVjAgSDAgdjg2LjkyNjIzNDUxMjU1MDAyIGgyNS43MTQzNzIwMDY4OTM2MjYgdjI4OS43NTQxMTUwNDE4MzM0IEgwIHY4Ni45MjYyMzQ1MTI1NTAwMiBoODUuNzE0NTczMzU2MzEyMDkgdi0yNy4wNDM3MTc0MDM5MDQ0NTIgaDI4NS43MTUyNDQ1MjEwNDAzIHYyNy4wNDM3MTc0MDM5MDQ0NTIgaDg1LjcxNDU3MzM1NjMxMjA5IHYtODYuOTI2MjM0NTEyNTUwMDIgaC0yMy44MDk2MDM3MTAwODY2OSBWODYuOTI2MjM0NTEyNTUwMDIgSDQ1OS4wNDkxNTk1MzA0NzEzNCB6TTM4NC43NjMxOTU5NTUwMDA5LDEyLjU1NjAxMTY1MTgxMjc4MSBoNjEuOTA0OTY5NjQ2MjI1Mzk2IHY2Mi43ODAwNTgyNTkwNjM5MSBoLTYxLjkwNDk2OTY0NjIyNTM5NiBWMTIuNTU2MDExNjUxODEyNzgxIHpNMTIuMzgwOTkzOTI5MjQ1MDUsMTIuNTU2MDExNjUxODEyNzgxIGg2MS45MDQ5Njk2NDYyMjUzOTYgdjYyLjc4MDA1ODI1OTA2MzkxIEgxMi4zODA5OTM5MjkyNDUwNSBWMTIuNTU2MDExNjUxODEyNzgxIHpNNzQuMjg1OTYzNTc1NDcwNTMsNDUxLjA1MDU3MjQxNTEyMDY2IEgxMi4zODA5OTM5MjkyNDUwNSB2LTYyLjc4MDA1ODI1OTA2MzkxIGg2MS45MDQ5Njk2NDYyMjUzOTYgVjQ1MS4wNTA1NzI0MTUxMjA2NiB6TTQ0NS43MTU3ODE0NTI4MjI3NCw0NTEuMDUwNTcyNDE1MTIwNjYgaC02Mi44NTczNTM3OTQ2Mjg4NjQgdi02Mi43ODAwNTgyNTkwNjM5MSBoNjIuODU3MzUzNzk0NjI4ODY0IFY0NTEuMDUwNTcyNDE1MTIwNjYgek00MDcuNjIwNDE1NTE2Njg0MjYsMzc2LjY4MDM0OTU1NDM4MzQ0IGgtMzYuMTkwNTk3NjM5MzMxNzcgdjMyLjgzODc5OTcwNDc0MTEyIEg4NS43MTQ1NzMzNTYzMTIwMyB2LTMyLjgzODc5OTcwNDc0MTEyIEg0OS41MjM5NzU3MTY5ODAzMiBWODYuOTI2MjM0NTEyNTUwMDIgaDM2LjE5MDU5NzYzOTMzMTc3IFY1MC4yMjQwNDY2MDcyNTExMjUgaDI4Ny42MjAwMTI4MTc4NDcyIHYzNi43MDIxODc5MDUyOTg5IGgzNC4yODU4MjkzNDI1MjQ4MzUgVjM3Ni42ODAzNDk1NTQzODM0NCB6IiBpZD0ic3ZnXzIiIGNsYXNzPSIiIGZpbGw9IiMxYTFhZWIiIGZpbGwtb3BhY2l0eT0iMSIvPjwvZz48L3N2Zz4=",
- iconSize: [32, 32],
- iconAnchor: [16, 16],
- }),
- },
- _onHandleDrag: function () {
- var t = this._handled,
- e = t._map,
- i = t.edgeMinWidth,
- o = t.getCorner(this._corner),
- n = this.getLatLng(),
- a = this._calculateScalingFactor(o, n);
- i || (i = 50);
- var s = e.latLngToLayerPoint(t.getCorner(0)),
- r = e.latLngToLayerPoint(t.getCorner(1)),
- l = Math.abs(s.x - r.x),
- c = Math.abs(s.y - r.y);
- Math.sqrt(l * l + c * c) > i || a > 1 ? t.scaleBy(a) : t.scaleBy(1);
- },
- updateHandle: function () {
- this.setLatLng(this._handled.getCorner(this._corner));
- },
- })),
- (L.scaleHandle = function (t, e, i) {
- return new L.ScaleHandle(t, e, i);
- });
- },
- 719: function () {
- (L.distortableImage = L.DistortableImage || {}),
- (L.distortableImage = L.DistortableImage),
- (L.DistortableImage.group_action_map = {}),
- (L.DistortableImage.ControlBar = L.Toolbar2.Control.extend({})),
- (L.distortableImage.controlBar = function (t) {
- return new L.DistortableImage.ControlBar(t);
- }),
- L.DistortableCollection.addInitHook(function () {
- (this.ACTIONS = [
- L.ExportAction,
- L.DeleteAction,
- L.LockAction,
- L.UnlockAction,
- ]),
- (L.DistortableCollection.Edit.MODES = {
- lock: L.LockAction,
- unlock: L.UnlockAction,
- });
- var t = this.options.actions ? this.options.actions : this.ACTIONS;
- this.editing = L.distortableCollection.edit(this, { actions: t });
+ }
+
+ return true;
+ }
+ });
+
+ if (!this._overlay.isSelected()) {
+ this._removeToolbar();
+ }
+
+ return this;
+ },
+ // set the mode to the next mode or if that was the last one set mode to ''
+ _nextOrNone: function _nextOrNone(mode) {
+ if (this.isMode(mode)) {
+ if (Object.keys(this.getModes()).length >= 1) {
+ this.nextMode();
+ } else {
+ if (mode === 'lock') {
+ this._enableDragging();
+ }
+
+ this._mode = '';
+
+ this._updateHandle();
+ }
+ }
+ },
+ _removeToolbar: function _removeToolbar() {
+ var ov = this._overlay;
+ var map = ov._map;
+
+ if (this.toolbar) {
+ map.removeLayer(this.toolbar);
+ this.toolbar = false;
+ }
+ },
+ _enableDragging: function _enableDragging() {
+ var _this3 = this;
+
+ var overlay = this._overlay;
+ var map = overlay._map;
+ this.dragging = new L.Draggable(overlay.getElement());
+ this.dragging.enable();
+ /* Hide toolbars and markers while dragging; click will re-show it */
+
+ this.dragging.on('dragstart', function () {
+ overlay.fire('dragstart');
+
+ _this3._removeToolbar();
+ });
+ /*
+ * Adjust default behavior of L.Draggable, which overwrites the CSS3
+ * distort transformations that we set when it calls L.DomUtil.setPosition.
+ */
+
+ this.dragging._updatePosition = function () {
+ var topLeft = overlay.getCorner(0);
+
+ var delta = this._newPos.subtract(map.latLngToLayerPoint(topLeft));
+
+ var currentPoint;
+ var corners = {};
+ var i;
+ this.fire('predrag');
+
+ for (i = 0; i < 4; i++) {
+ currentPoint = map.latLngToLayerPoint(overlay.getCorner(i));
+ corners[i] = map.layerPointToLatLng(currentPoint.add(delta));
+ }
+
+ overlay.setCorners(corners);
+ overlay.fire('drag');
+ this.fire('drag');
+ };
+
+ this.dragging.on('dragend', function () {
+ overlay.fire('dragend');
+ });
+ },
+ _disableDragging: function _disableDragging() {
+ if (this.dragging) {
+ this.dragging.disable();
+ delete this.dragging;
+ }
+ },
+ _dragMode: function _dragMode() {
+ this.setMode('drag');
+ },
+ _scaleMode: function _scaleMode() {
+ this.setMode('scale');
+ },
+ _distortMode: function _distortMode() {
+ this.setMode('distort');
+ },
+ _rotateMode: function _rotateMode() {
+ this.setMode('rotate');
+ },
+ _freeRotateMode: function _freeRotateMode() {
+ this.setMode('freeRotate');
+ },
+ _toggleLockMode: function _toggleLockMode() {
+ if (this.isMode('lock')) {
+ this._unlock();
+ } else {
+ this._lock();
+ }
+ },
+ _toggleOpacity: function _toggleOpacity() {
+ var image = this._overlay.getElement();
+
+ var opacity;
+
+ if (!this.hasTool(L.OpacityAction)) {
+ return;
+ }
+
+ this._transparent = !this._transparent;
+ opacity = this._transparent ? this.options.opacity : 1;
+ L.DomUtil.setOpacity(image, opacity);
+ image.setAttribute('opacity', opacity);
+
+ this._refresh();
+ },
+ _toggleBorder: function _toggleBorder() {
+ var image = this._overlay.getElement();
+
+ var outline;
+
+ if (!this.hasTool(L.BorderAction)) {
+ return;
+ }
+
+ this._outlined = !this._outlined;
+ outline = this._outlined ? this.options.outline : 'none';
+ image.style.outline = outline;
+
+ this._refresh();
+ },
+ // compare this to using overlay zIndex
+ _toggleOrder: function _toggleOrder() {
+ if (this._toggledImage) {
+ this._stackUp();
+ } else {
+ this._stackDown();
+ }
+ },
+ _removeOverlay: function _removeOverlay() {
+ var ov = this._overlay;
+ var eP = this.parentGroup;
+
+ if (this.isMode('lock') || !this.hasTool(L.DeleteAction)) {
+ return;
+ }
+
+ var choice = L.DomUtil.confirmDelete();
+
+ if (!choice) {
+ return;
+ }
+
+ this._removeToolbar();
+
+ if (eP) {
+ eP.removeLayer(ov);
+ } else {
+ ov._map.removeLayer(ov);
+ }
+ },
+ // Based on https://github.com/publiclab/mapknitter/blob/8d94132c81b3040ae0d0b4627e685ff75275b416/app/assets/javascripts/mapknitter/Map.js#L47-L82
+ _getExport: function _getExport() {
+ var overlay = this._overlay;
+ var map = overlay._map;
+ var img = overlay.getElement();
+
+ if (!this.hasTool(L.ExportAction)) {
+ return;
+ } // make a new image
+
+
+ var downloadable = new Image();
+ downloadable.id = downloadable.id || 'tempId12345';
+ document.body.appendChild(downloadable);
+
+ downloadable.onload = function onLoadDownloadableImage() {
+ var height = downloadable.height;
+ var width = downloadable.width;
+ var nw = map.latLngToLayerPoint(overlay.getCorner(0));
+ var ne = map.latLngToLayerPoint(overlay.getCorner(1));
+ var sw = map.latLngToLayerPoint(overlay.getCorner(2));
+ var se = map.latLngToLayerPoint(overlay.getCorner(3)); // I think this is to move the image to the upper left corner,
+ // eslint-disable-next-line max-len
+ // jywarren: i think we may need these or the image goes off the edge of the canvas
+ // jywarren: but these seem to break the distortion math...
+ // jywarren: i think it should be rejiggered so it
+ // finds the most negative values of x and y and then
+ // adds those to all coordinates
+ // nw.x -= nw.x;
+ // ne.x -= nw.x;
+ // se.x -= nw.x;
+ // sw.x -= nw.x;
+ // nw.y -= nw.y;
+ // ne.y -= nw.y;
+ // se.y -= nw.y;
+ // sw.y -= nw.y;
+ // run once warping is complete
+
+ downloadable.onload = function () {
+ L.DomUtil.remove(downloadable);
+ };
+
+ if (window && window.hasOwnProperty('warpWebGl')) {
+ warpWebGl(downloadable.id, [0, 0, width, 0, width, height, 0, height], [nw.x, nw.y, ne.x, ne.y, se.x, se.y, sw.x, sw.y], true // trigger download
+ );
+ }
+ };
+
+ downloadable.src = overlay.options.fullResolutionSrc || img.src;
+ },
+ _stackUp: function _stackUp() {
+ var t = this._toggledImage;
+
+ if (!t || !this.hasTool(L.StackAction)) {
+ return;
+ }
+
+ this._toggledImage = false;
+
+ this._overlay.bringToFront();
+
+ this._refresh();
+ },
+ _stackDown: function _stackDown() {
+ var t = this._toggledImage;
+
+ if (t || !this.hasTool(L.StackAction)) {
+ return;
+ }
+
+ this._toggledImage = true;
+
+ this._overlay.bringToBack();
+
+ this._refresh();
+ },
+ _unlock: function _unlock() {
+ var ov = this._overlay;
+ var map = ov._map;
+ var eP = this.parentGroup;
+
+ if (!this.isMode('lock')) {
+ return;
+ }
+
+ if (eP && !eP.isCollected(ov) || !eP) {
+ if (!this.hasTool(L.LockAction)) {
+ return;
+ }
+ }
+
+ if (this.currentHandle) {
+ map.removeLayer(this.currentHandle);
+ }
+
+ if (ov.options.mode === 'lock' || !this.hasMode(ov.options.mode)) {
+ this._mode = '';
+ this.currentHandle = '';
+ } else {
+ this._mode = ov.options.mode;
+ }
+
+ this._updateHandle();
+
+ this._enableDragging();
+
+ this._refresh();
+ },
+ _lock: function _lock() {
+ var ov = this._overlay;
+ var map = ov._map;
+ var eP = this.parentGroup;
+
+ if (this.isMode('lock')) {
+ return;
+ }
+
+ if (eP && !eP.isCollected(ov) || !eP) {
+ if (!this.hasTool(L.LockAction)) {
+ return;
+ }
+ }
+
+ if (this.currentHandle) {
+ map.removeLayer(this.currentHandle);
+ }
+
+ this._mode = 'lock';
+
+ this._updateHandle();
+
+ this._disableDragging();
+
+ this._refresh();
+ },
+ _deselect: function _deselect() {
+ this._overlay.deselect();
+ },
+ _showMarkers: function _showMarkers(e) {
+ var eP = this.parentGroup;
+
+ if (!this.currentHandle) {
+ return;
+ } // only markers we want in collect interface for now is lock
+
+
+ if (!this.isMode('lock') && eP && eP.anyCollected()) {
+ return;
+ }
+
+ this.currentHandle.eachLayer(function (handle) {
+ handle.setOpacity(1);
+
+ if (handle.dragging) {
+ handle.dragging.enable();
+ }
+
+ L.DomUtil.addClass(handle.getElement(), 'leaflet-interactive');
+ });
+ },
+ _hideMarkers: function _hideMarkers() {
+ var ov = this._overlay;
+ var eP = this.parentGroup; // workaround for race condition w/ feature group
+
+ if (!this._handles) {
+ this._initHandles();
+ }
+
+ if (!this.currentHandle) {
+ return;
+ }
+
+ if (this.isMode('lock') && eP && eP.isCollected(ov)) {
+ return;
+ }
+
+ this.currentHandle.eachLayer(function (handle) {
+ handle.setOpacity(0);
+
+ if (handle.dragging) {
+ handle.dragging.disable();
+ }
+
+ L.DomUtil.removeClass(handle.getElement(), 'leaflet-interactive');
+ });
+ },
+ _updateHandle: function _updateHandle() {
+ var ov = this._overlay;
+ var map = ov._map;
+ var mode = this.getMode();
+
+ if (this.currentHandle) {
+ map.removeLayer(this.currentHandle);
+ }
+
+ this.currentHandle = mode === '' ? '' : this._handles[mode];
+
+ if (this.currentHandle !== '') {
+ map.addLayer(this.currentHandle);
+ }
+ },
+ _addToolbar: function _addToolbar() {
+ var ov = this._overlay;
+ var eP = this.parentGroup;
+ var map = ov._map; // Find the topmost point on the image.
+
+ var corners = ov.getCorners();
+ var maxLat = -Infinity;
+
+ if (eP && eP.anyCollected()) {
+ eP.editing._addToolbar();
+
+ return;
+ }
+
+ if (ov.options.suppressToolbar || this.toolbar) {
+ return;
+ }
+
+ for (var i = 0; i < corners.length; i++) {
+ if (corners[i].lat > maxLat) {
+ maxLat = corners[i].lat;
+ }
+ } // Longitude is based on the centroid of the image.
+
+
+ var raisedPoint = ov.getCenter();
+ raisedPoint.lat = maxLat;
+ this.toolbar = L.distortableImage.popupBar(raisedPoint, {
+ actions: this.editActions
+ }).addTo(map, ov);
+ ov.fire('toolbar:created');
+ },
+ _refresh: function _refresh() {
+ if (this.toolbar) {
+ this._removeToolbar();
+ }
+
+ this._addToolbar();
+ },
+ _updateToolbarPos: function _updateToolbarPos() {
+ var overlay = this._overlay; // Find the topmost point on the image.
+
+ var corners = overlay.getCorners();
+ var toolbar = this.toolbar;
+ var maxLat = -Infinity;
+
+ if (toolbar && toolbar instanceof L.DistortableImage.PopupBar) {
+ for (var i = 0; i < corners.length; i++) {
+ if (corners[i].lat > maxLat) {
+ maxLat = corners[i].lat;
+ }
+ } // Longitude is based on the centroid of the image.
+
+
+ var raisedPoint = overlay.getCenter();
+ raisedPoint.lat = maxLat;
+
+ if (!overlay.options.suppressToolbar) {
+ this.toolbar.setLatLng(raisedPoint);
+ }
+ }
+ },
+ hasMode: function hasMode(mode) {
+ return !!this._modes[mode];
+ },
+ getMode: function getMode() {
+ if (!this.enabled()) {
+ return;
+ }
+
+ return this._mode;
+ },
+ getModes: function getModes() {
+ return this._modes;
+ },
+ isMode: function isMode(mode) {
+ if (!this.enabled()) {
+ return false;
+ }
+
+ return this._mode === mode;
+ },
+ setMode: function setMode(newMode) {
+ var ov = this._overlay;
+ var eP = this.parentGroup;
+ var mode = this.getMode();
+
+ if (mode === newMode || !this.hasMode(newMode) || !this.enabled()) {
+ return;
+ }
+
+ if (this.toolbar) {
+ this.toolbar.clickTool(newMode);
+ }
+
+ if (this.isMode('lock') && !this.dragging) {
+ this._enableDragging();
+ }
+
+ this._mode = newMode;
+
+ if (this.isMode('lock')) {
+ this._disableDragging();
+ }
+
+ this._updateHandle();
+
+ this._refresh();
+
+ if (eP && eP.isCollected(ov)) {
+ ov.deselect();
+ }
+
+ return this;
+ },
+
+ /**
+ * need to attach a stop to img dblclick or it will propagate to
+ * the map and fire the handler that shows map location labels on map dblclick.
+ */
+ nextMode: function nextMode(e) {
+ var mode = this.getMode();
+ var eP = this.parentGroup;
+ var modesArray = Object.keys(this.getModes());
+ var idx = modesArray.indexOf(mode);
+ var nextIdx = (idx + 1) % modesArray.length;
+ var newMode = modesArray[nextIdx];
+
+ if (e) {
+ if (eP && eP.anyCollected()) {
+ return;
+ }
+
+ L.DomEvent.stop(e);
+ }
+
+ return this.setMode(newMode);
+ }
+});
+
+L.distortableImage.edit = function (overlay, options) {
+ return new L.DistortableImage.Edit(overlay, options);
+};
+
+/***/ }),
+
+/***/ "./src/edit/actions/BorderAction.js":
+/*!******************************************!*\
+ !*** ./src/edit/actions/BorderAction.js ***!
+ \******************************************/
+/***/ (function() {
+
+L.BorderAction = L.EditAction.extend({
+ initialize: function initialize(map, overlay, options) {
+ var edit = overlay.editing;
+ var mode = edit._mode;
+ var use;
+ var tooltip;
+
+ if (edit._outlined) {
+ use = 'border_outer';
+ tooltip = overlay.options.translation.removeBorder;
+ } else {
+ use = 'border_clear';
+ tooltip = overlay.options.translation.addBorder;
+ }
+
+ options = options || {};
+ options.toolbarIcon = {
+ svg: true,
+ html: use,
+ tooltip: tooltip,
+ className: mode === 'lock' ? 'disabled' : ''
+ }; // conditional for disabling keybindings for this action when the image is locked.
+
+ L.DistortableImage.action_map.b = mode === 'lock' ? '' : '_toggleBorder';
+ L.EditAction.prototype.initialize.call(this, map, overlay, options);
+ },
+ addHooks: function addHooks() {
+ var edit = this._overlay.editing;
+ L.IconUtil.toggleXlink(this._link, 'border_clear', 'border_outer');
+ L.IconUtil.toggleTitle(this._link, 'Remove Border', 'Add Border');
+
+ edit._toggleBorder();
+ }
+});
+
+/***/ }),
+
+/***/ "./src/edit/actions/DeleteAction.js":
+/*!******************************************!*\
+ !*** ./src/edit/actions/DeleteAction.js ***!
+ \******************************************/
+/***/ (function() {
+
+L.DeleteAction = L.EditAction.extend({
+ initialize: function initialize(map, overlay, options) {
+ var edit = overlay.editing;
+ var use = 'delete_forever';
+ var tooltip;
+ /**
+ * we can tell whether the overlay is an instance of `L.DistortableImageOverlay` or `L.DistortableCollection` bc only
+ * the former should have `parentGroup` defined on it. From there we call the apporpriate keybindings and methods.
+ */
+
+ if (edit instanceof L.DistortableImage.Edit) {
+ tooltip = overlay.options.translation.deleteImage; // backspace windows / delete mac
+
+ L.DistortableImage.action_map.Backspace = edit._mode === 'lock' ? '' : '_removeOverlay';
+ } else {
+ tooltip = overlay.options.translation.deleteImages;
+ L.DistortableImage.group_action_map.Backspace = edit._mode === 'lock' ? '' : '_removeGroup';
+ }
+
+ options = options || {};
+ options.toolbarIcon = {
+ svg: true,
+ html: use,
+ tooltip: tooltip,
+ className: edit._mode === 'lock' ? 'disabled' : ''
+ };
+ L.EditAction.prototype.initialize.call(this, map, overlay, options);
+ },
+ addHooks: function addHooks() {
+ var edit = this._overlay.editing;
+
+ if (edit instanceof L.DistortableImage.Edit) {
+ edit._removeOverlay();
+ } else {
+ edit._removeGroup();
+ }
+ }
+});
+
+/***/ }),
+
+/***/ "./src/edit/actions/DistortAction.js":
+/*!*******************************************!*\
+ !*** ./src/edit/actions/DistortAction.js ***!
+ \*******************************************/
+/***/ (function() {
+
+L.DistortAction = L.EditAction.extend({
+ initialize: function initialize(map, overlay, options) {
+ options = options || {};
+ options.toolbarIcon = {
+ svg: true,
+ html: 'distort',
+ tooltip: overlay.options.translation.distortImage,
+ className: 'distort'
+ };
+ L.DistortableImage.action_map.d = '_distortMode';
+ L.EditAction.prototype.initialize.call(this, map, overlay, options);
+ },
+ addHooks: function addHooks() {
+ var edit = this._overlay.editing;
+
+ edit._distortMode();
+ }
+});
+
+/***/ }),
+
+/***/ "./src/edit/actions/DragAction.js":
+/*!****************************************!*\
+ !*** ./src/edit/actions/DragAction.js ***!
+ \****************************************/
+/***/ (function() {
+
+L.DragAction = L.EditAction.extend({
+ initialize: function initialize(map, overlay, options) {
+ options = options || {};
+ options.toolbarIcon = {
+ svg: true,
+ html: 'drag',
+ tooltip: overlay.options.translation.dragImage,
+ className: 'drag'
+ };
+ L.DistortableImage.action_map.D = '_dragMode';
+ L.EditAction.prototype.initialize.call(this, map, overlay, options);
+ },
+ addHooks: function addHooks() {
+ var edit = this._overlay.editing;
+
+ edit._dragMode();
+ }
+});
+
+/***/ }),
+
+/***/ "./src/edit/actions/EditAction.js":
+/*!****************************************!*\
+ !*** ./src/edit/actions/EditAction.js ***!
+ \****************************************/
+/***/ (function() {
+
+L.DistortableImage = L.DistortableImage || {};
+L.distortableImage = L.DistortableImage;
+L.DistortableImage.action_map = {};
+L.EditAction = L.Toolbar2.Action.extend({
+ options: {
+ toolbarIcon: {
+ svg: false,
+ html: '',
+ className: '',
+ tooltip: ''
+ }
+ },
+ initialize: function initialize(map, overlay, options) {
+ this._overlay = overlay;
+ this._map = map;
+ L.setOptions(this, options);
+ L.Toolbar2.Action.prototype.initialize.call(this, options);
+
+ this._injectIconSet();
+ },
+ _createIcon: function _createIcon(toolbar, container, args) {
+ var _this = this;
+
+ var iconOptions = this.options.toolbarIcon;
+ var className = iconOptions.className;
+ var edit = this._overlay.editing;
+ this.toolbar = toolbar;
+ this._icon = L.DomUtil.create('li', '', container);
+ this._link = L.DomUtil.create('a', '', this._icon);
+
+ if (iconOptions.svg) {
+ this._link.innerHTML = L.IconUtil.create(iconOptions.html);
+ } else {
+ this._link.innerHTML = iconOptions.html;
+ }
+
+ this._link.setAttribute('href', '#');
+
+ this._link.setAttribute('title', iconOptions.tooltip);
+
+ this._link.setAttribute('role', 'button');
+
+ L.DomUtil.addClass(this._link, this.constructor.baseClass);
+
+ if (className) {
+ L.DomUtil.addClass(this._link, className);
+
+ if (className === 'disabled') {
+ L.DomUtil.addClass(this._icon, className);
+ }
+
+ if (className === edit._mode) {
+ L.DomUtil.addClass(this._link, 'selected-mode');
+ } else {
+ L.DomUtil.removeClass(this._link, 'selected-mode');
+ }
+ }
+
+ L.DomEvent.on(this._link, 'click', this.enable, this);
+ L.DomEvent.on(this._overlay, 'update', function () {
+ var match = _this._link.innerHTML.match(/xlink:href="#restore"/);
+
+ if (match && match.length === 1) {
+ _this._enableAction();
+ }
+ });
+ /* Add secondary toolbar */
+
+ this._addSubToolbar(toolbar, this._icon, args);
+ },
+ _injectIconSet: function _injectIconSet() {
+ if (document.querySelector('#iconset')) {
+ return;
+ }
+
+ var el = document.createElement('div');
+ el.id = 'iconset';
+ el.setAttribute('hidden', 'hidden');
+ el.innerHTML = new L.ToolbarIconSet().render();
+ document.querySelector('.leaflet-marker-pane').appendChild(el);
+ },
+ _enableAction: function _enableAction() {
+ L.DomUtil.removeClass(this._link.parentElement, 'disabled');
+ L.DomUtil.removeClass(this._link, 'disabled');
+ },
+ _disableAction: function _disableAction() {
+ L.DomUtil.addClass(this._link.parentElement, 'disabled');
+ L.DomUtil.addClass(this._link, 'disabled');
+ }
+});
+
+L.editAction = function (map, overlay, options) {
+ return new L.EditAction(map, overlay, options);
+};
+
+/***/ }),
+
+/***/ "./src/edit/actions/ExportAction.js":
+/*!******************************************!*\
+ !*** ./src/edit/actions/ExportAction.js ***!
+ \******************************************/
+/***/ (function() {
+
+L.ExportAction = L.EditAction.extend({
+ // This function is executed every time we select an image
+ initialize: function initialize(map, overlay, options) {
+ var edit = overlay.editing;
+ var tooltip;
+ this.isExporting = false;
+ this.mouseLeaveSkip = true;
+ this.isHooksExecuted = false;
+
+ if (edit instanceof L.DistortableImage.Edit) {
+ L.DistortableImage.action_map.e = '_getExport';
+ tooltip = overlay.options.translation.exportImage;
+ } else {
+ L.DistortableImage.group_action_map.e = 'runExporter';
+ tooltip = overlay.options.translation.exportImages;
+ }
+
+ options = options || {};
+ options.toolbarIcon = {
+ svg: true,
+ html: 'get_app',
+ tooltip: tooltip
+ };
+ L.EditAction.prototype.initialize.call(this, map, overlay, options);
+ },
+ addHooks: function addHooks() {
+ var edit = this._overlay.editing;
+
+ if (edit instanceof L.DistortableImage.Edit) {
+ edit._getExport();
+
+ return;
+ } // Make sure that addHooks is executed only once, event listeners will handle the rest
+
+
+ if (this.isHooksExecuted) {
+ return;
+ } else {
+ this.isHooksExecuted = true;
+ }
+
+ var exportTool = this._link.parentElement;
+ this.mouseEnterHandler = this.handleMouseEnter.bind(this);
+ this.mouseLeaveHandler = this.handleMouseLeave.bind(this);
+ L.DomEvent.on(exportTool, 'click', function () {
+ if (!this.isExporting) {
+ this.isExporting = true;
+ this.renderExportIcon();
+ setTimeout(this.attachMouseEventListeners.bind(this, exportTool), 100);
+ edit.runExporter().then(function () {
+ this.resetState();
+ this.detachMouseEventListeners(exportTool);
+ }.bind(this));
+ } else {
+ // Clicking on the export icon after export has started will be ignored
+ if (this.mouseLeaveSkip) {
+ return;
+ }
+
+ this.resetState();
+ this.detachMouseEventListeners(exportTool);
+ edit.cancelExport();
+ }
+ }, this);
+ },
+ resetState: function resetState() {
+ this.renderDownloadIcon();
+ this.isExporting = false;
+ this.mouseLeaveSkip = true;
+ },
+ attachMouseEventListeners: function attachMouseEventListeners(element) {
+ element.addEventListener('mouseenter', this.mouseEnterHandler);
+ element.addEventListener('mouseleave', this.mouseLeaveHandler);
+ },
+ detachMouseEventListeners: function detachMouseEventListeners(element) {
+ element.removeEventListener('mouseenter', this.mouseEnterHandler);
+ element.removeEventListener('mouseleave', this.mouseLeaveHandler);
+ },
+ handleMouseEnter: function handleMouseEnter() {
+ this.renderCancelIcon();
+ },
+ handleMouseLeave: function handleMouseLeave() {
+ if (!this.mouseLeaveSkip) {
+ this.renderExportIcon();
+ } else {
+ this.mouseLeaveSkip = false;
+ }
+ },
+ renderDownloadIcon: function renderDownloadIcon() {
+ L.IconUtil.toggleXlink(this._link, 'get_app', 'spinner');
+ L.IconUtil.toggleTitle(this._link, 'Export Images', 'Loading...');
+ L.DomUtil.removeClass(this._link.firstChild, 'loader');
+ },
+ renderExportIcon: function renderExportIcon() {
+ L.IconUtil.toggleXlink(this._link, 'spinner');
+ L.IconUtil.toggleTitle(this._link, 'Export Images', 'Loading...');
+ L.IconUtil.addClassToSvg(this._link, 'loader');
+ },
+ renderCancelIcon: function renderCancelIcon() {
+ L.IconUtil.toggleXlink(this._link, 'cancel');
+ L.IconUtil.toggleTitle(this._link, 'Cancel Export', 'Loading...');
+ L.DomUtil.removeClass(this._link.firstChild, 'loader');
+ }
+});
+
+/***/ }),
+
+/***/ "./src/edit/actions/FreeRotateAction.js":
+/*!**********************************************!*\
+ !*** ./src/edit/actions/FreeRotateAction.js ***!
+ \**********************************************/
+/***/ (function() {
+
+L.FreeRotateAction = L.EditAction.extend({
+ initialize: function initialize(map, overlay, options) {
+ options = options || {};
+ options.toolbarIcon = {
+ svg: true,
+ html: 'crop_rotate',
+ tooltip: overlay.options.translation.freeRotateImage,
+ className: 'freeRotate'
+ };
+ L.DistortableImage.action_map.f = '_freeRotateMode';
+ L.EditAction.prototype.initialize.call(this, map, overlay, options);
+ },
+ addHooks: function addHooks() {
+ var edit = this._overlay.editing;
+
+ edit._freeRotateMode();
+ }
+});
+
+/***/ }),
+
+/***/ "./src/edit/actions/GeolocateAction.js":
+/*!*********************************************!*\
+ !*** ./src/edit/actions/GeolocateAction.js ***!
+ \*********************************************/
+/***/ (function() {
+
+L.GeolocateAction = L.EditAction.extend({
+ initialize: function initialize(map, overlay, options) {
+ var edit = overlay.editing;
+ options = options || {};
+ options.toolbarIcon = {
+ svg: true,
+ html: 'explore',
+ tooltip: overlay.options.translation.geolocateImage,
+ className: edit._mode === 'lock' ? 'disabled' : ''
+ };
+ L.EditAction.prototype.initialize.call(this, map, overlay, options);
+ },
+ addHooks: function addHooks() {
+ var image = this._overlay.getElement();
+
+ EXIF.getData(image, L.EXIF(image));
+ }
+});
+
+/***/ }),
+
+/***/ "./src/edit/actions/LockAction.js":
+/*!****************************************!*\
+ !*** ./src/edit/actions/LockAction.js ***!
+ \****************************************/
+/***/ (function() {
+
+L.LockAction = L.EditAction.extend({
+ initialize: function initialize(map, overlay, options) {
+ var edit = overlay.editing;
+ var use;
+ var tooltip;
+
+ if (edit instanceof L.DistortableImage.Edit) {
+ L.DistortableImage.action_map.u = '_unlock';
+ L.DistortableImage.action_map.l = '_lock';
+ tooltip = overlay.options.translation.lockMode;
+ use = edit.isMode('lock') ? 'lock' : 'unlock';
+ } else {
+ L.DistortableImage.group_action_map.l = '_lockGroup';
+ tooltip = overlay.options.translation.lockImages;
+ use = 'lock';
+ }
+
+ options = options || {};
+ options.toolbarIcon = {
+ svg: true,
+ html: use,
+ tooltip: tooltip,
+ className: 'lock'
+ };
+ L.EditAction.prototype.initialize.call(this, map, overlay, options);
+ },
+ addHooks: function addHooks() {
+ var edit = this._overlay.editing;
+
+ if (edit instanceof L.DistortableImage.Edit) {
+ edit._toggleLockMode();
+ } else {
+ edit._lockGroup();
+ }
+ }
+});
+
+/***/ }),
+
+/***/ "./src/edit/actions/OpacityAction.js":
+/*!*******************************************!*\
+ !*** ./src/edit/actions/OpacityAction.js ***!
+ \*******************************************/
+/***/ (function() {
+
+L.OpacityAction = L.EditAction.extend({
+ initialize: function initialize(map, overlay, options) {
+ var edit = overlay.editing;
+ var mode = edit._mode;
+ var use;
+ var tooltip;
+
+ if (edit._transparent) {
+ use = 'opacity_empty';
+ tooltip = overlay.options.translation.makeImageOpaque;
+ } else {
+ use = 'opacity';
+ tooltip = overlay.options.translation.makeImageTransparent;
+ }
+
+ options = options || {};
+ options.toolbarIcon = {
+ svg: true,
+ html: use,
+ tooltip: tooltip,
+ className: mode === 'lock' ? 'disabled' : ''
+ };
+ L.DistortableImage.action_map.o = mode === 'lock' ? '' : '_toggleOpacity';
+ L.EditAction.prototype.initialize.call(this, map, overlay, options);
+ },
+ addHooks: function addHooks() {
+ var edit = this._overlay.editing;
+ var link = this._link;
+ L.IconUtil.toggleXlink(link, 'opacity', 'opacity_empty');
+ L.IconUtil.toggleTitle(link, 'Make Image Transparent', 'Make Image Opaque');
+
+ edit._toggleOpacity();
+ }
+});
+
+/***/ }),
+
+/***/ "./src/edit/actions/RestoreAction.js":
+/*!*******************************************!*\
+ !*** ./src/edit/actions/RestoreAction.js ***!
+ \*******************************************/
+/***/ (function() {
+
+L.RestoreAction = L.EditAction.extend({
+ initialize: function initialize(map, overlay, options) {
+ var mode = L.Utils.getNestedVal(overlay, 'editing', '_mode');
+ var edited = overlay.edited;
+ options = options || {};
+ options.toolbarIcon = {
+ svg: true,
+ html: 'restore',
+ tooltip: overlay.options.translation.restoreImage,
+ className: edited && mode !== 'lock' ? '' : 'disabled'
+ };
+ L.EditAction.prototype.initialize.call(this, map, overlay, options);
+ },
+ addHooks: function addHooks() {
+ var ov = this._overlay;
+ L.DomEvent.on(ov, {
+ edit: this._enableAction,
+ restore: this._disableAction
+ }, this);
+ ov.restore();
+ }
+});
+
+/***/ }),
+
+/***/ "./src/edit/actions/RotateAction.js":
+/*!******************************************!*\
+ !*** ./src/edit/actions/RotateAction.js ***!
+ \******************************************/
+/***/ (function() {
+
+L.RotateAction = L.EditAction.extend({
+ initialize: function initialize(map, overlay, options) {
+ options = options || {};
+ options.toolbarIcon = {
+ svg: true,
+ html: 'rotate',
+ tooltip: overlay.options.translation.rotateImage,
+ className: 'rotate'
+ };
+ L.DistortableImage.action_map.r = '_rotateMode';
+ L.EditAction.prototype.initialize.call(this, map, overlay, options);
+ },
+ addHooks: function addHooks() {
+ var edit = this._overlay.editing;
+
+ edit._rotateMode();
+ }
+});
+
+/***/ }),
+
+/***/ "./src/edit/actions/ScaleAction.js":
+/*!*****************************************!*\
+ !*** ./src/edit/actions/ScaleAction.js ***!
+ \*****************************************/
+/***/ (function() {
+
+L.ScaleAction = L.EditAction.extend({
+ initialize: function initialize(map, overlay, options) {
+ options = options || {};
+ options.toolbarIcon = {
+ svg: true,
+ html: 'scale',
+ tooltip: overlay.options.translation.scaleImage,
+ className: 'scale'
+ };
+ L.DistortableImage.action_map.s = '_scaleMode';
+ L.EditAction.prototype.initialize.call(this, map, overlay, options);
+ },
+ addHooks: function addHooks() {
+ var edit = this._overlay.editing;
+
+ edit._scaleMode();
+ }
+});
+
+/***/ }),
+
+/***/ "./src/edit/actions/StackAction.js":
+/*!*****************************************!*\
+ !*** ./src/edit/actions/StackAction.js ***!
+ \*****************************************/
+/***/ (function() {
+
+L.StackAction = L.EditAction.extend({
+ initialize: function initialize(map, overlay, options) {
+ var edit = overlay.editing;
+ var use;
+ var tooltip;
+
+ if (edit._toggledImage) {
+ use = 'flip_to_back';
+ tooltip = overlay.options.translation.stackToFront;
+ } else {
+ use = 'flip_to_front';
+ tooltip = overlay.options.translation.stackToBack;
+ }
+
+ options = options || {};
+ options.toolbarIcon = {
+ svg: true,
+ html: use,
+ tooltip: tooltip,
+ className: edit._mode === 'lock' ? 'disabled' : ''
+ };
+ L.DistortableImage.action_map.q = edit._mode === 'lock' ? '' : '_stackUp';
+ L.DistortableImage.action_map.a = edit._mode === 'lock' ? '' : '_stackDown';
+ L.EditAction.prototype.initialize.call(this, map, overlay, options);
+ },
+ addHooks: function addHooks() {
+ var edit = this._overlay.editing;
+ L.IconUtil.toggleXlink(this._link, 'flip_to_front', 'flip_to_back');
+ L.IconUtil.toggleTitle(this._link, 'Stack to Front', 'Stack to Back');
+
+ edit._toggleOrder();
+ }
+});
+
+/***/ }),
+
+/***/ "./src/edit/actions/UnlockAction.js":
+/*!******************************************!*\
+ !*** ./src/edit/actions/UnlockAction.js ***!
+ \******************************************/
+/***/ (function() {
+
+L.UnlockAction = L.EditAction.extend({
+ initialize: function initialize(map, overlay, options) {
+ options = options || {};
+ options.toolbarIcon = {
+ svg: true,
+ html: 'unlock',
+ tooltip: overlay.options.translation.unlockImages
+ };
+ L.DistortableImage.group_action_map.u = '_unlockGroup';
+ L.EditAction.prototype.initialize.call(this, map, overlay, options);
+ },
+ addHooks: function addHooks() {
+ var edit = this._overlay.editing;
+
+ edit._unlockGroup();
+ }
+});
+
+/***/ }),
+
+/***/ "./src/edit/getEXIFdata.js":
+/*!*********************************!*\
+ !*** ./src/edit/getEXIFdata.js ***!
+ \*********************************/
+/***/ (function() {
+
+/* eslint-disable no-unused-vars */
+L.EXIF = function getEXIFdata(img) {
+ if (Object.keys(EXIF.getAllTags(img)).length !== 0) {
+ console.log(EXIF.getAllTags(img));
+ var GPS = EXIF.getAllTags(img);
+ var altitude;
+ /* If the lat/lng is available. */
+
+ if (typeof GPS.GPSLatitude !== 'undefined' && typeof GPS.GPSLongitude !== 'undefined') {
+ // sadly, encoded in [degrees,minutes,seconds]
+ // primitive value = GPS.GPSLatitude[x].numerator
+ var lat = GPS.GPSLatitude[0] + GPS.GPSLatitude[1] / 60 + GPS.GPSLatitude[2] / 3600;
+ var lng = GPS.GPSLongitude[0] + GPS.GPSLongitude[1] / 60 + GPS.GPSLongitude[2] / 3600;
+
+ if (GPS.GPSLatitudeRef !== 'N') {
+ lat = lat * -1;
+ }
+
+ if (GPS.GPSLongitudeRef === 'W') {
+ lng = lng * -1;
+ }
+ } // Attempt to use GPS compass heading; will require
+ // some trig to calc corner points, which you can find below:
+
+
+ var angle = 0; // "T" refers to "True north", so -90.
+
+ if (GPS.GPSImgDirectionRef === 'T') {
+ angle = Math.PI / 180 * (GPS.GPSImgDirection.numerator / GPS.GPSImgDirection.denominator - 90); // "M" refers to "Magnetic north"
+ } else if (GPS.GPSImgDirectionRef === 'M') {
+ angle = Math.PI / 180 * (GPS.GPSImgDirection.numerator / GPS.GPSImgDirection.denominator - 90);
+ } else {
+ console.log('No compass data found');
+ }
+
+ console.log('Orientation:', GPS.Orientation);
+ /* If there is orientation data -- i.e. landscape/portrait etc */
+
+ if (GPS.Orientation === 6) {
+ // CCW
+ angle += Math.PI / 180 * -90;
+ } else if (GPS.Orientation === 8) {
+ // CW
+ angle += Math.PI / 180 * 90;
+ } else if (GPS.Orientation === 3) {
+ // 180
+ angle += Math.PI / 180 * 180;
+ }
+ /* If there is altitude data */
+
+
+ if (typeof GPS.GPSAltitude !== 'undefined' && typeof GPS.GPSAltitudeRef !== 'undefined') {
+ // Attempt to use GPS altitude:
+ // (may eventually need to find EXIF field of view for correction)
+ if (typeof GPS.GPSAltitude !== 'undefined' && typeof GPS.GPSAltitudeRef !== 'undefined') {
+ altitude = GPS.GPSAltitude.numerator / GPS.GPSAltitude.denominator + GPS.GPSAltitudeRef;
+ } else {
+ altitude = 0; // none
+ }
+ }
+ } else {
+ alert('EXIF initialized. Press again to view data in console.');
+ }
+};
+
+/***/ }),
+
+/***/ "./src/edit/handles/DistortHandle.js":
+/*!*******************************************!*\
+ !*** ./src/edit/handles/DistortHandle.js ***!
+ \*******************************************/
+/***/ (function() {
+
+L.DistortHandle = L.EditHandle.extend({
+ options: {
+ TYPE: 'distort',
+ icon: L.icon({
+ iconUrl: // eslint-disable-next-line max-len
+ 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAklEQVR4AewaftIAAAChSURBVO3BIU4DURgGwNkvL2B6AkQTLBqP4QCoSm7DDXoBLBZHDbfgICAIZjEV3YTn9uVHdMZZtcnCfI13bIzxg0emg6Nm6QVbYz3jylEsXRrvwommb49X67jFkz80fR9Mb1YxTzqiWBSLYlEsikWxKBbFolgUi2JRLIpFsSgWxaJY03fHHOu40dH07bAzWCx9Ge/TiWbpHgdsjPGNB2f/yS+7xRCyiiZPJQAAAABJRU5ErkJggg==',
+ iconSize: [32, 32],
+ iconAnchor: [16, 16]
+ })
+ },
+ _onHandleDrag: function _onHandleDrag() {
+ var overlay = this._handled;
+ overlay.setCorner(this._corner, this.getLatLng());
+ },
+ updateHandle: function updateHandle() {
+ this.setLatLng(this._handled.getCorner(this._corner));
+ }
+});
+
+L.distortHandle = function (overlay, idx, options) {
+ return new L.DistortHandle(overlay, idx, options);
+};
+
+/***/ }),
+
+/***/ "./src/edit/handles/DragHandle.js":
+/*!****************************************!*\
+ !*** ./src/edit/handles/DragHandle.js ***!
+ \****************************************/
+/***/ (function() {
+
+L.DragHandle = L.EditHandle.extend({
+ options: {
+ TYPE: 'drag',
+ icon: L.icon({
+ // eslint-disable-next-line max-len
+ iconUrl: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAsVJREFUeNrMVztLXEEUvnNVFAVBAhY2aRKbTZEHJNpYabuNjSgYg/GxdsmPSJkUAa/ZdVEX8mgWYVutbHxAHkVskjQBuUUgBISVhCQk3wnfwMlk1rusN1wHPubOzJlzvjlz5sxc01Ma/hUEwQnwDIjqc7uvgv9YYO86qgIwCXQbdNTlQ8kcCBHgBch8TcloF6oJGr6phk6EQAkfdz3zvgDr9Mr7Fg1fptEZoM8jsmrokpfsiIFO4IIjuE2v1EDmR4LRdlR5Gh51hj8D34ABtm8YTtqna0TgklIw5CgQguKxIojEjmFROg/MKQO27NkFAB+4wAPouGUJiIvWKHwbAxX2XyWRKWkqhT+pbJntJZJuUzISW0+5hW+obxrVBsfvoH/dqCCJuU97GBh2VteLSiYvArmErT8EVoAK9Bw7enbpVYmvAQlyowYforrH5jXL2rPHI/TKONDB7u9AlavdaTBPvPmazUeQuy8f7UomUgTEwIJPEQ3sQGE/6ll2l9H/KcEzBcfWn2IclluM3DpddJxSHujlFkscbUPvmB0LHVnLrId7nlaZVkEc6QGXQI1MAwZcWmVRHeNaQwJMMiU2cwy4s7p/RJ2ckpvIQs+cIs+5GzitloLKHUV3MPREuXbTOKO91dX387gGTONxIgEWm+E61FFrpcyqXLHsEwiDjEsjAksqw5XPoL9MHVrn6QR4q+XZrDaR4RoWzq2ymafuRA/Mq1stSsHLVkcbdf9VjOcx8ZH3+SFWcCWlVPyWuUBOwUWdC1wP5NVjYiXFWLO69PZ6CRTUY6KSIoEKdf6T3IzzgHxnsyHctNBEkmn6Oob8ExUDg/ahGybd177cDjzH5xHwgDiSvoS7I/LZyvxJZj0wod7tkX5G0XVC7rEyLhfLJjBGbKoLLEfZWObyKeZ6oY82g+yf5Zn/mJyHX7PMf04z/T3/LcAAu4E6iiyJqf0AAAAASUVORK5CYII=',
+ iconSize: [32, 32],
+ iconAnchor: [16, 16]
+ })
+ },
+ _onHandleDrag: function _onHandleDrag() {
+ var overlay = this._handled;
+ var formerLatLng = overlay.getCorner(this._corner);
+ var newLatLng = this.getLatLng();
+ overlay.dragBy(formerLatLng, newLatLng);
+ },
+ updateHandle: function updateHandle() {
+ this.setLatLng(this._handled.getCorner(this._corner));
+ }
+});
+
+L.dragHandle = function (overlay, idx, options) {
+ return new L.DragHandle(overlay, idx, options);
+};
+
+/***/ }),
+
+/***/ "./src/edit/handles/EditHandle.js":
+/*!****************************************!*\
+ !*** ./src/edit/handles/EditHandle.js ***!
+ \****************************************/
+/***/ (function() {
+
+L.EditHandle = L.Marker.extend({
+ initialize: function initialize(overlay, corner, options) {
+ var latlng = overlay.getCorner(corner);
+ L.setOptions(this, options);
+ this._handled = overlay;
+ this._corner = corner;
+ var markerOptions = {
+ draggable: true,
+ zIndexOffset: 10
+ };
+
+ if (options && options.hasOwnProperty('draggable')) {
+ markerOptions.draggable = options.draggable;
+ }
+
+ L.Marker.prototype.initialize.call(this, latlng, markerOptions);
+ },
+ onAdd: function onAdd(map) {
+ L.Marker.prototype.onAdd.call(this, map);
+
+ this._bindListeners();
+
+ this.updateHandle();
+ },
+ onRemove: function onRemove(map) {
+ this._unbindListeners();
+
+ L.Marker.prototype.onRemove.call(this, map);
+ },
+ _onHandleDragStart: function _onHandleDragStart() {
+ this._handled.fire('editstart');
+ },
+ _onHandleDragEnd: function _onHandleDragEnd() {
+ this._fireEdit();
+ },
+ _fireEdit: function _fireEdit() {
+ this._handled.edited = true;
+
+ this._handled.fire('edit');
+ },
+ _bindListeners: function _bindListeners() {
+ this.on({
+ contextmenu: L.DomEvent.stop,
+ dragstart: this._onHandleDragStart,
+ drag: this._onHandleDrag,
+ dragend: this._onHandleDragEnd
+ }, this);
+
+ this._handled._map.on('zoomend', this.updateHandle, this);
+
+ this._handled.on('update', this.updateHandle, this);
+ },
+ _unbindListeners: function _unbindListeners() {
+ this.off({
+ contextmenu: L.DomEvent.stop,
+ dragstart: this._onHandleDragStart,
+ drag: this._onHandleDrag,
+ dragend: this._onHandleDragEnd
+ }, this);
+
+ this._handled._map.off('zoomend', this.updateHandle, this);
+
+ this._handled.off('update', this.updateHandle, this);
+ },
+
+ /* Takes two latlngs and calculates the scaling difference. */
+ _calculateScalingFactor: function _calculateScalingFactor(latlngA, latlngB) {
+ var overlay = this._handled;
+ var map = overlay._map;
+ var centerPoint = map.latLngToLayerPoint(overlay.getCenter());
+ var formerPoint = map.latLngToLayerPoint(latlngA);
+ var newPoint = map.latLngToLayerPoint(latlngB);
+
+ var formerRadiusSquared = this._d2(centerPoint, formerPoint);
+
+ var newRadiusSquared = this._d2(centerPoint, newPoint);
+
+ return Math.sqrt(newRadiusSquared / formerRadiusSquared);
+ },
+
+ /* Distance between two points in cartesian space, squared (distance formula). */
+ _d2: function _d2(a, b) {
+ var dx = a.x - b.x;
+ var dy = a.y - b.y;
+ return Math.pow(dx, 2) + Math.pow(dy, 2);
+ },
+
+ /* Takes two latlngs and calculates the angle between them. */
+ calculateAngleDelta: function calculateAngleDelta(latlngA, latlngB) {
+ var overlay = this._handled;
+ var map = overlay._map;
+ var centerPoint = map.latLngToLayerPoint(overlay.getCenter());
+ var formerPoint = map.latLngToLayerPoint(latlngA);
+ var newPoint = map.latLngToLayerPoint(latlngB);
+ var initialAngle = Math.atan2(centerPoint.y - formerPoint.y, centerPoint.x - formerPoint.x);
+ var newAngle = Math.atan2(centerPoint.y - newPoint.y, centerPoint.x - newPoint.x);
+ return newAngle - initialAngle;
+ }
+});
+
+/***/ }),
+
+/***/ "./src/edit/handles/FreeRotateHandle.js":
+/*!**********************************************!*\
+ !*** ./src/edit/handles/FreeRotateHandle.js ***!
+ \**********************************************/
+/***/ (function() {
+
+L.FreeRotateHandle = L.EditHandle.extend({
+ options: {
+ TYPE: 'freeRotate',
+ icon: L.icon({
+ iconUrl: // eslint-disable-next-line max-len
+ 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAklEQVR4AewaftIAAAHiSURBVMXBa3HbShgA0PMp/1sCCo8oCEpgTaCXgIXAJiDzyCJoAUTm4UVQAns1Y8+snWnTvJyeE16hkjDgDrfoNTMKcpC9UPiLSo8JyetkjEHxjPCMyoS199kFoz8Iv1HpMaN3qWDCHoegOKkkRwnJpRmroHgiPFEZ8IBekzEGxQtUEhKSS/fB7Ew4U+lxcGkVZG9QWWPSFAxBcdK59KApuA+yNwp2uEdx1GN25sZJZULSfAtm77SlbNjju6MvG75u+WHRWVR6rDVjMPsgwYyVZl3pLTpHkyYHOx8syMiayaJzlDTZ9YyaZNFVkiYH2ZUEBcVJJXVImuz6Js3Qofe59pq7DoOTILu+g+a288mCouk7/1iH4qTS+2QdDppbV1ZJmrnDXnPnc5UOs2Z0fUmTuyBr+krvSioJyUmQO0dZM7mepMkWnaNRkyrJB6uskTSjxY3Fll8bvmJwlDb83FJ8gMqAB80uyBY3Trb82PAfvjj6vuHnluIdKgMeNXOwctK5NKBoHitrb1RJeHRp5Ux4ojLg0aWMHGQvUOkxIWkKVsHsTPiNSo8HDC5lZIsgO6n0uMUdRvQuFQxB8UR4RmXC2vvsgtEfhL+o9JiQvE7GGBTPCK9QSUjoMWgKDthjDrIX+h/k0I7gth6N5gAAAABJRU5ErkJggg==',
+ iconSize: [32, 32],
+ iconAnchor: [16, 16]
+ })
+ },
+ _onHandleDrag: function _onHandleDrag() {
+ var overlay = this._handled;
+ var map = overlay._map;
+ var formerLatLng = overlay.getCorner(this._corner);
+ var newLatLng = this.getLatLng();
+ var angle = this.calculateAngleDelta(formerLatLng, newLatLng);
+
+ var scale = this._calculateScalingFactor(formerLatLng, newLatLng);
+
+ if (angle !== 0) {
+ overlay.rotateBy(angle, 'rad');
+ }
+
+ var edgeMinWidth = overlay.edgeMinWidth;
+
+ if (!edgeMinWidth) {
+ edgeMinWidth = 50;
+ }
+ /* just in case */
+
+
+ var corner1 = map.latLngToContainerPoint(overlay.getCorner(0));
+ var corner2 = map.latLngToContainerPoint(overlay.getCorner(1));
+ var w = Math.abs(corner1.x - corner2.x);
+ var h = Math.abs(corner1.y - corner2.y);
+ var distance = Math.sqrt(w * w + h * h);
+
+ if (distance > edgeMinWidth || scale > 1) {
+ overlay.scaleBy(scale);
+ } else {
+ overlay.scaleBy(1);
+ }
+ },
+ updateHandle: function updateHandle() {
+ this.setLatLng(this._handled.getCorner(this._corner));
+ }
+});
+
+L.freeRotateHandle = function (overlay, idx, options) {
+ return new L.FreeRotateHandle(overlay, idx, options);
+};
+
+/***/ }),
+
+/***/ "./src/edit/handles/LockHandle.js":
+/*!****************************************!*\
+ !*** ./src/edit/handles/LockHandle.js ***!
+ \****************************************/
+/***/ (function() {
+
+L.LockHandle = L.EditHandle.extend({
+ options: {
+ TYPE: 'lock',
+ interactive: false,
+ icon: L.icon({
+ // eslint-disable-next-line max-len
+ iconUrl: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAklEQVR4AewaftIAAAD8SURBVO3BPU7CYAAA0AdfjIcQlRCQBG7C3gk2uIPG2RC3Dk16Gz0FTO1WZs/gwGCMP/2+xsSl7+n1er1Iz9LtRQjaPeMeO+TinLDCJV78YqjdA04YodKuxhUaPGoRxMmxwRQZSt87Yo4KExGCeAUyLLFB4bMacxywEClIU2KDKXbInTUYo8JCgoFuGoxQO5uiwY1EA91VmDqrcKeDoX8WdNNgjApvmGGLXKIgXY0xGkxQYItrrFFIEKQ5Yo4KEx9yrDFDhlKkIF6NOQ5Y+KpAhiXWKEQI4pxwiwoLPyuxwQw75FoE7fZYocFEuwI7jHCBV39gL92TXq/Xi/AOcmczZmaIMScAAAAASUVORK5CYII=',
+ iconSize: [32, 32],
+ iconAnchor: [16, 16]
+ })
+ },
+ onRemove: function onRemove(map) {
+ this.unbindTooltip();
+ L.EditHandle.prototype.onRemove.call(this, map);
+ },
+ _bindListeners: function _bindListeners() {
+ var icon = this.getElement();
+
+ L.EditHandle.prototype._bindListeners.call(this);
+
+ L.DomEvent.on(icon, {
+ mousedown: this._tooltipOn,
+ mouseup: this._tooltipOff
+ }, this);
+ L.DomEvent.on(document, 'pointerleave', this._tooltipOff, this);
+ },
+ _unbindListeners: function _unbindListeners() {
+ var icon = this.getElement();
+
+ L.EditHandle.prototype._bindListeners.call(this);
+
+ L.DomEvent.off(icon, {
+ mousedown: this._tooltipOn,
+ mouseup: this._tooltipOff
+ }, this);
+ L.DomEvent.off(document, 'pointerleave', this._tooltipOff, this);
+ },
+
+ /* cannot be dragged */
+ _onHandleDrag: function _onHandleDrag() {},
+ updateHandle: function updateHandle() {
+ this.setLatLng(this._handled.getCorner(this._corner));
+ },
+ _tooltipOn: function _tooltipOn(e) {
+ var eP = this._handled.parentGroup;
+ var edit = eP ? eP.editing : this._handled.editing;
+
+ if (e.shiftKey) {
+ return;
+ }
+
+ if (!this._handled.isSelected() && eP && !eP.isCollected(this._handled)) {
+ return;
+ }
+
+ var handlesArr = edit._lockHandles;
+ this._timer = setTimeout(L.bind(function () {
+ if (this._timeout) {
+ clearTimeout(this._timeout);
+ }
+
+ if (!this.getTooltip()) {
+ this.bindTooltip('Locked!', {
+ permanent: true
});
- },
- 93: function () {
- (L.DistortableImage = L.DistortableImage || {}),
- (L.distortableImage = L.DistortableImage),
- (L.DistortableImage.action_map = {}),
- (L.DistortableImage.PopupBar = L.Toolbar2.Popup.extend({
- options: { anchor: [0, -10] },
- initialize: function (t, e) {
- L.setOptions(this, e),
- L.Toolbar2.Popup.prototype.initialize.call(this, t, e);
- },
- addHooks: function (t, e) {
- (this.map = t), (this.ov = e);
- },
- tools: function () {
- if (this._ul) return this._ul.children;
- },
- clickTool: function (t) {
- for (var e = this.tools(), i = 0; i < e.length; i++) {
- var o = e.item(i).children[0];
- if (L.DomUtil.hasClass(o, t)) return o.click(), o;
- }
- return !1;
- },
- })),
- (L.distortableImage.popupBar = function (t, e) {
- return new L.DistortableImage.PopupBar(t, e);
- }),
- L.DistortableImageOverlay.addInitHook(function () {
- (this.ACTIONS = [
- L.DragAction,
- L.ScaleAction,
- L.DistortAction,
- L.RotateAction,
- L.FreeRotateAction,
- L.LockAction,
- L.OpacityAction,
- L.BorderAction,
- L.ExportAction,
- L.DeleteAction,
- ]),
- (L.DistortableImage.Edit.MODES = {
- drag: L.DragAction,
- scale: L.ScaleAction,
- distort: L.DistortAction,
- rotate: L.RotateAction,
- freeRotate: L.FreeRotateAction,
- lock: L.LockAction,
- });
- var t = this.options.actions ? this.options.actions : this.ACTIONS;
- this.editing = L.distortableImage.edit(this, { actions: t });
+ } else {
+ handlesArr.eachLayer(function (handle) {
+ if (this !== handle) {
+ handle.closeTooltip();
+ }
});
- },
- 376: function () {
- L.IconSet = L.Class.extend({
- _svg: '