Skip to content
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

Add display parameter to show specific layers #378

Merged
merged 3 commits into from
Feb 1, 2020

Conversation

nstjean
Copy link
Contributor

@nstjean nstjean commented Jan 31, 2020

Fixes #377 (<=== Add issue number here)

There are cases in plots2 where we can't use a url hash to enable layers to be displayed. This param is optional and defaults to no layers being displayed on page load.
include: ['layername'] will still limit what maps are available in the menu
display: ['layername'] will turn on the specified layers, if they are available
addLayersToMap: true will override and display all layers that are available, regardless of what is in display

Selection_041
FireShot Capture 268 - Leaflet Environmental Layers -

Selection_042
FireShot Capture 269 - Leaflet Environmental Layers -

Selection_043
FireShot Capture 270 - Leaflet Environmental Layers -

Selection_045
Leaflet Environmental Layers - Google Chrome_044

@nstjean nstjean requested a review from crisner January 31, 2020 17:37
@nstjean
Copy link
Contributor Author

nstjean commented Jan 31, 2020

currentHash: location.hash,
addLayersToMap: false,
addLayersToMap: false, // activates layers on map by default if true.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for catching this! 😃


if (!!this.options.addLayersToMap) { // turn on all layers
for (let layer of this.options.layers.include) {
map.addLayer(this.overlayMaps[layer]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome refactor!

for (let layer of this.options.layers.display) {
// make sure the layer exists in the display list
if (this.options.layers.include.includes(layer)) {
map.addLayer(this.overlayMaps[layer]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! 🚀

if (this.options.layers.include.includes(layer)) {
map.addLayer(this.overlayMaps[layer]);
} else {
console.log("Layer specified does not exist.");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding in the error handling too! 😄

@crisner
Copy link
Contributor

crisner commented Feb 1, 2020

Everything looks good to me. @sagarpreet-chadha

Copy link
Collaborator

@sagarpreet-chadha sagarpreet-chadha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add parameter 'display' to options
3 participants