-
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
Implement new menu in one liner code #353
Implement new menu in one liner code #353
Conversation
Things done:
Things to do:
|
This is great. Do you mean things to do in a future PR and this one is
ready? Or still a work in progress? Thank you!!!
…On Fri, Jan 17, 2020 at 12:01 PM Renisha Christie. A < ***@***.***> wrote:
Things done:
- Implemented new menu in one liner code
- Add new menu dependancies to one-liner code example files
- Fix styles from overriding default leaflet styles
Things to do:
- Fix error from layer when refreshing map view when the layer is out
of bounds(when using include)
- Add option to use default layer control when needed
- Add option to display all layers when map is initialized
- Add documentation
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#353?email_source=notifications&email_token=AAAF6JZZTYF4OOE5FCM2O2LQ6HP5PA5CNFSM4KILFZY2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEJIKK5I#issuecomment-575710581>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAF6JYG2LL3ITXQLXOIALTQ6HP5PANCNFSM4KILFZYQ>
.
|
This is still a work in progress. Things to do are what's left to do in this PR. I shall make sure to mention when the PR is ready. Thanks! |
ok, looks awesome, and keep up the great work!
…On Fri, Jan 17, 2020 at 2:12 PM Renisha Christie. A < ***@***.***> wrote:
This is still a work in progress. Things to do are what's left to do in
this PR. I shall make sure to mention when the PR is ready. Thanks!
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#353?email_source=notifications&email_token=AAAF6J46BSKDEZI2DCPIACDQ6H6W3A5CNFSM4KILFZY2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEJIVLFI#issuecomment-575755669>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAF6J62WD4JOUQF2IMPCADQ6H6W3ANCNFSM4KILFZYQ>
.
|
src/AllLayers.js
Outdated
var baseMaps = this.options.baseLayers ? this.options.baseLayers : { "Grey-scale": this.options.defaultBaseLayer.addTo(map) }; | ||
|
||
for (let layer of this.options.layers.include) { | ||
if (this.options.layers0.includes(layer)) { | ||
this.overlayMaps[layer] = window['L']['layerGroup'][layer](); | ||
if (layer === 'purpleLayer' && !this.groupedOverlayMaps.PurpleAir) { |
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 this is getting messy, can we use switch case instead?
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.
Sure, will do.
example/styles.css
Outdated
overflow-y: hidden; | ||
} | ||
|
||
.leaflet-control-layers-overlays { | ||
.leaflet-control-layers-menu .leaflet-control-layers-overlays { |
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 will need this CSS as well in plots2, right?
Also we need to make sure that we use different CSS for different custom bars. 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 will need this CSS as well in plots2, right?
Thanks for mentioning this. I had assumed it would be bundled into dist. I think it is safe to move the styles to LeafletEnvironmentalLayers.css
in /dist. What do you think?
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.
Also we need to make sure that we use different CSS for different custom bars.
Yes, you are right. That is why I had added .leaflet-control-layers-menu
which is a custom class so that it does not override leaflet's default .leaflet-control-layers-overlays
.
@@ -129,7 +178,8 @@ L.LayerGroup.environmentalLayers = L.LayerGroup.extend( | |||
) : L.control.embed().addTo(map); | |||
} | |||
|
|||
L.control.layers(baseMaps, this.overlayMaps).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.
Let's just add if option has param to show default, use this line else use the below layerbrowser line.
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.
Working on this.
PR ready for review. The implementation can be checked at https://crisner.github.io/leaflet-environmental-layers/example/oneLinerCodeExample.html |
Dependencies: | ||
``` | ||
<!-- Bootstrap --> | ||
<link rel="stylesheet" href="../node_modules\bootstrap\dist\css\bootstrap.min.css"> |
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.
@sagarpreet-chadha, this just occurred to me. To add these dependencies shouldn't I point it to LEL's node modules? So here, shouldn't I be writing "leaflet-environmental-layers/node_modules" instead to make sense? It wouldn't work otherwise unless the destination repo had bootstrap installed, right?
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.
Found that only LBL was in the node_modules folder in LEL when installing as a package. I was of the impression that all dependencies of a package would be included in the node_modules of that package. So I am assuming we should explicitly mention in the documentation that bootstrap needs to be installed? The new menu needs bootstrap load correctly.
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.
Yes let's do that!
Dependencies: | ||
``` | ||
<!-- Bootstrap --> | ||
<link rel="stylesheet" href="../node_modules\bootstrap\dist\css\bootstrap.min.css"> |
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.
Yes let's do that!
@@ -42,6 +47,11 @@ | |||
<script src="../lib/glify.js"></script> | |||
|
|||
<script src="../lib/leaflet-fullUrlHash.js"></script> | |||
|
|||
<script src="../node_modules/leaflet-google-places-autocomplete/src/js/leaflet-gplaces-autocomplete.js"></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.
We have documented this also?
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 don't think so. This needs to be added too.
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.
Added to readme.md
src/AllLayers.js
Outdated
@@ -46,7 +47,7 @@ L.LayerGroup.environmentalLayers = L.LayerGroup.extend( | |||
this.options.baseLayers = param.baseLayers; | |||
} | |||
if (!!param.include) { | |||
this.options.addLayersToMap = true; | |||
this.options.addLayersToMap = param.addLayersToMap === false ? false : true; |
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.
this.options.addLayersToMap = param.addLayersToMap === false ? false : true; | |
this.options.addLayersToMap = param.addLayersToMap; |
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.
Done. To display layers by default on inline maps in plots2 we'll need to add addLayersToMap: true
to the LEL initialization.
if (isPageRefreshed < 2 && window.performance.navigation.type !== 1) { | ||
isPageRefreshed++; // Track page moveend events to prevent errors on map.removeLayer when a page is reloaded | ||
} | ||
if(isPageRefreshed > 1) { | ||
self._hideElements(obj, data, layerName, elements, true); | ||
} |
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.
What these lines do?
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 new layer menu removes the map on 'moveend' event if the layer is displayed on the map but is out of bounds. The 'moveend' event was being triggered on page refresh causing the error on the unearthing layer where it couldn't find the layer to remove from the map.
This was weird because that line of code would only run if map.hasLayer()
returned true. And also I could see the layer displayed on the map and could access it on the console. So I set this up to avoid running that code if it is the first 'moveend' event after a page refresh.
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.
Ah okay
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 it is good to go now :) Thanks!
Awesome!!! |
Fixes #347 (<=== 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!