Skip to content
Closed
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
ac7f1e9
Create README.md
altheaFeu Mar 7, 2024
9552a40
Add files via upload
altheaFeu Mar 7, 2024
a39a598
Update README.md
altheaFeu Mar 7, 2024
754389d
Update tour.css
altheaFeu Mar 7, 2024
eed7472
Update tour.js
altheaFeu Mar 7, 2024
738857d
Update tour.js
altheaFeu Mar 8, 2024
765fec9
Update tour.css
altheaFeu Mar 8, 2024
b089815
Update README.md
altheaFeu Mar 8, 2024
29c651d
Create README.md
altheaFeu Mar 13, 2024
3308d58
Add transparency script
altheaFeu Mar 13, 2024
7883fd3
Update README.md
altheaFeu Mar 13, 2024
a108c68
Update README.md
altheaFeu Mar 13, 2024
d031ea4
Delete library/ui/change_opacity directory
altheaFeu Mar 14, 2024
147525b
Update README.md
altheaFeu Mar 14, 2024
f419db3
Create data_table.js
altheaFeu Mar 19, 2024
05f5081
Create README.md
altheaFeu Mar 19, 2024
770af45
Update README.md
altheaFeu Mar 19, 2024
be93fe9
Update README.md
altheaFeu Mar 19, 2024
5d6211e
Add demo.gif
altheaFeu Mar 19, 2024
6f52b17
Update README.md
altheaFeu Mar 19, 2024
ea50903
Update README.md
altheaFeu Mar 19, 2024
95772ec
Update tour.js
altheaFeu Mar 19, 2024
d923ed4
Add demo.png
altheaFeu Mar 19, 2024
987e255
Update README.md
altheaFeu Mar 19, 2024
fd4b414
Create README.md
altheaFeu Mar 25, 2024
7a60894
Create table-dock.js
altheaFeu Mar 25, 2024
c1fb2d8
Create table-dock.css
altheaFeu Mar 25, 2024
808cbde
Create table-XY.js
altheaFeu Mar 25, 2024
bb6002f
Update table-XY.js
altheaFeu Mar 25, 2024
da49258
Update table-dock.js
altheaFeu Mar 25, 2024
5febfd5
Create table-style.js
altheaFeu Mar 25, 2024
77ba2e9
Update README.md
altheaFeu Mar 25, 2024
0ea982c
Update README.md
altheaFeu Mar 26, 2024
8e143d7
Update README.md
altheaFeu Mar 26, 2024
4ec702b
Update table-XY.js
altheaFeu Mar 26, 2024
8d1aa07
Create workerXY.js
altheaFeu Mar 26, 2024
3ddfc45
Update table-dock.js
altheaFeu Mar 26, 2024
bff19d0
Update table-XY.js
altheaFeu Mar 26, 2024
6fa4510
Update README.md
altheaFeu Mar 27, 2024
b1ca250
Delete library/ui/driver_tutorial directory
altheaFeu Mar 27, 2024
08a08ad
Delete library/ui/data_table directory
altheaFeu Mar 27, 2024
4b829c4
Delete library/ui/map-excel directory
altheaFeu Mar 27, 2024
ff91d69
Merge branch '3liz:master' into update-selectionFromPopupGeometry
altheaFeu Mar 28, 2024
32ed761
Update selectionFromPopupGeometry.js
altheaFeu Mar 28, 2024
1dd8c49
Update selectionFromPopupGeometry.js
altheaFeu Mar 28, 2024
dd8a457
Update selectionFromPopupGeometry.js
altheaFeu Mar 29, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,32 @@
* @param {string} featureCrs The CRS of the geometry
*/
function addSelectionButton(featureToolbar, featureGeometry, featureCrs) {

const featureToolbarDiv = featureToolbar.querySelector('div.feature-toolbar');
var featureToolbarDiv = featureToolbar.find('div.feature-toolbar');

// Get the button if it already exists
const buttonValue = `${featureGeometry}@${featureCrs}`;

// Selection button HTML
const selectionButtonHtml = `
<button class="btn btn-mini popup-select-by-geometry" value="${buttonValue}" type="button" data-original-title="Selection" title="Selection">
<i class="icon-star"></i>
&nbsp;</button>
<button class="btn btn-mini popup-select-by-geometry" value="${buttonValue}" type="button" data-original-title="Selection" title="Selection">
<i class="icon-star"></i>
&nbsp;
</button>
`;

const existingButton = featureToolbarDiv.querySelector(`button.popup-select-by-geometry[value="${buttonValue}"]`);
if (existingButton) {
// Check if the button already exists
const existingButton = featureToolbarDiv.find(`button.popup-select-by-geometry[value="${buttonValue}"]`);
if (existingButton.length > 0) {
return false;
}

// Append the button to the toolbar
featureToolbarDiv.insertAdjacentHTML('beforeend', selectionButtonHtml);
const selectionButton = featureToolbarDiv.querySelector(`button.popup-select-by-geometry[value="${buttonValue}"]`);

featureToolbarDiv.append(selectionButtonHtml);
// Trigger the action when clicking on button
selectionButton.addEventListener('click', popupSelectionButtonClickHandler);
featureToolbarDiv.on('click', `button.popup-select-by-geometry[value="${buttonValue}"]`, popupSelectionButtonClickHandler);
}


/**
* Function which wait for te given ms before returning the promise
*
Expand All @@ -42,7 +42,6 @@ function delay(time) {
return new Promise(resolve => setTimeout(resolve, time));
}


/**
* Reacts to the click on a popup select by geometry/
*
Expand All @@ -51,42 +50,52 @@ function delay(time) {
function popupSelectionButtonClickHandler(event) {
// Only go on when the button has been clicked
// not the child <i> icon
let target = event.target;
if (!event.target.matches('.popup-select-by-geometry')) {
target = target.parentNode;
let target = $(event.target);
if (!target.is('.popup-select-by-geometry')) {
target = target.parent();
}

// Get the button which triggered the click event
const button = target;
const value = button.value;
const value = button.val();
const wkt = value.split('@')[0];
const crs = value.split('@')[1];
const featureToolbar = button.closest('lizmap-feature-toolbar');
const featureToolbarValue = featureToolbar.getAttribute('value');
const featureToolbarValue = featureToolbar.attr('value');

// check geometry type
let isPolygon = (wkt.toUpperCase().indexOf('POLYGON') !== -1);
let isLinestring = (wkt.toUpperCase().indexOf('LINE') !== -1);
let isPoint = (wkt.toUpperCase().indexOf('POINT') !== -1);

// Create a temporary layer from the WKT
const temporaryVector = lizMap.mainLizmap.layers.addLayerFromWKT(wkt, crs, null);

// Get the features of this layer
const features = temporaryVector.getSource().getFeatures();
const temporaryVector = new OpenLayers.Layer.Vector("Vector Layer");
// Convert WKT as a geometry
const format = new OpenLayers.Format.WKT();
const feature = format.read(wkt);
temporaryVector.addFeatures([feature]);
lizMap.map.addLayer(temporaryVector);

// Open the selection tool to activate it
const selectionMenu = document.getElementById('mapmenu').querySelector('li.selectiontool a');
let selectionMenuIsActive = selectionMenu.parentElement.classList.contains("active");
const selectionMenu = $('#mapmenu li.selectiontool a');
let selectionMenuIsActive = selectionMenu.parent().hasClass("active");
if (!selectionMenuIsActive) {
selectionMenu.click();
}

let drawLayer = lizMap.mainLizmap.digitizing.drawLayer;
// Clear the previously drawn geometries
lizMap.mainLizmap.digitizing.drawLayer.getSource().clear();
if (drawLayer.getSource && typeof drawLayer.getSource().clear === 'function') {
drawLayer.getSource().clear();
} else {
drawLayer.removeAllFeatures();
}

// Add the feature created from the popup
lizMap.mainLizmap.digitizing.drawLayer.getSource().addFeature(features[0]);
// Add the features to drawLayer
if (drawLayer.addFeature && typeof drawLayer.addFeature() === 'function') {
drawLayer.addFeature(feature);
} else {
drawLayer.addFeatures(temporaryVector.features);
}

// For polygons
// We must add a buffer 1 to force the transformation of multipolygon
Expand All @@ -96,15 +105,20 @@ function popupSelectionButtonClickHandler(event) {
let hadBuffer = false;
let hadBufferValue = false;
if (isPolygon) {
const selectionToolDiv = document.getElementById('selectiontool');
const bufferInput = selectionToolDiv.querySelector('div.selectiontool-buffer input');
hadBufferValue = bufferInput.value;
if (bufferInput.value == 0) {
const selectionToolDiv = $('#selectiontool');
const bufferInput = selectionToolDiv.find('div.selectiontool-buffer input');
hadBufferValue = bufferInput.val();
if (bufferInput.val() == 0) {
lizMap.mainLizmap.selectionTool._bufferValue = 0.00001;
hadBuffer = true;
}
}

// change color of feature selected for yellow highlight
selectionTool.bufferLayer.styleMap.styles.select.defaultStyle.strokeColor = "yellow";
selectionTool.bufferLayer.styleMap.styles.select.defaultStyle.fillColor = "yellow";
selectionTool.bufferLayer.styleMap.styles.select.defaultStyle.fillOpacity = 0.3;

// Select only inside
let oldOperator = lizMap.mainLizmap.selectionTool._geomOperator;
if (isPolygon) {
Expand All @@ -115,7 +129,7 @@ function popupSelectionButtonClickHandler(event) {
lizMap.mainEventDispatcher.dispatch('digitizing.featureDrawn');

// Remove the temporary vector layer
lizMap.mainLizmap.layers.removeLayer(temporaryVector);
lizMap.map.removeLayer(temporaryVector);

// Set back the buffer if necessary
if (isPolygon && hadBuffer) {
Expand All @@ -126,7 +140,11 @@ function popupSelectionButtonClickHandler(event) {
}

// Remove the selection geometry
lizMap.mainLizmap.digitizing.drawLayer.getSource().clear();
if (drawLayer.getSource && typeof drawLayer.getSource().clear === 'function') {
drawLayer.getSource().clear();
} else {
drawLayer.removeAllFeatures();
}

// Deactivate back the selection tool
if (!selectionMenuIsActive) {
Expand All @@ -136,11 +154,11 @@ function popupSelectionButtonClickHandler(event) {
// // Deselect the feature which triggered the selection
delay(5000).then(() => {
// Get the popup again (it could have disappeared and reappeared after the selection
const parentToolbar = document.querySelector(`lizmap-feature-toolbar[value="${featureToolbarValue}"]`);
if (!parentToolbar) return;
const unselectButton = parentToolbar.querySelector('button.feature-select');
if (!unselectButton) return;
if (unselectButton.classList.contains('btn-primary')) {
const parentToolbar = $(`lizmap-feature-toolbar[value="${featureToolbarValue}"]`);
if (!parentToolbar.length) return;
const unselectButton = parentToolbar.find('button.feature-select');
if (!unselectButton.length) return;
if (unselectButton.hasClass('btn-primary')) {
unselectButton.click();
}
});
Expand All @@ -149,35 +167,46 @@ function popupSelectionButtonClickHandler(event) {
lizMap.events.on({
lizmappopupdisplayed: function (e) {
// Loop through each layer+feature item
const popupContainer = document.getElementById(e.containerId);
const items = popupContainer.querySelectorAll('div.lizmapPopupDiv');
items.forEach(function (item) {
const popupContainer = $('#' + e.containerId); // Container
const items = popupContainer.find('div.lizmapPopupDiv');

items.each(function() {
// Get the layer ID
const featureId = item.querySelector('input.lizmap-popup-layer-feature-id').value;

const featureId = $(this).find('input.lizmap-popup-layer-feature-id').val();
// Check if there is a geometry
const featureGeometryInput = item.querySelector('input.lizmap-popup-layer-feature-geometry');
if (!featureGeometryInput) {
const featureGeometryInput = $(this).find('input.lizmap-popup-layer-feature-geometry');
if (!featureGeometryInput.length) {
return;
}
const featureGeometry = featureGeometryInput.value;
const featureGeometry = featureGeometryInput.val();

// Geometry CRS
let featureCrs = 'EPSG:4326';
const featureCrsInput = item.querySelector('input.lizmap-popup-layer-feature-crs');
if (featureCrsInput) {
featureCrs = featureCrsInput.value
const featureCrsInput = $(this).find('input.lizmap-popup-layer-feature-crs');
if (featureCrsInput.length) {
featureCrs = featureCrsInput.val();
}

// Get feature toolbar
const featureToolbar = item.querySelector(`lizmap-feature-toolbar[value="${featureId}"]`);

let featureToolbar = $(this).find(`lizmap-feature-toolbar[value="${featureId}"]`);

if (!featureToolbar.length) {
// Create feature toolbar
featureToolbar = $('<lizmap-feature-toolbar>')
.attr('value', featureId)
.css('display', 'inline-flex')
.append($(this).find('input[value="' + featureId + '"]').nextUntil('br'))
.append($('<div>').addClass('feature-toolbar').css('display', 'inline'));

// Insert feature toolbar after input element
$(this).find('input[value="' + featureId + '"]').after(featureToolbar);
}

// Add a button in the popup feature bar
if (featureGeometry && featureCrs) {
addSelectionButton(featureToolbar, featureGeometry, featureCrs);
}

});
}
});