-
Notifications
You must be signed in to change notification settings - Fork 29
Open
Description
hi
How can I access the client's location
Whether through adminui or javascript
like this in nicegui
from nicegui import ui
async def show_location():
response = await ui.run_javascript('''
return await new Promise((resolve, reject) => {
if (!navigator.geolocation) {
reject(new Error('Geolocation is not supported by your browser'));
} else {
navigator.geolocation.getCurrentPosition(
(position) => {
resolve({
latitude: position.coords.latitude,
longitude: position.coords.longitude,
});
},
() => {
reject(new Error('Unable to retrieve your location'));
}
);
}
});
''', timeout=5.0)
ui.notify(f'Your location is {response["latitude"]}, {response["longitude"]}')
ui.button('Show location', on_click=show_location)
ui.run()
Metadata
Metadata
Assignees
Labels
No labels