Skip to content

Commit

Permalink
#378 Legend formatting, reacts to layer toggles
Browse files Browse the repository at this point in the history
  • Loading branch information
tariqksoliman committed May 11, 2023
1 parent 408d932 commit 2eb8c71
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
13 changes: 13 additions & 0 deletions src/essence/Basics/Layers_/Layers_.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,15 @@ const L_ = {
}
} else console.log('Failure updating to new site')
},
_onLayerToggleSubscriptions: {},
subscribeOnLayerToggle: function (fid, func) {
if (typeof func === 'function')
L_._onLayerToggleSubscriptions[fid] = func
},
unsubscribeOnLayerToggle: function (fid) {
if (L_._onLayerToggleSubscriptions[fid] != null)
delete L_._onLayerToggleSubscriptions[fid]
},
//Takes in config layer obj
//Toggles a layer on and off and accounts for sublayers
//Takes in a config layer object
Expand All @@ -198,6 +207,10 @@ const L_ = {
else on = false

await L_.toggleLayerHelper(s, on)

Object.keys(L_._onLayerToggleSubscriptions).forEach((k) => {
L_._onLayerToggleSubscriptions[k](s.name, !on)
})
},
toggleLayerHelper: async function (s, on, ignoreToggleStateChange) {
if (s.type !== 'header') {
Expand Down
1 change: 1 addition & 0 deletions src/essence/Basics/ToolController_/ToolController_.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ let ToolController_ = {
this.toolModuleNames.push(tools[i].js)

if (tools[i].separatedTool) {
d3.select('#viewerToolBar').style('padding-left', '36px')
let sep = this.separatedDiv
.append('div')
.attr('id', `toolSeparated_${tools[i].name}`)
Expand Down
2 changes: 2 additions & 0 deletions src/essence/Basics/Viewer_/Viewer_.js
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,7 @@ var Viewer_ = {

function buildToolBar() {
d3.select('#viewerToolBar').html('')

Viewer_.toolBar = d3
.select('#viewerToolBar')
.append('div')
Expand All @@ -415,6 +416,7 @@ function buildToolBar() {
.style('display', 'flex')
.style('justify-content', 'space-between')
.style('padding', '0px 5px')
//.style()

let left = Viewer_.toolBar.append('div')

Expand Down
7 changes: 6 additions & 1 deletion src/essence/Tools/Legend/LegendTool.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,16 @@ var LegendTool = {
this.MMWebGISInterface = new interfaceWithMMWebGIS()
this.activeLayerNames = []

L_.subscribeOnLayerToggle('LegendTool', () => {
this.MMWebGISInterface = new interfaceWithMMWebGIS()
})

this.made = true
},
destroy: function () {
this.MMWebGISInterface.separateFromMMWebGIS()
this.targetId = null

L_.unsubscribeOnLayerToggle('LegendTool')
this.made = false
},
overwriteLegends: overwriteLegends,
Expand All @@ -34,6 +38,7 @@ function interfaceWithMMWebGIS() {
this.separateFromMMWebGIS = function () {
separateFromMMWebGIS()
}
separateFromMMWebGIS()

let tools = drawLegendHeader()

Expand Down

0 comments on commit 2eb8c71

Please sign in to comment.