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

Right dock that show data from a layer #75

Open
wants to merge 42 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 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
8e45d81
Update README.md
altheaFeu Mar 27, 2024
5cca9dd
Delete library/ui/map-excel directory
altheaFeu Mar 27, 2024
a39eadb
Delete library/ui/driver_tutorial directory
altheaFeu Mar 27, 2024
716ad81
Update data_table.js
altheaFeu Mar 27, 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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ If you are developing a new feature, do not hesitate to let us know so that we c
## UI

* [Add documentation](./library/ui/add_documentation) with buttons and a dock
* [Display a right-docked table of data](./library/ui/data_table)
* [Background selector](./library/ui/background_selector), like on Google Maps
* [Hide value popup](./library/ui/hide_value_popup)
* [Measure tool custom style](./library/ui/measure_tool_custom_style)
Expand Down
5 changes: 5 additions & 0 deletions library/ui/data_table/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Data Display

![donnees](./demo.png)

This script retrieves data from a given URL containing GeoJSON data, dynamically creates an HTML table with the fetched data, and displays it in a Lizmap user interface.
101 changes: 101 additions & 0 deletions library/ui/data_table/data_table.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
lizMap.events.on({
'uicreated': function () {

// Change the URL from your own data
const URL = 'https://url/index.php/lizmap/service/?repository=your_repositoryu&project=your_project&SERVICE=WFS&REQUEST=GetFeature&VERSION=your_version&TYPENAME=your_layerOUTPUTFORMAT=GeoJSON';
const NAME = "Nom de la couche"

var html = '<div id="statistic_content"></div>';
lizMap.addDock(
'table_dock',
`Table of ${NAME}`,
'right-dock',
html,
'icon-signal'
);

try {
const promise = getData(URL);

// Handle promise resolution
promise.then(features =>{
// Extract property names from the first feature
const propertyNames = Object.keys(features[0].properties);
const tableRows = [];

// Create table header using property names
const tableHeader = `
<thead>
<tr>
${propertyNames.map(propertyName => `<th>${propertyName}</th>`).join('')}
</tr>
</thead>
`;

// Add rows to the table
features.forEach(feature => {
const row = `
<tr>
${propertyNames.map(propertyName => `<td>${feature.properties[propertyName]}</td>`).join('')}
</tr>
`;
tableRows.push(row);
});

// Update the style of your table
const tableStyle = `
<style>
table#table-data {
width: 100%;
border-collapse: collapse;
border: 1px solid;
color:white;
}
#table-data th, #table-data td {
padding: 8px;
text-align: left;
border-bottom: 1px solid #ddd;
}
table#table-data th {
background-color: grey;
}
</style>
`;

// Get to the table container
const tableContainer = $('#statistic_dock');

// Add the content of the table
tableContainer.html(`
${tableStyle}
<table id="table-data">
${tableHeader}
${tableRows.join('')}
</table>
`);

})
}catch (error) {
console.error('An error occurred during processing: ', error);
}

}
})

// Asynchronous function to get data
async function getData(url) {
try {
const response = await fetch(url);

if (!response.ok) {
throw new Error(`HTTP Error! Status: ${response.status}`);
}

const data = await response.json();
return data.features;

} catch (error) {
console.error('An error occurred while retrieving the data', error);
throw error;
}
};
Binary file added library/ui/data_table/demo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.