-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Map layer permalinks get overwritten on page open #6889
Map layer permalinks get overwritten on page open #6889
Comments
I checked this out and looked over the code. But I can't seem to reproduce the behaviour in my local environment so that I could locate the code causing the issue. @IshaGupta18, would you be able to guide me on how to go about this? |
Hey @crisner , The reason is the leaflet-hash library in LEL. We need to store the 'hash' variable somewhere such that it does not get re-initialize. |
Thanks for the reply @sagarpreet-chadha. I managed to figure out that I need to store the hash so it does not change but I had trouble figuring out where to do it. It has become harder as I couldn't replicate the behaviour in my local environment which means I can't confirm if I am working on the right file. Not sure if I am missing something. I'll try to look at it again tomorrow. |
Ah, I am not sure if I just misunderstood your reply. Did you mean the problem lies in the LEL repo? Anyway shall take a look at it again. |
I'm not 100% sure but I think that may be correct -- in the LEL codebase?
…On Tue, Dec 3, 2019 at 11:44 AM Renisha Christie. A < ***@***.***> wrote:
Ah, I am not sure if I just misunderstood your reply. Did you mean the
problem lies in the LEL repo?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#6889?email_source=notifications&email_token=AAAF6JYTNGDINHC7QOON6ETQW2EEJA5CNFSM4JUCWTC2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEF2AWMY#issuecomment-561253171>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAF6JYLU6GPGNRUNIMVUXDQW2EEJANCNFSM4JUCWTCQ>
.
|
When I open the link(https://publiclab.org/maps#3/41.00/-71.00/pfasLayer) elsewhere the coordinates in the URL also changes. It overwrites to https://publiclab.org/maps#2/15.0/2.8/. As @sagarpreet-chadha mentioned the problem lies with the leaflet-hash library in LEL, specifically how the hash instance is saved in the environmental layers LayerGroup. Please correct me if I am wrong. I am stuck at the moment trying to prevent the hash from getting reinitialized. Tried to save the hash globally as well but I think the trick is to have it initialized after the map instance? Trying to figure out how to get that done. |
Hey, yes you understand the issue correctly. The bug is in LEL. |
Thanks for the tip Sagarpreet and thanks for working on this @crisner. It
seems a subtle bug! Sagarpreet, you're saying maybe initialize the variable
before the library is loaded, to try to force a broader scope?
I wonder if we could add some kind of detection in the constructor function
of LEL to first check if there is a hash existing? Would you be able to
point us at the right area of the code to do something like that,
Sagarpreet?
Thanks, all!
…On Thu, Dec 5, 2019 at 1:40 PM Sagarpreet Chadha ***@***.***> wrote:
Hey, yes you understand the issue correctly. The bug is in LEL.
One way to solve this be to initialize the hash variable outside library
in .html example file. We need to pass the object of layers to hash
function. This object should be returned/exposed from the library. Makes
sense? Thanks!
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#6889?email_source=notifications&email_token=AAAF6J2SXBVASH2SDOOK3YLQXFDHNA5CNFSM4JUCWTC2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEGBWJUY#issuecomment-562259155>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAF6JYCNMS4Y4VAIXIJZVTQXFDHNANCNFSM4JUCWTCQ>
.
|
Just wanted to bring it to attention that the following lines outputs an error and does not let the layer control render on the map when I run plots2 locally. This is because the omsUtil function is not available outside of LEL. I came across this when I was trying to fix this issue #6889. plots2/app/assets/javascripts/leaflet_helper.js Lines 100 to 103 in 3c4dfc5
|
I will need to debug the error a bit more to be sure. |
I apologize for the confusion. Looks the LEL copy in my plots2 copy didn't have the omsUtil defined. 😅 |
part of #6801 -
Leaflet Environmental Layers has a great feature which appends the displayed layers to the URL hash; so, if you enable the "pfasLayer" layer while on https://publiclab.org/maps, the URL will look like this:
https://publiclab.org/maps#3/41.00/-71.00/pfasLayer
Note that it also includes the latitude/longitude.
However, if you copy that link and open it somewhere else, that's not preserved; it overwrites with just the lat/lon/zoom:
https://publiclab.org/maps#3/41.00/-71.00/
We should, instead, see that page with the corresponding layers already enabled:
We'd love help with this! Maybe @crisner would be interested? Also cc'ing @nstjean and @sagarpreet-chadha as this is a tiny part of the overall Outreachy/Geographic features projects you're both working on!
The text was updated successfully, but these errors were encountered: