mirror of
https://github.com/publiclab/mapknitter.git
synced 2025-12-05 16:00:00 +01:00
new multi-exporter working (#1126)
This commit is contained in:
@@ -46,7 +46,6 @@
|
||||
//= require leaflet-draw/dist/leaflet.draw-src.js
|
||||
//= require leaflet-illustrate/dist/Leaflet.Illustrate.js
|
||||
//= require leaflet-distortableimage/dist/leaflet.distortableimage.js
|
||||
//= require leaflet-distortableimage/src/edit/tools/EditAction.js
|
||||
//= require mapknitter/Map.js
|
||||
//= require cable.js
|
||||
|
||||
|
||||
@@ -610,10 +610,8 @@ MapKnitter.Map = MapKnitter.Class.extend({
|
||||
},
|
||||
|
||||
setupCollection: function() {
|
||||
var customExports = mapknitter.customExportAction();
|
||||
|
||||
map._imgGroup = L.distortableCollection({
|
||||
actions: [customExports],
|
||||
editable: !mapknitter.readOnly
|
||||
}).addTo(map);
|
||||
|
||||
@@ -661,71 +659,8 @@ MapKnitter.Map = MapKnitter.Class.extend({
|
||||
}
|
||||
});
|
||||
|
||||
return action;
|
||||
},
|
||||
|
||||
customExportAction: function () {
|
||||
var action = L.EditAction.extend({
|
||||
initialize: function (map, overlay, options) {
|
||||
var use = 'get_app';
|
||||
|
||||
options = options || {};
|
||||
options.toolbarIcon = {
|
||||
svg: true,
|
||||
html: use,
|
||||
tooltip: 'Export Images'
|
||||
};
|
||||
|
||||
L.EditAction.prototype.initialize.call(this, map, overlay, options);
|
||||
},
|
||||
|
||||
addHooks: function () {
|
||||
var group = this._overlay;
|
||||
var edit = group.editing;
|
||||
var exportInterval;
|
||||
|
||||
var updateUI = function updateUI(data) {
|
||||
data = JSON.parse(data);
|
||||
console.log("in updateui: " + data);
|
||||
if (data.status == 'complete') clearInterval(exportInterval);
|
||||
if (data.status == 'complete' && data.jpg.match('.jpg')) alert("Export succeeded. http://export.mapknitter.org/" + data.jpg);
|
||||
}
|
||||
|
||||
var addUrlToModel = function addUrlToModel(data) {
|
||||
var statusUrl = "//export.mapknitter.org" + data;
|
||||
console.log("statusUrl: " + statusUrl);
|
||||
|
||||
// repeatedly fetch the status.json
|
||||
var updateInterval = function updateInterval() {
|
||||
exportInterval = setInterval(function intervalUpdater() {
|
||||
$.ajax(statusUrl + "?" + Date.now(), { // bust cache with timestamp;
|
||||
type: "GET",
|
||||
crossDomain: true
|
||||
}).done(function (data) {
|
||||
updateUI(data);
|
||||
});
|
||||
}, 3000);
|
||||
}
|
||||
/**
|
||||
* TODO: update API to say if you pass in a custom `handleStatusUrl` you must also build your own updater
|
||||
* and also create your own a frequency
|
||||
* or fix this part
|
||||
*/
|
||||
$.ajax({
|
||||
url: "/export",
|
||||
type: 'POST',
|
||||
data: { status_url: statusUrl }
|
||||
}).done(function (data) {
|
||||
console.log('success!! ' + data);
|
||||
updateInterval();
|
||||
});
|
||||
}
|
||||
|
||||
edit.startExport({ handleStatusUrl: addUrlToModel, updater: updateUI, scale: prompt("Choose a scale or use the default (cm per pixel):", 100) });
|
||||
}
|
||||
});
|
||||
|
||||
return action;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
"leaflet": "Leaflet/Leaflet#^1.0.0",
|
||||
"leaflet-dist": "vperron/leaflet-dist#0.7.x",
|
||||
"leaflet-draw": "Leaflet/Leaflet.draw#0.2.4",
|
||||
"leaflet-distortableimage": "0.7.7",
|
||||
"leaflet-distortableimage": "0.8.7",
|
||||
"leaflet-easybutton": "^2.4.0",
|
||||
"leaflet-environmental-layers": "^1.3.6",
|
||||
"leaflet-fullhash": "^1.0.0",
|
||||
|
||||
11
yarn.lock
11
yarn.lock
@@ -3095,7 +3095,7 @@ jquery-ujs@rails/jquery-ujs#~1.0.4:
|
||||
version "0.0.0"
|
||||
resolved "https://codeload.github.com/rails/jquery-ujs/tar.gz/7146dc96a71fda9b713f1f60fb414c699db0b3a7"
|
||||
|
||||
jquery@>=1.8, jquery@^3.2.1, jquery@^3.3.1:
|
||||
jquery@>=1.8, jquery@^3.2.1, jquery@^3.3.1, "jquery@~> 3.4.0":
|
||||
version "3.4.1"
|
||||
resolved "https://registry.yarnpkg.com/jquery/-/jquery-3.4.1.tgz#714f1f8d9dde4bdfa55764ba37ef214630d80ef2"
|
||||
integrity sha512-36+AdBzCL+y6qjw5Tx7HgzeGCzC81MDDgaUP8ld2zhx58HdqXGoBd+tHdrBMiyjGQs0Hxs/MLZTu/eHNJJuWPw==
|
||||
@@ -3236,13 +3236,14 @@ leaflet-dist@vperron/leaflet-dist#0.7.x:
|
||||
version "0.0.0"
|
||||
resolved "https://codeload.github.com/vperron/leaflet-dist/tar.gz/2ec7a0846eaecdce1321d92b3c45c74f4fd08dd3"
|
||||
|
||||
leaflet-distortableimage@0.7.7:
|
||||
version "0.7.7"
|
||||
resolved "https://registry.yarnpkg.com/leaflet-distortableimage/-/leaflet-distortableimage-0.7.7.tgz#72a8516aa31edb75fc6f5d9e7da41158fac44441"
|
||||
integrity sha512-ncLq9UR5n67jlEuzQnln7p9YaKww8fUWfkylCrujRFi4lktFsYlblhRGEB+7p7gmBsB503l/M8SxMmKNhlC8Rg==
|
||||
leaflet-distortableimage@0.8.7:
|
||||
version "0.8.7"
|
||||
resolved "https://registry.yarnpkg.com/leaflet-distortableimage/-/leaflet-distortableimage-0.8.7.tgz#d6cdaac6c54872416a124af604bdbbed3b37af91"
|
||||
integrity sha512-D643lX4V6HRVTWDroZVrm6IriWVJlpMINooMsxyTkFyNq/cPLj11pB0nayHIykENA8PqJNvzAB2WZc/uci3Kdg==
|
||||
dependencies:
|
||||
exif-js "^2.3.0"
|
||||
glfx "0.0.4"
|
||||
jquery "~> 3.4.0"
|
||||
leaflet-toolbar "0.4.0-alpha.2"
|
||||
webgl-distort "0.0.2"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user