-
Notifications
You must be signed in to change notification settings - Fork 77
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
[wip] Replace permalink/Share URL feature with automatic URL rewriting on change. #74
Conversation
Thanks for working on this.
It's a tricky task, and unless I missed something, there are some issues (see first post) |
Thanks for these comments! Again I am not a JS developer so I am still learning a lot about best practices and such :). |
For reference, see Extending Leaflet tutorial and other examples in |
|
Indeed @nrenner, it looks tricky - would you mind helping on this actually? |
8216ddb
to
cc5da47
Compare
Regarding old style URL support, would you mind taking at look at it (eg. am I doing it a correct way? Is there a more "standard" way of doing it?). |
Instead of a |
Will have a look at it tomorrow. |
Regarding extending leaflet-fullHash I needed to test it myself, so I made two examples: Some resources:
Let me know if that helps. |
Looks OK to me for our use case, don't know if there is a best practice or standard way. |
Hm, I know this is handy with Maybe we can use URLSearchParams - we have the polyfill already included - like I did in the marker test for more parsing convenience? |
@nrenner Only item left is extending upstream leaflet-fullHash. I reduced to the minimal number of required modifications, but I feel like it won't be super great to extend it anyway:
So we'll end up with a copy/paste of 2 functions - do you think it's still better to extend it? If you think it's worth it, I'll do it but with my current (poor) experience I don't see any benefit of doing so. Again, just asking and I appreciate your feedbacks! |
Not sure what to say here. Better than copy/pasting the whole thing? I guess for me it's about organizing the project in a certain way and to stick with it. And the current structure is:
This has the benefit that for all external code (with some limitations):
Of course there will be no updates if the author is happy with it and everyone else just copies and modifies it in their code ;-) Looking at the open PRs of the original leaflet-hash, there sure are people who wish for improvements and have shared theirs. Ideally, the solution to both bad options of modifying a file copy or extending and copying functions, would be to fix the original leaflet-fullHash code and make it extendable, either by creating issues or pull requests. But I leave it up to you if you want to make this extra effort. So I'm merging this now as is and create a separate reminder to sort this out later. |
So as talked earlier, here is a PR hopefully doing things the rightway :).
I removed "Permalink" button and Share URL menu, instead the URL of the window automatically updates on map changes (and reciprocally). Now URLs look like:
http://HOST/brouter-web/#map=16/43.6404/3.8691/OpenStreetMap/brouter?lonlats=3.869483,43.640594|3.865385,43.640858&nogos=3.867778,43.641107,180&profile=trekking
If you don't like/think it's unnecessary the part
#map=zoom/x/y
, I believe we could remove it and instead center the map on… the first point oflonlats
? Compute a boundingbox of it? Something else?Also, I fixed a tiny issue with circles drawing that were 10px radius due to Leaflet 1.x migration.
By the way this will break old links - but if it's mandatory I think we can handle that.
Testing/Reviews're welcome!
TODO list:
It seems all layers - including vector layers - get removed by fullHash on update, probably a bug.
I guess the idea is to have a separate layer list (including overlays) with keys instead of names, see the demo
/brouter?
in the URL, that's for the server call, replace with a simple&
?leaflet-fullHash.js
code injs/plugin/
should ideally be an external dependency in bower, and any modifications made by extending the original class.