-
Notifications
You must be signed in to change notification settings - Fork 207
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
Insert custom updater function into Leaflet.DistortableImage for displaying export status #756
Comments
We'll have to bump an LDI version to get this code onto MapKnitter, though! |
Or would it be code like this, where we'd pass in the function for a customized updater? |
_removeOverlay: function () {
var overlay = this._overlay,
eventParents = overlay._eventParents;
if (this._mode === "lock") { return; }
var choice = this.confirmDelete();
if (!choice) { return; }
this._hideToolbar();
if (eventParents) {
var eP = eventParents[Object.keys(eventParents)[0]];
eP.removeLayer(overlay);
} else {
overlay._map.removeLayer(overlay);
}
}, |
So ok - let's aim to have the updater function passed into each image as a constructor option, and when you have a collection selected, a new button for |
OK, so new plan:
|
OK - so, first, we'll need to create a DistortableCollection in our MapKnitter code, which I believe we do at this line: But @sashadev-sky - why do we add images to it from the HTML file? Aren't we going to be adding them dynamically, by selecting them? In any case, we have several functions we can pass in as overrides: imgGroup = L.distortableCollection({
actions: [Exports],
updater: function updater(data) {},
scale: 100, // optional cm per pixel scale, defaults to 100
frequency: 3000, // optional frequency to request status, defaults to 3000ms, or 3 seconds
}).addTo(map); And for this function updater(data) {
// here we can display data.jpg, data.tif, data.status, data.tms, and data.zip, as they become available
console.log(data);
// this code segment doesn't work, actually:
if (data.hasOwnProperty('status_url') && statusUrl !== data.status_url && data.status_url.match('.json')) { statusUrl = data.status_url; } if (data.status === "complete") {
clearInterval(updateInterval);
}
} Code reference: In terms of how we display it, let's just get it running first, and then we can decide to insert https://getbootstrap.com/docs/4.3/components/modal/#modal-components Let's keep it simple for now, and just display the export status and exports as Badges: https://getbootstrap.com/docs/4.3/components/badge/ Sound good? (cc @divyabaid16 because we're going to start thinking about how we reconcile this system with the multiple image select and export system you're working on in parallel! We should be able to construct a similar |
And linking to @divyabaid16's work in #693 |
@divyabaid16 this is part of the ongoing process of moving all exporting work off or the MapKnitter application. Your interface work will interface with the new cloud export service in almost the same way as Sasha's! |
@jywarren we add them in the HTML file because its a demo! We can add them anytime. In regard to this: imgGroup = L.distortableCollection({
actions: [Exports],
updater: function updater(data) {},
scale: 100, // optional cm per pixel scale, defaults to 100
frequency: 3000, // optional frequency to request status, defaults to 3000ms, or 3 seconds
}).addTo(map); I haven't exposed the Exports actions yet so that we can manipulate what we pass to it. I am thinking about how to do that. It seemed unnecessary to make each action its own class. I was thinking maybe just an exports class? Definitely a decision to discuss what would make most sense, but that is why I held off on documentation exporting for now. But I was thinking for now setup would be: imgGroup = L.distortableCollection({
actions: [<insert-custom-action-here>],
}).addTo(map); And we would just rewrite the exports action? And when we're rewriting it well be able to access it and pass whatever. |
@divyabaid16 let me know if you need to walk through the custom collection passing! |
Starting now. The new MK front page looks so good |
@jywarren if you don't like the idea of reewriting I can go back and expose Exports however would make most sense (see first commnt above) I was imagining once it would be exposed it would be passed something more like: updater = function updater(data) {};
exportCustom = L.export(updater);
imgGroup = L.distortableCollection({
actions: [ExportCustom],
}).addTo(map); |
This is fine for now! |
mapknitter/app/assets/javascripts/mapknitter/Map.js
Lines 102 to 108 in 5f59c7e
This will build on publiclab/Leaflet.DistortableImage#310 by @sashadev-sky !
This is initialized here too, for images added later:
mapknitter/app/assets/javascripts/mapknitter/Map.js
Lines 165 to 170 in 5f59c7e
The text was updated successfully, but these errors were encountered: