new features to radar

This commit is contained in:
Pranshul committed 2024-11-27 22:07:09 +05:30
1 parent d09ae196e3
commit 0f166aa9d7
1 file changed
+127
+127
View File
@@ -200,6 +200,57 @@
z-index: 1;
}
.custom-tooltip {
background-color: #3d322f;
border-color: #3d322f;
z-index: 436;
border-radius: 18px;
}
.leaflet-tooltip-right:before {
border-right-color: #a08c87;
}
.leaflet-tooltip-left:before {
border-left-color: #a08c87;
}
.leaflet-tooltip-top:before {
border-top-color: #a08c87;
}
.leaflet-tooltip-bottom:before {
border-bottom-color: #a08c87;
}
.custom-tooltip .content_holder_weather{
height: 50px;
max-width: 150px;
padding: 10px;
padding-top: 0;
padding-bottom: 0;
}
.custom-tooltip .content_holder_weather p{
width: 100%;
overflow: hidden;
text-overflow: ellipsis;
font-family: var(--outfit);
font-size: 16px;
color: #d8c2bc;
white-space: nowrap;
}
.custom-tooltip .content_holder_weather div{
display: flex;
align-items: center;
color: #f1dfda;
gap: 10px;
font-family: var(--google-mid);
padding-top: 5px;
padding-bottom: 5px;
}
.custom-tooltip .content_holder_weather div img{
width: 20px;
height: 20px;
}
</style>
</head>
@@ -412,6 +463,82 @@ const AppLanguageCodeValue = localStorage.getItem('AppLanguageCode');
}
});
const savedLocations = JSON.parse(localStorage.getItem('savedLocations')) || [];
const selectedProvider = localStorage.getItem("selectedMainWeatherProvider")
let alldata
savedLocations.forEach((locationsData) => {
let currentLocationData = locationsData.locationName;
let weatherData;
let locationWeatherCondition;
let icon
if (selectedProvider === 'Met norway' ||
(localStorage.getItem('ApiForAccu') && selectedProvider === 'Accuweather')) {
weatherData = JSON.parse(localStorage.getItem(`WeatherDataOpenMeteo_${currentLocationData}`));
} else if (selectedProvider === 'meteoFrance') {
weatherData = JSON.parse(localStorage.getItem(`WeatherDataMeteoFrance_${currentLocationData}`));
} else if (selectedProvider === 'dwdGermany') {
weatherData = JSON.parse(localStorage.getItem(`WeatherDataDWDGermany_${currentLocationData}`));
} else if (selectedProvider === 'noaaUS') {
weatherData = JSON.parse(localStorage.getItem(`WeatherDataNOAAUS_${currentLocationData}`));
} else if (selectedProvider === 'ecmwf') {
weatherData = JSON.parse(localStorage.getItem(`WeatherDataECMWF_${currentLocationData}`));
} else if (selectedProvider === 'ukMetOffice') {
weatherData = JSON.parse(localStorage.getItem(`WeatherDataukMetOffice_${currentLocationData}`));
} else if (selectedProvider === 'jmaJapan') {
weatherData = JSON.parse(localStorage.getItem(`WeatherDataJMAJapan_${currentLocationData}`));
} else if (selectedProvider === 'gemCanada') {
weatherData = JSON.parse(localStorage.getItem(`WeatherDatagemCanada_${currentLocationData}`));
} else if (selectedProvider === 'bomAustralia') {
weatherData = JSON.parse(localStorage.getItem(`WeatherDatabomAustralia_${currentLocationData}`));
} else if (selectedProvider === 'cmaChina') {
weatherData = JSON.parse(localStorage.getItem(`WeatherDatacmaChina_${currentLocationData}`));
} else if (selectedProvider === 'knmiNetherlands') {
weatherData = JSON.parse(localStorage.getItem(`WeatherDataknmiNetherlands_${currentLocationData}`));
} else if (selectedProvider === 'dmiDenmark') {
weatherData = JSON.parse(localStorage.getItem(`WeatherDatadmiDenmark_${currentLocationData}`));
} else {
weatherData = JSON.parse(localStorage.getItem(`WeatherDataOpenMeteo_${currentLocationData}`));
}
if (weatherData) {
locationWeatherCondition = getWeatherLabelInLangNoAnim(
weatherData.current.weather_code,
weatherData.current.is_day,
getTranslationByLang(localStorage.getItem('AppLanguageCode'))
);
icon = GetWeatherIcon(weatherData.current.weather_code, weatherData.current.is_day);
window.L.tooltip({
permanent: true,
opacity: 1,
className: 'custom-tooltip'
})
.setLatLng([locationsData.lat, locationsData.lon])
.setContent(`
<div class="content_holder_weather">
<p>${locationsData.locationName}</p>
<div>
<img src="${icon}">
<span>${locationWeatherCondition}</span>
</div>
</div>
`)
.addTo(map);
} else {
console.warn(`No weather data found for ${currentLocationData}`);
}
});
}