';
}
infoWindow.setContent(content);
}).catch(
(error) => {
if(error.response.status == 404) {
smot.fileFetched = true;
let locationString = '';
if(smot.street) {
locationString += smot.street;
if(smot.city) {
locationString += ', ';
}
}
if(smot.city) {
locationString += smot.city + ' ';
}
locationString += smot.zipCode ?? '';
var content =
'
';
}
infoWindow.setContent(content);
}
);
}
function calculateMapCenter(coords) {
if (coords.length === 1) {
return coords[0];
}
let x = 0.0;
let y = 0.0;
let z = 0.0;
let length = 0;
for (const coord of coords) {
if (coord.lat() !== 0 && coord.lng() !== 0) {
length += 1;
const latitude = coord.lat() * Math.PI / 180;
const longitude = coord.lng() * Math.PI / 180;
x += Math.cos(latitude) * Math.cos(longitude);
y += Math.cos(latitude) * Math.sin(longitude);
z += Math.sin(latitude);
}
}
const total = length;
x = x / total;
y = y / total;
z = z / total;
const centralLongitude = Math.atan2(y, x);
const centralSquareRoot = Math.sqrt(x * x + y * y);
const centralLatitude = Math.atan2(z, centralSquareRoot);
return { lat: centralLatitude * 180 / Math.PI, lng: centralLongitude * 180 / Math.PI };
}