Skip to content

Commit

Permalink
Merge pull request #393 from NASA-AMMOS/jr-displayonstart-legend
Browse files Browse the repository at this point in the history
Added an option to the LegendTool to automatically display on start
  • Loading branch information
jtroberts authored Jul 12, 2023
2 parents bfcc59d + cb41d0c commit e608671
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 2 deletions.
8 changes: 7 additions & 1 deletion docs/pages/Tools/Legend/Legend.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@ parent: Tools

A layer can be configured with a legend by pointing its Legend field to a .csv file or by including a JSON `legend` array into the layer's Raw Variables. The Legend Tool renders symbologies and gradient scales for any properly configured on layer.

The Legend Tool takes no raw variable configurations in the Tools Tab.
On the Configure page, under Tools, you can specify if the expanded legend should automatically be displayed on start:

```javascript
{
"displayOnStart": true
}
```

### legend.csv example:

Expand Down
14 changes: 14 additions & 0 deletions src/essence/Basics/Map_/Map_.js
Original file line number Diff line number Diff line change
Expand Up @@ -1131,6 +1131,20 @@ function allLayersLoaded() {

L_.loaded()
//OTHER TEMPORARY TEST STUFF THINGS

// Turn on legend if displayOnStart is true
if ('LegendTool' in ToolController_.toolModules) {
if (ToolController_.toolModules['LegendTool'].displayOnStart == true) {
ToolController_.toolModules['LegendTool'].make('toolContentSeparated_Legend')
let _event = new CustomEvent('toggleSeparatedTool', {
detail: {
toggledToolName: 'LegendTool',
visible: true,
},
})
document.dispatchEvent(_event)
}
}
}
}

Expand Down
5 changes: 5 additions & 0 deletions src/essence/Tools/Legend/LegendTool.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ var LegendTool = {
MMWebGISInterface: null,
targetId: null,
made: false,
displayOnStart: false,
initialize: function () {
//Get tool variables
this.displayOnStart = L_.getToolVars('legend')['displayOnStart']
},
make: function (targetId) {
this.targetId = targetId
this.MMWebGISInterface = new interfaceWithMMWebGIS()
Expand Down
2 changes: 1 addition & 1 deletion src/essence/Tools/Legend/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"defaultIcon": "map-legend",
"description": "Show a chart mapping colors and symbols to meaning.",
"descriptionFull": "",
"hasVars": false,
"hasVars": true,
"name": "Legend",
"toolbarPriority": 2,
"separatedTool": true,
Expand Down

0 comments on commit e608671

Please sign in to comment.