-
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 popups not working #7281
Comments
The popups seem to be working on the /map page and the map embedded in the sidebar(like here https://publiclab.org/wiki/unearthing-pvd). It doesn't seem to work on inline maps or the people page. I checked this locally after bumping LEL and it seems to work when using inline maps on a post but I am getting the same error for the map in people page.
We will need to look into why the popup is having these issues when executing maps in people page as it seems to be working on other pages. Perhaps we need to compare the code for setting up in LEL in each of these pages? |
So, I managed to see the popup in the people page when I commented out lines 128 to130 and L132 without any errors. plots2/app/views/map/_peopleLeaflet.html.erb Lines 128 to 132 in b80f193
I thought it was working in the inline maps here but it turned out only this marker was working and I got the same error on every other marker. The dom has the popup elements in the popup pane when we click on the markers but they seem to have no content causing the error. Could this be because the requests from the layers are not being completed? It seems weird as it works on the /map page and the small maps embedded on the side as shown here: If the popup content is being loaded with @sagarpreet-chadha's fix, then we could try to extend leaflet's popup, make the fix there and use it until we figure it out. We may have to replace all the reference to L.popup to our custom one. |
That seems so strange that it would work in one map but not the other. Thanks for doing all this research! |
Thank you so much for the research.
So let's try out @sagarpreet-chadha's fix? Agreed that we can fix this way. Has anyone had a chance to look this up on the Leaflet repo? I can if you can describe the issue in once sentence so I can properly relay it over! |
Tracking this: Popups work:
Popups not working: |
setContent usages:
appendChild used: https://github.com/publiclab/leaflet-environmental-layers/search?q=appendChild&unscoped_q=appendChild |
Goals:
|
Ah, and also, to see if upstream Leaflet is tracking any related issue, it seems not, but here is my search: https://github.com/Leaflet/Leaflet/search?q=setContent+popup&type=Issues |
To my last comment, I searched a bit more, and Leaflet specifies only HTML as the parameter: https://leafletjs.com/reference-1.4.0.html#popup-setcontent I think we need to find where we're passing in That would be somewhere in this JS file, i think? plots2/app/assets/javascripts/leaflet_helper.js Lines 25 to 51 in 23e83cd
|
Also, i've tried to put a range of good example maps on this page and ensure that stable/production are both showing the same content: |
So it looks like only the last map on the page has working popups. This is when I click on a marker on the top map: This is when I click on a marker on the bottom map: They are exactly the same code, exactly the same template _inlineLeaflet.html.erb. The same thing happens with _peopleLeaflet.html.erb and _plainInlineLeaflet.html.erb I'm going to do some digging to figure out what isn't working correctly when we have multiple maps being called. |
If I put multiple maps in the same template (with unique variable names) they work. The exact same code pasted into separate templates is throwing the error. I think it might be because of the separate ruby function calls here? plots2/app/models/concerns/node_shared.rb Lines 356 to 372 in aa3b864
I'm going to keep experimenting. |
Great observation! Thanks @nstjean !! |
Great catch @nstjean! 🎉 🚀 🚀 |
@crisner I thought so too but changing them didn't make a difference! |
Just posting this link on a similar issue here as a note:
I'll edit this comment to add other similar issues that I find as a reference here. |
@nstjean, when you are looking into this issue I think it would be better to pass in the baselayer as done here: plots2/app/views/map/map.html.erb Lines 103 to 106 in aa3b864
in the functions here: plots2/app/assets/javascripts/leaflet_helper.js Lines 94 to 107 in aa3b864
and here: plots2/app/assets/javascripts/leaflet_helper.js Lines 143 to 155 in aa3b864
The problem didn't go away after I changed this on my machine but giving you a head's up just in case. |
Also, here are couple of issues I found that could be related. |
I figured it out! We can't have the map dependencies included for every single map:
I see the same issue happen if there's a map in the sidebar, which also loads the dependencies and breaks the marker popups. I think the reason they were only on map pages was because we didn't want to load everything for non-map pages, but I feel like it's better to put it in the header somewhere? @jywarren what do you think? |
This is awesome @nstjean! 🎉 🎉 🎉 Amazing work!! 🚀 🚀 🚀 |
Awesome!!!!! 🎉 🎉 🎉 🎉 So glad you found this! This really seems correct. Let's try it out! Fantastic! 💥 |
@sagarpreet-chadha reported this, we need to collect more information on it.
(original post)
My response:
Possibilities:
What do folks think? Let's dig a bit on the Leaflet project to see what's up?
The text was updated successfully, but these errors were encountered: