-
-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3656 from nboisteault/baselayers-ol7
Baselayers ol7
- Loading branch information
Showing
72 changed files
with
5,546 additions
and
3,518 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { mainLizmap, mainEventDispatcher } from '../modules/Globals.js'; | ||
import {html, render} from 'lit-html'; | ||
|
||
|
||
export default class BaseLayers extends HTMLElement { | ||
constructor() { | ||
super(); | ||
} | ||
|
||
connectedCallback() { | ||
|
||
if (mainLizmap.state.baseLayers.baseLayerNames.length === 0) { | ||
document.getElementById('switcher-baselayer').classList.add('hide'); | ||
return; | ||
} | ||
|
||
this._template = () => html` | ||
${mainLizmap.state.baseLayers.baseLayerNames.length > 1 | ||
? html` | ||
<select @change=${(event) => { mainLizmap.state.baseLayers.selectedBaseLayerName = event.target.value }}> | ||
${mainLizmap.state.baseLayers.baseLayerConfigs.map((config) => | ||
html`<option .selected="${mainLizmap.state.baseLayers.selectedBaseLayerName === config.name}" value="${config.name}">${config.title === 'empty' ? lizDict['baselayer.empty.title'] : config.title}</option>` | ||
)} | ||
</select>` | ||
: | ||
html`${mainLizmap.state.baseLayers.baseLayerNames[0].title}` | ||
} | ||
`; | ||
|
||
render(this._template(), this); | ||
|
||
mainEventDispatcher.addListener( | ||
() => { | ||
render(this._template(), this); | ||
}, ['baselayers.selection.changed'] | ||
); | ||
} | ||
|
||
disconnectedCallback() { | ||
mainEventDispatcher.removeListener( | ||
() => { | ||
render(this._template(), this); | ||
}, ['baselayers.selection.changed'] | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
import { mainLizmap } from '../modules/Globals.js'; | ||
|
||
import { html, render } from 'lit-html'; | ||
import { when } from 'lit-html/directives/when.js'; | ||
|
||
export default class Treeview extends HTMLElement { | ||
constructor() { | ||
super(); | ||
} | ||
|
||
connectedCallback() { | ||
|
||
this._onChange = () => { | ||
render(this._layerTemplate(mainLizmap.state.layerTree), this); | ||
}; | ||
|
||
this._layerTemplate = layerTreeGroupState => | ||
html` | ||
<ul> | ||
${layerTreeGroupState.children.map(item => html` | ||
<li> | ||
${item.type === 'group' || (item.symbologyChildrenCount && item.layerConfig.legendImageOption !== "disabled") | ||
? html`<div class="expandable ${item.expanded ? 'expanded' : ''}" @click=${() => item.expanded = !item.expanded}></div>` | ||
: '' | ||
} | ||
<div class="${item.checked ? 'checked' : ''} ${item.type}"> | ||
<div class="loading ${item.loading ? 'spinner' : ''}"></div> | ||
<input class="${layerTreeGroupState.mutuallyExclusive ? 'rounded-checkbox' : ''}" type="checkbox" id="node-${item.name}" .checked=${item.checked} @click=${() => item.checked = !item.checked} > | ||
<div class="node ${item.isFiltered ? 'filtered' : ''}"> | ||
${item.type === 'layer' | ||
? html`<img class="legend" src="${item.icon}">` | ||
: '' | ||
} | ||
<label for="node-${item.name}">${item.name}</label> | ||
<div class="layer-actions"> | ||
<a href="${this._createDocLink(item.name)}" target="_blank" title="${lizDict['tree.button.link']}"> | ||
<i class="icon-share"></i> | ||
</a> | ||
<a href="${this._createRemoveCacheLink(item.name)}" target="_blank"> | ||
<i class="icon-remove-sign" title="${lizDict['tree.button.removeCache']}" @click=${event => this._removeCache(event)}></i> | ||
</a> | ||
<i class="icon-info-sign" @click=${() => this._toggleMetadata(item.name, item.type)}></i> | ||
</div> | ||
</div> | ||
</div> | ||
${(item.symbologyChildrenCount && item.layerConfig.legendImageOption !== "disabled") | ||
? html` | ||
<ul class="symbols"> | ||
${item.symbologyChildren.map(symbol => html` | ||
<li> | ||
<label class="symbol-title"> | ||
<input type="checkbox" .checked=${symbol.checked} @click=${() => symbol.checked = !symbol.checked}> | ||
<img class="legend" src="${symbol.icon}"> | ||
${symbol.title} | ||
</label> | ||
</li>` | ||
)} | ||
</ul>` | ||
: '' | ||
} | ||
${when(item.type === 'group', () => this._layerTemplate(item))} | ||
</li>` | ||
)} | ||
</ul>`; | ||
|
||
render(this._layerTemplate(mainLizmap.state.layerTree), this); | ||
|
||
mainLizmap.state.layerTree.addListener( | ||
this._onChange, | ||
['layer.loading.changed', 'layer.visibility.changed', 'group.visibility.changed', 'layer.style.changed', 'layer.symbology.changed', 'layer.filter.changed', 'layer.expanded.changed', 'group.expanded.changed'] | ||
); | ||
} | ||
|
||
disconnectedCallback() { | ||
mainLizmap.state.layerTree.removeListener( | ||
this._onChange, | ||
['layer.loading.changed', 'layer.visibility.changed', 'group.visibility.changed', 'layer.style.changed', 'layer.symbology.changed', 'layer.filter.changed', 'layer.expanded.changed', 'group.expanded.changed'] | ||
); | ||
} | ||
|
||
_createDocLink(layerName) { | ||
let url = lizMap.config.layers?.[layerName]?.link; | ||
|
||
// Test if the url is internal | ||
const mediaRegex = /^(\/)?media\//; | ||
if (mediaRegex.test(url)) { | ||
const mediaLink = lizUrls.media + '?' + new URLSearchParams(lizUrls.params); | ||
url = mediaLink + '&path=/' + url; | ||
} | ||
return url; | ||
} | ||
|
||
_createRemoveCacheLink(layerName) { | ||
if(!lizUrls.removeCache){ | ||
return; | ||
} | ||
const removeCacheServerUrl = lizUrls.removeCache + '?' + new URLSearchParams(lizUrls.params); | ||
return removeCacheServerUrl + '&layer=' + layerName; | ||
} | ||
|
||
_removeCache(event) { | ||
if (! confirm(lizDict['tree.button.removeCache.confirmation'])){ | ||
event.preventDefault(); | ||
} | ||
} | ||
|
||
_toggleMetadata (layerName, isGroup){ | ||
lizMap.events.triggerEvent("lizmapswitcheritemselected", | ||
{ 'name': layerName, 'type': isGroup ? "group" : "layer", 'selected': true} | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.