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

save map coordinates in local storage #1225

Open
wants to merge 26 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
87f5076
detect key from longer URL
vanithaak Oct 16, 2022
f6225c3
Merge branch 'main' of https://github.com/vanithaak/Leaflet.Distortab…
vanithaak Oct 17, 2022
4976617
Merge branch 'publiclab:main' into main
vanithaak Oct 19, 2022
c71fc06
Merge branch 'publiclab:main' into main
vanithaak Oct 19, 2022
8db3a8e
Merge branch 'publiclab:main' into main
vanithaak Oct 19, 2022
1dca9e3
Merge branch 'publiclab:main' into main
vanithaak Oct 20, 2022
7cbcb80
fixes
vanithaak Oct 20, 2022
24df784
Merge branch 'main' of https://github.com/vanithaak/Leaflet.Distortab…
vanithaak Oct 20, 2022
47f1aa2
Merge branch 'publiclab:main' into main
vanithaak Oct 21, 2022
07c7e94
Merge branch 'publiclab:main' into main
vanithaak Oct 21, 2022
773c2fe
Merge branch 'publiclab:main' into main
vanithaak Oct 22, 2022
13c6402
Merge branch 'publiclab:main' into main
vanithaak Oct 23, 2022
67b2862
updates
vanithaak Oct 23, 2022
8407d0f
save map coordinates in local storage
vanithaak Oct 22, 2022
4a1339a
error fixes
vanithaak Oct 22, 2022
a03c45c
made a new method to save map in localStorage
vanithaak Oct 23, 2022
e409e69
error fixes
vanithaak Oct 23, 2022
415f0da
error fixes X2
vanithaak Oct 23, 2022
44d3a4b
error fixes X3
vanithaak Oct 23, 2022
f9e8212
Merge branch 'main' into localStorage
vanithaak Oct 25, 2022
eb09b9e
Merge branch 'main' into localStorage
vanithaak Oct 25, 2022
57613e6
removed overwriting of coordinates
vanithaak Oct 25, 2022
5f3e111
removed overwriting of coordinates
vanithaak Oct 25, 2022
a798be5
error fixes
vanithaak Oct 25, 2022
96dc9f1
Merge branch 'main' into localStorage
jywarren Oct 30, 2022
7cfe4be
Merge branch 'main' into localStorage
vanithaak Oct 31, 2022
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
11 changes: 11 additions & 0 deletions dist/leaflet.distortableimage.js

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

8 changes: 7 additions & 1 deletion src/DistortableCollection.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,11 +218,17 @@ L.DistortableCollection = L.FeatureGroup.extend({

json.images = json.images.reverse();
json.avg_cm_per_pixel = this._getAvgCmPerPixel(json.images);

var jsonImages = json.images;
savetoLocalStorage(jsonImages);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, this is looking like a good start, thank you! I wanted to suggest that you build on #1237, because it is almost the same! We'll want to make a function which runs each time there is an update to an image... it could even be each time there's a MouseUp, maybe? And it'll write a new "saved state" into localStorage, and similarly to #1237, not just the selected ones but all the images.

Shall we wait a little bit until #1237 is resolve then? Thanks!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually wait, cancel that. My mistake. I meant #1161 -- where we are working with the generateExportJson() function. Unfortunately I think there is some overlap between #1237 and #1161, and I'd like to ask you and @leilayesufu to try to work together on #1237 and to record a joint contribution. Would you both be willing to try that, since it's quite a complex one? If so, you can mark the PR as collaborative and work on it together.

Copy link
Contributor Author

@vanithaak vanithaak Nov 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, this is looking like a good start, thank you! I wanted to suggest that you build on #1237, because it is almost the same! We'll want to make a function which runs each time there is an update to an image... it could even be each time there's a MouseUp, maybe? And it'll write a new "saved state" into localStorage, and similarly to #1237, not just the selected ones but all the images.

Shall we wait a little bit until #1237 is resolve then? Thanks!

Hi Jeff, I'm little bit confused how to get started on this. Could you please drop some hints? Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Jeff, just a little hint, please

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @vanithaak -- so, I had realized that I was also working with @leilayesufu on a parallel track on parts of this, in #1161 -- and we had found that the problem was it only downloaded images that have been selected, so we needed to modify generateExportJson() to have a an onlySelected parameter defaulting to true, but so that we can override it if we want ALL images:

#1161 (comment)

Once this modification is made, we can use generateExportJson() for both downloading a JSON file, and storing the JSON file in localStorage. If you or @leilayesufu are interested in continuing to work on this, I think that's the key. It could even be done as its own PR -- and then we can begin using generateExportJson(false) to collect ALL images, for saving in localStorage OR for download. Does that make sense?

return json;
},
});

L.distortableCollection = function(id, options) {
return new L.DistortableCollection(id, options);
};

function savetoLocalStorage(jsonImages) {
var result = jsonImages.map(img => ({value: img.nodes}));
localStorage.setItem('locations', JSON.stringify(result));
}