Getting User's Location from Mobile Device

Hey,

Here’s what I cooked up over a lazy weekend:
Where Am I? (https://where-am-i.anvilapp.net)

First, I built a “Geolocator” custom component. It requests geolocation information (using Javascript in a Custom HTML form), then raises the custom event update_position every time the browser gives it a new position:
https://anvil.works/ide#clone:EFABX52BM4GXXA4Y=2OZE3DVMWSWCXH6NGNLKPKQW

Then, I built the “Where Am I?” app using the Geolocator component. The “Where Am I?” app is pure Python - once you’ve written the custom component to access to low-level browser APIs, you can do the rest with standard Anvil features:
https://anvil.works/ide#clone:XNMSCSRWUFFMUH2X=V5JK6U6BJYYNYQ5SNVFA23NA
(NB once you’ve cloned “Where Am I?”, you’ll have to open its Dependencies menu and select your version of the Geolocator component - otherwise it will complain about a missing/deleted dependency. You will then need to delete and recreate the geolocator_1 component so you’re using your version rather than mine, and re-bind its update_position event.)

6 Likes