We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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()
The text was updated successfully, but these errors were encountered:
No branches or pull requests
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()
The text was updated successfully, but these errors were encountered: