publiclab / Leaflet.DistortableImage

A Leaflet extension to distort or "rubber sheet" images
https://publiclab.github.io/Leaflet.DistortableImage/examples/
BSD 2-Clause "Simplified" License
273 stars 285 forks source link

Download json file of saved positions #1237

Closed vanithaak closed 1 year ago

vanithaak commented 2 years ago

Fixes #998 (<=== Add issue number here)

Make sure these boxes are checked before your pull request (PR) is ready to be reviewed and merged. Thanks!

We're happy to help you get this ready -- don't be afraid to ask for help, and don't be discouraged if your tests fail at first!

If tests do fail, click on the red X to learn why by reading the logs.

Please be sure you've reviewed our contribution guidelines at https://publiclab.org/contributing-to-public-lab-software

Thanks!

GIF

https://user-images.githubusercontent.com/59090053/197871579-8e525d12-dfcb-44c7-ad98-5a0789fa63b0.mp4

Screenshot

image
gitpod-io[bot] commented 2 years ago

vanithaak commented 2 years ago

@jywarren, please review my pr! For now I'm trying to make the downloaded file more readable.

vanithaak commented 2 years ago

hi @jywarren , I was trying to make the JSON pretty, with JSON.stringify( obj, undefined, "\t")(Also, tried null instead of undefined). Usually this works but it's not showing any tabs in downloaded file, rather it's showing "\t" . Is their anything else I can try?

jywarren commented 1 year ago

OK, resuming here, we want to add a default generateExportJson(allImages = false) { parameter, and a conditional (referencing this conversation: https://github.com/publiclab/Leaflet.DistortableImage/pull/1161#issuecomment-1284089852):

     if (allImages || this.isCollected(layer)) {

https://github.com/publiclab/Leaflet.DistortableImage/blob/c80a7c69904694bdd50ca0f9e6e358abbdfb98af/src/DistortableCollection.js#L192-L197

jywarren commented 1 year ago

Referencing this function could work like:

document.getElementById('export').onclick = function() { map.imgGroup.generateExportJson(true); }
7malikk commented 1 year ago

Hello @jywarren, I've been able to integrate the downloadJSON trigger in the Export Images button Kindly review and let me know what you think.

UI Changes

downloadJSON

7malikk commented 1 year ago

Hello @jywarren, per our discussion here are the changes Let me know what you think, thank you!

UI Changes

downloadJSON-two