This commit is contained in:
Ly-sec 2025-08-24 16:35:12 +02:00
commit 2917de8b03
3 changed files with 11 additions and 7 deletions

View file

@ -109,8 +109,8 @@ Singleton {
// --------------------------------
function _geocodeLocation(locationName, callback, errorCallback) {
Logger.log("Location", "Geocoding from api.open-meteo.com")
var geoUrl = "https://geocoding-api.open-meteo.com/v1/search?name=" + encodeURIComponent(
Logger.log("Location", "Geocoding location name")
var geoUrl = "https://assets.noctalia.dev/geocode.php?city=" + encodeURIComponent(
locationName) + "&language=en&format=json"
var xhr = new XMLHttpRequest()
xhr.onreadystatechange = function () {
@ -119,8 +119,8 @@ Singleton {
try {
var geoData = JSON.parse(xhr.responseText)
// Logger.logJSON.stringify(geoData))
if (geoData.results && geoData.results.length > 0) {
callback(geoData.results[0].latitude, geoData.results[0].longitude)
if (geoData.lat != null) {
callback(geoData.lat, geoData.lng)
} else {
errorCallback("Location", "could not resolve location name")
}