map - show points

This commit is contained in:
Jan Prochazka
2022-06-11 16:06:49 +02:00
parent 343cf84a58
commit f65c15d2e5

View File

@@ -30,9 +30,31 @@
const geoValues = selection.map(x => x.value).filter(isWktGeometry); const geoValues = selection.map(x => x.value).filter(isWktGeometry);
const geometries = [];
if (geoValues.length > 0) { if (geoValues.length > 0) {
// parse WKT to geoJSON array // parse WKT to geoJSON array
const geometries = geoValues.map(wellknown); geometries.push(...geoValues.map(wellknown));
}
const selectedRows = _.groupBy(selection || [], 'row');
for (const rowKey of _.keys(selectedRows)) {
const cells = selectedRows[rowKey];
const lat = cells.find(x => x.column.toLowerCase().includes('lat'));
const lon = cells.find(x => x.column.toLowerCase().includes('lon') || x.column.toLowerCase().includes('lng'));
if (lat && lon) {
geometries.push({
type: 'Point',
coordinates: [lon.value, lat.value],
});
}
}
if (geometries.length == 0) {
return;
}
const geoJson = { const geoJson = {
type: 'GeometryCollection', type: 'GeometryCollection',
geometries, geometries,
@@ -64,7 +86,6 @@
map.fitBounds(geoJsonObj.getBounds()); map.fitBounds(geoJsonObj.getBounds());
selectionLayers.push(geoJsonObj); selectionLayers.push(geoJsonObj);
} }
}
onMount(() => { onMount(() => {
// new Map({ // new Map({