Added option to get user location directly from the app

This commit is contained in:
Paweł Malak 2022-02-14 13:58:57 +01:00
parent 2d5cce9fdb
commit 76dc3c44c8
3 changed files with 18 additions and 11 deletions

View file

@ -1,4 +1,5 @@
### v2.2.2 (2022-02-TBA)
- Added option to get user location directly from the app ([#287](https://github.com/pawelmalak/flame/issues/287))
- Fixed bug with local search not working when using prefix ([#289](https://github.com/pawelmalak/flame/issues/289))
- Fixed bug with app description not updating when using custom icon ([#310](https://github.com/pawelmalak/flame/issues/310))
- Changed some of the settings tabs

View file

@ -82,6 +82,19 @@ export const WeatherSettings = (): JSX.Element => {
});
};
// Get user location
const getLocation = () => {
window.navigator.geolocation.getCurrentPosition(
({ coords: { latitude, longitude } }) => {
setFormData({
...formData,
lat: latitude,
long: longitude,
});
}
);
};
return (
<form onSubmit={(e) => formSubmitHandler(e)}>
<SettingsHeadline text="API" />
@ -120,15 +133,8 @@ export const WeatherSettings = (): JSX.Element => {
step="any"
lang="en-150"
/>
<span>
You can use
<a
href="https://www.latlong.net/convert-address-to-lat-long.html"
target="blank"
>
{' '}
latlong.net
</a>
<span onClick={getLocation}>
<a href="#">Click to get current location</a>
</span>
</InputGroup>

View file

@ -23,7 +23,7 @@
.InputGroup span {
font-size: 12px;
color: var(--color-primary)
color: var(--color-primary);
}
.InputGroup span a {
@ -37,4 +37,4 @@
.InputGroup textarea {
resize: none;
height: 50vh;
}
}