-
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]Embed feature in demo page #296
Conversation
I have added the embed feature only to the layers.js file as it was specifically for the demo page. Should this be implemented in AllLayers.js as well? Also, when I was referring to the embed feature implemented in plots2 I noticed that the URL has query strings. Should that be implemented here as well? |
Should the embed button follow the style guide and have a bootstrap styled button or should it be similar to the zoom controls in the map? |
Embed code in use at the bottom of the page --> https://codepen.io/crisren/full/abzdJPV |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/util/embedControl.js
Outdated
|
||
generateCode: function() { | ||
var params = this.getUrlHashParameters(); | ||
var code = '<iframe style="border:none;" width="100%" height="900px" src="//publiclab.github.io/leaflet-environmental-layers/example/#' + params.zoom + '/' + params.lat + '/' + params.lng + '/' + params.layers +'"></iframe>'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @crisner ,
Instead of this URL, let's use the one i created in PL:
https://publiclab.org/map/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried loading the mentioned URL but I am getting a 404 page.
return code; | ||
}, | ||
|
||
onRemove: function(map) {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you verify if on calling remove function, the button gets removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't implement a remove function thinking there wasn't a need for it. I shall check it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The button gets removed using removeControl(control)
on the map object. It looks like the onRemove
method works as expected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay cool! You never know what use-case the user may need :)
@@ -232,6 +232,8 @@ | |||
var hash = new L.Hash(map, allMapLayers); | |||
var leafletControl = new L.control.layers(baseMaps,overlayMaps); | |||
leafletControl.addTo(map); | |||
|
|||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AWESOME!!!
Let's add this to all HTML demo files :)
example/index.html
Outdated
@@ -38,6 +38,8 @@ | |||
<script src="https://cdnjs.cloudflare.com/ajax/libs/OverlappingMarkerSpiderfier-Leaflet/0.2.6/oms.min.js"></script> | |||
|
|||
<script src="lib/glify.js"></script> | |||
|
|||
<script src="https://kit.fontawesome.com/92fa0312fd.js" crossorigin="anonymous"></script> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we download this font-awesome file and add that to LEL repo in /images folder so that the button image is there even if we are offline?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And then remove this script also. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could include it using NPM and then it'd be in node_modules
?
Regarding the styling, i guess it might work best as a native Leaflet styled button, like the full screen buttons on https://publiclab.org/wiki/unearthing-pvd for example. Once you try it out can you share a screenshot? Thank you! Looking awesome! |
Thank you for the feedback @sagarpreet-chadha and @jywarren! I shall make the changes as suggested. |
@jywarren, here's the screenshot of the embed button I have now. What do you think? |
Oh that's beautiful! Great job!
I was thinking that, in the online gh-pages demo, we may want a page that
explicitly says something like "Pan & zoom the map below and select layers
to display, then use the `</>` button to generate an embed code you can use
on your own website." -- this could just be a strip of text at the top, you
know? That way the gh-pages demo is a utility as well as a demo.
Later, we could actually offer a choice of embed types - HTML <iframe> or
plots2 shortcode ([map:______] style) on this example page. What do you
think?
…On Tue, Dec 10, 2019 at 8:40 AM Renisha Christie. A < ***@***.***> wrote:
@jywarren <https://github.com/jywarren>, here's the screenshot of the
embed button I have now. What do you think?
[image: 127 0 0 1_5500_example_index html (2)]
<https://user-images.githubusercontent.com/29401459/70534117-61df2800-1b80-11ea-9aad-5387a7c00108.png>
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#296?email_source=notifications&email_token=AAAF6J4EDMYCACKJZCXFNYDQX6L3JA5CNFSM4JYHWOY2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEGPIGFA#issuecomment-564036372>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAF6J3X7M6PBFRYCOV4SCDQX6L3JANCNFSM4JYHWOYQ>
.
|
This is what I have so far:
Issues I am facing:
|
This sounds great. Could we split out the domain name as a settable option
defaulting to the gh-pages
https://publiclab.github.io/leaflet-environmental-layers/ but overridable
when LEL is initialized with something like options.hostname or
options.root_url ? I guess it's more complicated than that but maybe it's
worth spinning out a new issue to follow-up on this idea. Sorry to throw
more and more into this PR! We can focus on solving a narrower task here
and defer any extra stuff for a separate issue/PR; that's a best practice
anyways!
Thanks!!
…On Tue, Dec 10, 2019 at 11:06 AM Renisha Christie. A < ***@***.***> wrote:
This is what I have so far:
- Assuming the URL needed to be formatted as:
http://localhost:3000/map/Unearthing,eonetFiresLayer,odorreport,asian#lat=30.600093873550072&lon=52.03125&zoom=3
I tried to implement the hash but with the formatted code by modifying
the fullHash library. -> https://github.com/crisner/leaflet-fullUrlHash.
I have the following format now:
http://127.0.0.1:5500/example/index.html#lat=43.00&lon=-83.00&zoom=3&layers=BL1
- Added fontawesome to node modules
- Added native leaflet style to embed icon
Issues I am facing:
- When I click on the prompt buttons, generated more than once after
loading the page, for some reason the location hash gets reset. I will be
looking into this tomorrow.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#296?email_source=notifications&email_token=AAAF6J24CUGB2U3PFRLPRKLQX64OZA5CNFSM4JYHWOY2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEGPYLOY#issuecomment-564102587>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAF6J63UQY4VSPTYKWXQRDQX64OZANCNFSM4JYHWOYQ>
.
|
Thanks, @jywarren! I like the idea of spinning it out as a new issue. That way it is easier for me to focus. |
Super!
…On Tue, Dec 10, 2019, 11:25 AM Renisha Christie. A ***@***.***> wrote:
Thanks, @jywarren <https://github.com/jywarren>! I like the idea of
spinning it out as a new issue. That way it is easier for me to focus.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#296?email_source=notifications&email_token=AAAF6J3BR57T4QSDAIC5T5DQX67HTA5CNFSM4JYHWOY2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEGP3CUI#issuecomment-564113745>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAF6J7QCGNFE2NJI3APG4LQX67HTANCNFSM4JYHWOYQ>
.
|
|
Looking forward to your feedback on the changes @sagarpreet-chadha. :) I would also like your feedback on a couple of issues I have mentioned in my previous comment. |
Should I also commit the package-lock.json file? |
Just quickly, yes please do commit it, as it often includes updates or adjustments. We can pull it out if there's anything too weird in there :-) Do you know how to test by setting up your own gh-pages branch? This is a good way to check that it'll work the same way without needing to first overwrite the publiclab gh-pages. But you do need to keep a separate branch with gh-pages with your node_modules all added, and commit and push them only to your own gh-pages branch. This gets a little complicated, but it's great for showing off a new version so it can be tested out before being merged! |
Awesome work so far!!! |
I have set up gh-pages before. But it has been a while. I'll give it a go and update my progress here. |
Awesome!!!
…On Wed, Dec 11, 2019 at 10:26 PM Renisha Christie. A < ***@***.***> wrote:
I have set up gh-pages before. But it has been a while. I'll give it a go
and update my progress here.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#296?email_source=notifications&email_token=ADSCRRJFWYC4O2YIBMGY6U3QYELVJA5CNFSM4JYHWOY2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEGT2XMA#issuecomment-564636592>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADSCRRKSI7GJKJJCQIU3GOLQYELVJANCNFSM4JYHWOYQ>
.
|
It was harder than I expected to figure things out but I have managed to set up a working gh-pages from a 'development' branch on my forked repo. Screenshot for index.html:
Screenshot for oneLinerCodeExample.html:
Screenshot for unearthing-pvd.html:
|
I am also getting the following warning from GitHub in my mail,
|
The active baselayer appears unselected in the map's layer control which affects the url hash as well. I started another branch from the changes in this PR as the base and created issue #299 and linked PR #300 to it. Please let me know if this is not the right way to go about adding more changes in a separate PR. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just a small change and this looks good!!!
@@ -121,15 +121,18 @@ L.LayerGroup.environmentalLayers = L.LayerGroup.extend( | |||
} | |||
|
|||
if(this.options.embed) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redundant code?
return code; | ||
}, | ||
|
||
onRemove: function(map) {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay cool! You never know what use-case the user may need :)
var HAS_HASHCHANGE = (function() { | ||
var doc_mode = window.documentMode; | ||
return ('onhashchange' in window) && | ||
(doc_mode === undefined || doc_mode > 7); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to add this to a separate folder outside example. Let's make one lib folder at the root level and change the script tag above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should I move the whole lib folder to the root or just the fullUrlHash.js file?
Continued to #300 (review) |
Yes the whole lib folder, but we should make note that we will have to change script src for glify.js in plots2 then. Thanks! |
Fixes #252 (<=== Add issue number here)
Make sure these boxes are checked before your pull request (PR) is ready to be reviewed and merged. Thanks!
@publiclab/reviewers
for help, in a comment belowIf tests do fail, click on the red
X
to learn why by reading the logs.Please be sure you've reviewed our contribution guidelines at https://publiclab.org/contributing-to-public-lab-software
Thanks!