Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEATURE: Make collection export option dynamic #523

Merged
merged 2 commits into from
Jan 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions dist/leaflet.distortableimage.js
Original file line number Diff line number Diff line change
Expand Up @@ -3040,6 +3040,10 @@ L.DistortableCollection.Edit = L.Handler.extend({
},

cancelExport: function() {
if (!this.customCollection) {
this._exportOpts.collection = undefined;
}

clearInterval(this.updateInterval);
},

Expand Down Expand Up @@ -3116,6 +3120,11 @@ L.DistortableCollection.Edit = L.Handler.extend({

if (data.status === 'complete') {
clearInterval(self.updateInterval);

if (!self.customCollection) {
self._exportOpts.collection = undefined;
}

resolve();
if (data.jpg !== null) {
alert('Export succeeded. ' + opts.exportUrl + data.jpg);
Expand Down Expand Up @@ -3150,15 +3159,22 @@ L.DistortableCollection.Edit = L.Handler.extend({
crossDomain: true,
type: 'POST',
data: {
collection: JSON.stringify(opts.collection.images),
collection: JSON.stringify(opts.collection),
scale: opts.scale,
upload: true,
},
success: function(data) { opts.handleStatusRes(data); }, // this handles the initial response
});
}

opts.collection = opts.collection || this._group.generateExportJson();
// If the user has passed collection property
if (opts.collection) {
self.customCollection = true;
} else {
self.customCollection = false;
opts.collection = this._group.generateExportJson().images;
}

opts.frequency = opts.frequency || 3000;
opts.scale = opts.scale || 100; // switch it to _getAvgCmPerPixel !
opts.updater = opts.updater || _defaultUpdater;
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "leaflet-distortableimage",
"version": "0.11.1",
"version": "0.11.2",
"description": "Leaflet plugin enabling image overlays to be distorted, stretched, and warped (built for Public Lab's MapKnitter: http://publiclab.org).",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
Expand Down
20 changes: 18 additions & 2 deletions src/edit/DistortableCollection.Edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,10 @@ L.DistortableCollection.Edit = L.Handler.extend({
},

cancelExport: function() {
if (!this.customCollection) {
this._exportOpts.collection = undefined;
}

clearInterval(this.updateInterval);
},

Expand Down Expand Up @@ -275,6 +279,11 @@ L.DistortableCollection.Edit = L.Handler.extend({

if (data.status === 'complete') {
clearInterval(self.updateInterval);

if (!self.customCollection) {
self._exportOpts.collection = undefined;
}

resolve();
if (data.jpg !== null) {
alert('Export succeeded. ' + opts.exportUrl + data.jpg);
Expand Down Expand Up @@ -309,15 +318,22 @@ L.DistortableCollection.Edit = L.Handler.extend({
crossDomain: true,
type: 'POST',
data: {
collection: JSON.stringify(opts.collection.images),
collection: JSON.stringify(opts.collection),
scale: opts.scale,
upload: true,
},
success: function(data) { opts.handleStatusRes(data); }, // this handles the initial response
});
}

opts.collection = opts.collection || this._group.generateExportJson();
// If the user has passed collection property
if (opts.collection) {
self.customCollection = true;
} else {
self.customCollection = false;
opts.collection = this._group.generateExportJson().images;
}

opts.frequency = opts.frequency || 3000;
opts.scale = opts.scale || 100; // switch it to _getAvgCmPerPixel !
opts.updater = opts.updater || _defaultUpdater;
Expand Down