Skip to content

Commit

Permalink
added mapping date and fixed broken geojson
Browse files Browse the repository at this point in the history
  • Loading branch information
p3t3r67x0 committed Nov 21, 2024
1 parent 952a7ea commit e9255e6
Showing 1 changed file with 34 additions and 5 deletions.
39 changes: 34 additions & 5 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,19 @@ function formatPlaceName(placeName) {
}


function formatDateString(dateString) {
const date = new Date(dateString)

const germanDate = date.toLocaleDateString('de-DE', {
day: 'numeric',
month: 'long',
year: 'numeric'
})

return germanDate
}


function formatToHectar(number) {
let hectar = Number(number) / 10000

Expand All @@ -42,13 +55,23 @@ function renderBiotopeMeta(data) {
map.removeLayer(currentLayer)
}

const feature = JSON.parse(data['geojson'])
const geoJsonData = {
'type': 'FeatureCollection',
'features': [{
'type': 'Feature',
'geometry': {
'type': data['geojson']['type'],
'coordinates': data['geojson']['coordinates']
},
'properties': {}
}]
}

currentLayer = L.geoJSON(feature, {
currentLayer = L.geoJSON(geoJsonData, {
style: {
'color': '#333',
'weight': 2,
'fillOpacity': 0.1
color: '#333',
weight: 2,
fillOpacity: 0.1
}
}).addTo(map)

Expand All @@ -64,6 +87,12 @@ function renderBiotopeMeta(data) {
detailOutput += `<li><strong>Bemerkung</strong><br>${data['description']}</li>`
}

if (data['mapping_date'] !== null) {
const dateString = formatDateString(data['mapping_date'])

detailOutput += `<li><strong>Kartierdatum</strong><br>${dateString}</li>`
}

if (data['mapping_origin'].length > 1) {
detailOutput += `<li><strong>Herkunft</strong><br>${data['mapping_origin']}</li>`
}
Expand Down

0 comments on commit e9255e6

Please sign in to comment.