-
Notifications
You must be signed in to change notification settings - Fork 0
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
Enable URL handling for selected layers #53
Comments
✅
This is going to be interesting, let us know if you find snakes. |
I agree, this will be useful and needed. Happy to help out. |
Nice! So, broadly, I think there's two pathways here for implementation:
I think the second approach should be doable - we'd probably need to think a little bit about how best to represent the URL parameters, and what all we might want to encode in the URL to be able to be shareable in the future. The tasks here would be roughly:
I'll poke around things a bit and see what it takes to get a basic proof of concept going. |
Don't say such things - next @marlonrodrigues will make a ticket to add a live map of all snakes in Goa 😂 |
Explicit Permalink button is how it's done for the Singapore Land Map site and works great. This feels like a natural workflow for a user. The urls however are not pretty, but maybe its on purpose?
👌 Let's start with just having |
I generally like having readable url values vs hashed ones. Like what @batpad suggested, https://amche.in?layers=gstm,abc,xyz&selectedItem=13#12.456/15.456/7 |
I have slightly complex thoughts on this - While this readable URL structure seems nice at first, I do think we are quickly going to run into more complex state that we will want to store in the URL. For example, I do think we will want to be able to store something like "sub-options" for layers, for things like the Opacity values, Terrain Exxageration, Choice of Data / Map, so that a URL can more exactly reproduce the state of the map the user is looking at / sharing. At that point, for convenience, I really want to just put JSON in the URL so like I think I actually really like what these ura.sg.gov folks seem to be doing with the URL like https://www.ura.gov.sg/maps/?link=N4IgDg9gliBcoBsCGAXOBGAdAZgOwA4AWXATgFZ1sKTCAGdXAGhAQDsBzDW7TE2s-AJIkq2WgCYSAX2YBnAKYIAygDcAxnBAARAKIA1ACoAlHQHEQzALZIwOgB4p5rNPBAB9WRACuKABYB1eVkXRFQMHDpJMgA2WlxCQXjxQmY2Tlh0bkx8fBJccXF8ZNoSaOj8GXdWCAAnPx0kYLhQlyxCTP4BMgTcWMl0VI4uHlLowrwSIoZSKUqAI0b5azA4AG1QKAATTTnLdAtwJFZ5AC0ASVZN+Ts4cXpmCDAkNSgUAE8uWhkN7dgQXfEByex3Ol2utwkDyeL3enykAF0Hip5DVkB9YOsQFtNBAEPggUdThcrjdYIRhFDnq90R0EVIgA. - it looks like just some sort of base64 encoding or so of the options (I couldn't quite figure out decoding it, but that's what it roughly seems like). I actually like this - it avoids a lot of silly URL encoding issues with having raw JSON in the URL, and looks slightly cleaner - and for complex state, I think the representation of the options is always going to be a bit opaque to the user in the URL. So I think my proposal would actually be to just represent all the map options as JSON, and then to save the state in the URL, just base64 encode the JSON string. I think the fundamental consideration is what all we want to store in the URL state. My argument would be that while it would okay to start with just the selected layers and maybe "selected item", which can be represented cleanly in the URL, the feature is incomplete without incorporating things like Opacity for each layer. My head hurts trying to think of how one would represent these kinds of layer options cleanly as query parameters - if it was just Opacity, one could probably come up with something, but there can be a different range of "sub options" for each layer, and we shouldn't have to make changes to the structure of the query parameters every time there's a new type of layer with new options, etc. It seems really convenient to just have a JSON representation of all these layer options that we can easily deserialize and re-create the map state from and then instead of having a convoluted mechanic to go from the JSON to a "clean" query parameter representation back to the JSON, to just encode the JSON itself in the URL. I love thinking through stuff like this :) - @pratapvardhan let me know if you have strong feelings either way - happy to chat a bit to try and make the "cleaner URLs" option work, but I think right now I'm leaning toward "base64 encoded JSON as a single query parameter", and if needed down the line consider a URL shortener integration. |
The most basic use case to preserve a camera view can be satisfied largely with just the Layer specific settings can be quite large in number and scope like opacity, raster-coloring options, override styling, feature state of the selected map object etc and its not yet clear what the universe of what we would need look like. We could then keep this ticket focused on adding |
@batpad Ah, they are using LZ-based compression on json object. URL you shared decodes to this.
|
@batpad agree with how you're thinking, don't have very strong opinions. If we really need readable URLs, I'd probably think of flattening the state like this, but may not be useable once we start having too many configuration options to store in state, perhaps? we'll also have to deal with ~2000 character limit and type coercion issues I suspect.
|
As I starting writing above message, I'm leaning towards "base64 encoded JSON as a single query parameter". I think, we should only do this if we decide to store whole set of configuration parameters in URL. But if we will expose only layers list, perhaps read-able URL would be more useful? |
I think we can just do both - start simple and add an extra query parameter for extra options as we need. I do want to try and make sure URLs continue to work, so ideally whatever we do now should be backwards compatible in the future. Shall we do:
How does that sound @planemad @pratapvardhan ? |
If I find it, you'll see it posted here :))) |
* slightly messy, first stab at constructing initially checked layers based on query parameters in url * Remove flash animation of layers on load --------- Co-authored-by: Arun Ganesh <[email protected]>
With #59, we are handling layers set in the URL state. @planemad next, we need some UI for users to be able to generate this permalink to be able to share. What it would roughly need to be:
|
@batpad I'm thinking, since we aren't adding a bas64 encoded value yet. Should we push the state to URL instead of adding a UI element? |
@pratapvardhan I think my main concern with pushing state to the URL is ensuring neat handling of things like back button behaviour. I think if we use I think if we use It was also not fully clear to me if there's a good way to add the URL update code to a single place in the code, or if we'd land up then having to add that to a bunch of different checkbox / click handlers in the code. Just generating the URL on clicking one "Permalink" button again seemed like a way to get around that problem. But I haven 't looked close enough to be sure if this is really a problem. However, if you feel good about pushing to the URL and feel like there's a reasonably clean path to that, that sounds good to me! |
I think so, yes! Sorry I'm probably going to have limited time until early Jan, so if you want to take a stab at this, please go ahead :) |
Currently, you can share a URL with the position of the map, but you cannot share a URL state that will have the same selected layers, etc. show up for the user opening the URL.
We should be able to encode the entire map state into the URL so we can share URLs that have all the selected layers, and ideally, as well selected locations w/ popups open, etc. to make it easier to share links for specific locations, and specific layer combinations.
This would allow us to craft more precise stories and highlight particular things by sharing the map state more precisely in the URL.
I think this is pretty important to do as the list of data layer grows - it does not help to send someone a link to look at something and then have to tell them to click a hamburger menu and select particular layers - one should be able to select the relevant layers and generate a URL to share.
This is going to be a bit tricky to implement - @planemad @pratapvardhan, I could sketch something out, but this would probably need some thoughtful refactoring of the code to make manageable. Let me know if this seems worth spending time on, and then I can give this some thought and sketch something out.
The text was updated successfully, but these errors were encountered: