mirror of
https://github.com/pawelmalak/flame.git
synced 2025-07-23 21:29:37 +02:00
Added option to get user location directly from the app
This commit is contained in:
parent
2d5cce9fdb
commit
76dc3c44c8
3 changed files with 18 additions and 11 deletions
|
@ -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>
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue