-
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
Add display parameter to show specific layers #378
Add display parameter to show specific layers #378
Conversation
currentHash: location.hash, | ||
addLayersToMap: false, | ||
addLayersToMap: false, // activates layers on map by default if 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.
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]); |
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 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]); |
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.
Nice! 🚀
if (this.options.layers.include.includes(layer)) { | ||
map.addLayer(this.overlayMaps[layer]); | ||
} else { | ||
console.log("Layer specified does not exist."); |
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.
Thanks for adding in the error handling too! 😄
Everything looks good to me. @sagarpreet-chadha |
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.
🎉
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 menudisplay: ['layername']
will turn on the specified layers, if they are availableaddLayersToMap: true
will override and display all layers that are available, regardless of what is indisplay