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

Baselayers ol7 #3656

Merged
merged 103 commits into from
Jul 18, 2023
Merged
Show file tree
Hide file tree
Changes from 102 commits
Commits
Show all changes
103 commits
Select commit Hold shift + click to select a range
7b6ba45
Add OL7 map for base layers
nboisteault Apr 27, 2023
3f7167d
Add OSM, Stamen, OpenTopoMap base layers
nboisteault Apr 27, 2023
8fb14f0
Add Thunderforest cyclemap
nboisteault Apr 27, 2023
3199a51
Add Bing maps
nboisteault Apr 27, 2023
ea838d7
Add culture to get Bing maps tile in user language
nboisteault Apr 27, 2023
c974f5d
Add BaseLayers component
nboisteault May 2, 2023
e764413
Use minZoom/maxZoom
nboisteault May 2, 2023
ed93acc
Use QGIS project projection as OL map projection
nboisteault May 2, 2023
25d86af
Add overlay layers via WMS
nboisteault May 4, 2023
d256289
Handle image format for WMS
nboisteault May 4, 2023
8fd8890
Handle scale dependent layer visibility
nboisteault May 4, 2023
c7a9491
Handle layer visibility at startup
nboisteault May 4, 2023
03d0948
Handle cached layers with WMTS
nboisteault May 4, 2023
eb220ec
Handle SELECTION with WMS
nboisteault May 4, 2023
d01fa61
Handle FILTER with WMS
nboisteault May 5, 2023
792ace0
API: add getLayerByTypeName() method
nboisteault May 5, 2023
a05f696
Finish refacto WMS layers in attributeTable.js
nboisteault May 5, 2023
1215d17
Register projections from `lizProj4` if unknown
nboisteault May 9, 2023
93fd6ac
e2e: fix URL encoding for requests made by fetch
nboisteault May 11, 2023
29b7e2a
Handle FILTER with WMS in timemanager
nboisteault May 11, 2023
32ab27c
Handle style in theme selector
nboisteault May 12, 2023
3022767
Put baseLayers and overlayLayers in LayerGroup
nboisteault May 12, 2023
d9afbf9
Add overlayLayers in correct z order
nboisteault May 12, 2023
7b902bb
Apply theme directly on map
nboisteault May 12, 2023
7943c82
Display selected style in metadata
nboisteault May 12, 2023
b624b8a
GetFeatureInfo without OL2
nboisteault May 15, 2023
9075612
Set min/max resolution only when not default
nboisteault May 23, 2023
ec7410e
Layers and LayersGroups hierarchy
nboisteault May 23, 2023
66e5a33
Treeview component
nboisteault May 23, 2023
79524b7
Treeview: add checkbox to toggle layer/group visibility
nboisteault May 25, 2023
2e5429d
Treeview: children UI for layers in group w/ visibility set to false
nboisteault May 25, 2023
9621502
Treeview: display metadata
nboisteault May 26, 2023
ebf9830
Handle layers opacity in metadata
nboisteault May 26, 2023
73905a7
Handle layers style in metadata
nboisteault May 26, 2023
7da1fd7
Handle themes
nboisteault May 26, 2023
023201b
Handle group's visibility for theme
nboisteault May 26, 2023
9939dcf
Set layer's group visible to `true` when layer's visible is set to `t…
nboisteault May 30, 2023
4e473d6
treeview: mutually exclusive groups
nboisteault Jun 1, 2023
3d4942a
Trreview: handle layer UI when filtered
nboisteault Jun 1, 2023
6d65f7d
Treeview: group as layer
nboisteault Jun 1, 2023
db1a145
Treeview: opacity can be set for groups too
nboisteault Jun 1, 2023
d047d6b
Handle baselayers reprojection
nboisteault Jun 6, 2023
d6fb0ac
Add .js for import when missing
nboisteault Jun 8, 2023
31fec8f
Handle baselayers from validated configuration
nboisteault Jun 8, 2023
5adf73f
Display baselayers metadata
nboisteault Jun 9, 2023
d1446ce
Handle layer link to doc
nboisteault Jun 9, 2023
92b055e
Handle layer link to remove cache
nboisteault Jun 9, 2023
13ef01e
Display a spinner when a layer is loading
nboisteault Jun 9, 2023
283d31f
Several fixes
nboisteault Jun 12, 2023
3d7d12c
Use new config. Remove "True"/"False"
nboisteault Jun 13, 2023
2cbc0d9
Treeview: display groups label in bold
nboisteault Jun 13, 2023
f4a1685
Display simple legend next to layer title as QGIS does
nboisteault Jun 13, 2023
bd57bc4
Don't display `switcher-baselayer` when no base layers
nboisteault Jun 15, 2023
b06fbd1
Handle single base layer display
nboisteault Jun 15, 2023
9ef3b6d
Refactor listen/dispatch events from map
nboisteault Jun 16, 2023
7d10c68
Display treeview based on mapState
nboisteault Jun 19, 2023
be418c7
Treeview: display symbols for categorized/rules legends
nboisteault Jun 20, 2023
0e50cbb
Use `mainLizmap.state` to init OL map
nboisteault Jun 20, 2023
046f875
Treeview: toggle children and symbols visibility
nboisteault Jun 20, 2023
6962f43
Treeview: expand/unfold all
nboisteault Jun 20, 2023
7e7e15e
Check/uncheck legend's symbology
nboisteault Jun 23, 2023
8a5808c
Handle style switch with new API
nboisteault Jun 23, 2023
155e67f
Update legends when style changes
nboisteault Jun 26, 2023
76e68af
Handle loading with new API
nboisteault Jun 26, 2023
ca9c7ce
e2e: base-layers cypress to playwright
nboisteault Jun 27, 2023
8341166
Fix: use `LAYER` parameter not `LAYERS` w/ getLegendGraphic
nboisteault Jun 27, 2023
7e02aac
Remove old layer switcher
nboisteault Jun 27, 2023
53f2363
Handle baselayers with new API
nboisteault Jun 29, 2023
afdfa16
Handle select/filter with new API
nboisteault Jun 29, 2023
bce0dd6
Fix Action.js for OL7
nboisteault Jun 30, 2023
b22ecb0
e2e: make geature_toolbar tests pass
nboisteault Jun 30, 2023
b01ea45
Fix: auto hide popup w/ no content only
nboisteault Jul 3, 2023
e30e10b
e2e: test filter by user w/ playwright
nboisteault Jul 3, 2023
bfdf841
e2e: setup authentification for playwright
nboisteault Jul 3, 2023
ad39dbc
e2e: test filter by user w/ playwright. Follow up
nboisteault Jul 4, 2023
186ef44
e2e: note on how to get mouse coords in Firefox
nboisteault Jul 4, 2023
51b0787
e2e: form_edit_related_child_data
nboisteault Jul 4, 2023
985beea
Popup: layer w/ some edition capabilities have popup enabled
nboisteault Jul 4, 2023
3d1170b
Multiple fixes
nboisteault Jul 4, 2023
22185c7
e2e: use login script instead of login step by step
nboisteault Jul 6, 2023
7cf4cd0
Set opacity w/ new API
nboisteault Jul 6, 2023
755c0a7
Handle print w/ new API
nboisteault Jul 7, 2023
a957f02
Fix: MapItemState opacity setter
rldhont Jul 10, 2023
0662c97
Fix: LayerTreeItemState opacity getter and setter
rldhont Jul 10, 2023
2a18670
Units JS Test: opacity
rldhont Jul 10, 2023
b29cb98
MapLayerState Loading event propagation
rldhont Jul 10, 2023
d75886a
e2e: remove legend test
nboisteault Jul 10, 2023
e7f83aa
e2e: fix startup.spec.js
nboisteault Jul 10, 2023
10e22b8
Handle popup w/ new API
nboisteault Jul 10, 2023
5a695b9
Don't request popup when edition is pending
nboisteault Jul 10, 2023
e8d2049
e2e: some fixes
nboisteault Jul 10, 2023
e33bedd
Remove some legacy code
nboisteault Jul 11, 2023
fbe5e82
e2e: add pixel diff tolerance to snapshot tests
nboisteault Jul 11, 2023
f4c35d3
Add methods to get layers and groups in a group
nboisteault Jul 11, 2023
7e042ee
Fix group opacity
nboisteault Jul 11, 2023
0fb49b2
e2e: replace treeview Cypress test to Playwright
nboisteault Jul 11, 2023
6e858f7
Add methods to get layers and groups in a group followup
nboisteault Jul 11, 2023
e16f69e
Add item expanded state
nboisteault Jul 17, 2023
4e8b207
e2e: Tests the legend display option expand/hide/disabled w/ playwright
nboisteault Jul 17, 2023
18d3da4
Handle themes w/ new API
nboisteault Jul 17, 2023
f5d4b13
e2e: test themes w/ Playwright
nboisteault Jul 18, 2023
04c6d67
e2e: Fix last tests
nboisteault Jul 18, 2023
d5d2193
Tests: add `checkedGroupNode` to theme test
nboisteault Jul 18, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ tests/end2end/cypress/screenshots/
tests/js-units/node_modules/
tests/.env
tests/end2end/playwright-report/
tests/end2end/playwright/.auth
tests/end2end/test-results

/.composer
Expand Down
46 changes: 46 additions & 0 deletions assets/src/components/BaseLayers.js
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']
);
}
}
29 changes: 6 additions & 23 deletions assets/src/components/Print.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,34 +230,17 @@ export default class Print extends HTMLElement {
}

// Add visible layers
for (const layer of mainLizmap._lizmap3.map.layers) {
if (((layer instanceof OpenLayers.Layer.WMS) || (layer instanceof OpenLayers.Layer.WMTS))
&& layer.getVisibility() && layer?.params?.LAYERS) {
// Get config
let configLayer;
let layerCleanName = mainLizmap._lizmap3.cleanName(layer.name);

if (layerCleanName) {
let qgisName = mainLizmap._lizmap3.getLayerNameByCleanName(layerCleanName);
configLayer = mainLizmap.config.layers[qgisName];
}
if (!configLayer) {
configLayer = mainLizmap.config.layers[layer.params['LAYERS']] || mainLizmap.config.layers[layer.name];
}
// If the layer has no config or no `id` it is not a QGIS layer or group
if (!configLayer || !configLayer?.id) {
return;
}

for (const layer of mainLizmap.state.rootMapGroup.findMapLayers().slice().reverse()) {
if (layer.visibility) {
// Add layer to the list of printed layers
printLayers.push(layer.params['LAYERS']);
printLayers.push(layer.wmsName);

// Optionally add layer style if needed (same order as layers )
styleLayers.push(layer.params?.['STYLES'] || '');
styleLayers.push(layer.wmsSelectedStyleName);

// Handle qgis layer opacity otherwise client value override it
if (configLayer?.opacity) {
opacityLayers.push(parseInt(255 * layer.opacity * configLayer.opacity));
if (layer.layerConfig?.opacity) {
opacityLayers.push(parseInt(255 * layer.opacity * layer.layerConfig.opacity));
} else {
opacityLayers.push(parseInt(255 * layer.opacity));
}
Expand Down
112 changes: 112 additions & 0 deletions assets/src/components/Treeview.js
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}
)
}
}
4 changes: 4 additions & 0 deletions assets/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import PasteGeom from './components/edition/PasteGeom.js';
import ActionSelector from './components/ActionSelector.js';
import Print from './components/Print.js';
import FullScreen from './components/FullScreen.js';
import BaseLayers from './components/BaseLayers.js';
import Treeview from './components/Treeview.js';

import { mainLizmap, mainEventDispatcher } from './modules/Globals.js';

Expand All @@ -35,6 +37,8 @@ lizMap.events.on({
window.customElements.define('lizmap-action-selector', ActionSelector);
window.customElements.define('lizmap-print', Print);
window.customElements.define('lizmap-fullscreen', FullScreen);
window.customElements.define('lizmap-base-layers', BaseLayers);
window.customElements.define('lizmap-treeview', Treeview);

lizMap.mainLizmap = mainLizmap;
lizMap.mainEventDispatcher = mainEventDispatcher;
Expand Down
Loading
Loading