🔧 Fix location name logic: User determines name, API only provides coordinates
- Removed automatic API location name usage - User input from locationSearch field is used as location name - API search only provides coordinates (latitude/longitude) - User has full control over location naming - Search functionality purely for coordinate lookup
This commit is contained in:
@@ -172,7 +172,7 @@ function toggleTokenFields() {
|
|||||||
|
|
||||||
// Standort automatisch speichern, falls vorhanden
|
// Standort automatisch speichern, falls vorhanden
|
||||||
let locationSaved = false;
|
let locationSaved = false;
|
||||||
const locationName = document.getElementById('realLocationName')?.value || document.getElementById('locationSearch')?.value?.trim();
|
const locationName = document.getElementById('locationSearch')?.value?.trim();
|
||||||
const latitude = document.getElementById('latitude')?.textContent;
|
const latitude = document.getElementById('latitude')?.textContent;
|
||||||
const longitude = document.getElementById('longitude')?.textContent;
|
const longitude = document.getElementById('longitude')?.textContent;
|
||||||
|
|
||||||
@@ -331,18 +331,8 @@ function toggleTokenFields() {
|
|||||||
const lat = parseFloat(location.lat);
|
const lat = parseFloat(location.lat);
|
||||||
const lon = parseFloat(location.lon);
|
const lon = parseFloat(location.lon);
|
||||||
|
|
||||||
// Echten Standortnamen aus der API speichern
|
// Der Name wird vom User bestimmt - nur Koordinaten aus der API verwenden
|
||||||
const realLocationName = location.display_name || location.name || locationInput;
|
// Kein verstecktes Feld nötig, da der User den Namen selbst eingibt
|
||||||
|
|
||||||
// Verstecktes Feld für echten Standortnamen erstellen/aktualisieren
|
|
||||||
let locationNameField = document.getElementById('realLocationName');
|
|
||||||
if (!locationNameField) {
|
|
||||||
locationNameField = document.createElement('input');
|
|
||||||
locationNameField.type = 'hidden';
|
|
||||||
locationNameField.id = 'realLocationName';
|
|
||||||
document.body.appendChild(locationNameField);
|
|
||||||
}
|
|
||||||
locationNameField.value = realLocationName;
|
|
||||||
|
|
||||||
// Koordinaten anzeigen
|
// Koordinaten anzeigen
|
||||||
updateCoordinates(lat, lon);
|
updateCoordinates(lat, lon);
|
||||||
@@ -353,7 +343,7 @@ function toggleTokenFields() {
|
|||||||
mapContainer.style.display = 'block';
|
mapContainer.style.display = 'block';
|
||||||
|
|
||||||
// Erfolgsmeldung
|
// Erfolgsmeldung
|
||||||
showSuccess(`✅ Standort "${realLocationName}" erfolgreich gefunden! Klicken Sie auf die Karte, um den Pin zu verschieben.`);
|
showSuccess(`✅ Koordinaten für "${locationInput}" erfolgreich gefunden! Klicken Sie auf die Karte, um den Pin zu verschieben.`);
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
showError(`Fehler bei der Standortsuche: ${error.message}`);
|
showError(`Fehler bei der Standortsuche: ${error.message}`);
|
||||||
@@ -473,7 +463,7 @@ function toggleTokenFields() {
|
|||||||
|
|
||||||
// Standort in Datenbank speichern
|
// Standort in Datenbank speichern
|
||||||
async function saveLocationToDatabase() {
|
async function saveLocationToDatabase() {
|
||||||
const locationName = document.getElementById('realLocationName')?.value || document.getElementById('locationSearch').value.trim();
|
const locationName = document.getElementById('locationSearch').value.trim();
|
||||||
const latitude = document.getElementById('latitude').textContent;
|
const latitude = document.getElementById('latitude').textContent;
|
||||||
const longitude = document.getElementById('longitude').textContent;
|
const longitude = document.getElementById('longitude').textContent;
|
||||||
const saveBtn = document.getElementById('saveLocationBtn');
|
const saveBtn = document.getElementById('saveLocationBtn');
|
||||||
|
|||||||
Reference in New Issue
Block a user