With the new maps plugin for bases you can get a nice map view. But getting longitude and latitude for an adress is a hassle. So I made a templter template to do that for me.
the required YAML to make this work is:
straat_huisnummer: Bezuidenhoutseweg 73
postcode: 2594 AC
plaats: Den Haag
land: NL
The used adress is an example.
After rumming the template (insert). It will look like:
straat_huisnummer: Bezuidenhoutseweg 73
postcode: 2594 AC
plaats: Den Haag
land: NL
lat: “52.0833363”
lon: “4.3281949”
coordinaten:
- “52.0833363”
- “4.3281949”
Templater code:
<%* const file = tp.file.find_tfile(tp.file.title); const metadata = app.metadataCache.getFileCache(file)?.frontmatter; if (metadata && metadata.straat_huisnummer && metadata.postcode && metadata.plaats) { const adres = ${metadata.straat_huisnummer}, ${metadata.postcode} ${metadata.plaats}, ${metadata.land || 'NL'}; const url = https://nominatim.openstreetmap.org/search?q=${encodeURIComponent(adres)}&format=json&limit=1; try { const response = await fetch(url, { headers: { ‘User-Agent’: ‘Obsidian Geocoder’ } }); const data = await response.json(); if (data.length > 0) { const lat = parseFloat(data[0].lat).toFixed(7); const lon = parseFloat(data[0].lon).toFixed(7); await app.fileManager.processFrontMatter(file, (fm) => { fm.lat = lat; fm.lon = lon; fm.coordinaten = [lat, lon]; }); new Notice(“✓ Coördinaten toegevoegd!”); } else { new Notice(“✗ Geen coördinaten gevonden voor dit adres”); } } catch (error) { new Notice(“✗ Fout bij geocoding”); console.error(error); } } else { new Notice(“✗ Vul eerst straat_huisnummer, postcode en plaats in”); } _%>
Hope this is useful.
Bas