#108 How to use the Browser Geolocation API with Rails
Another geolocation episode!
In previous episodes we learnt to get COORDINATES based on address, and place coordinates on a map.
Now, we will learn to get a users' accurate geolocation based on browser Geolocation API. It is supported by any browser!
We will integrate Geolocation into a Rails app with StimulusJS.
Warning! Asking for access to the location on page load will result in most of your users rejecting access.
Blogpost for this video: https://blog.corsego.com/stimulus-get-browser-location
Episode source code: https://github.com/corsego/108-geolocation-api/commit/9aed77ce811492a16e8c78d1dccb74106c531b2b
P.S. what do you think about my new setup π? That's actually the reason I did the few previous episodes without showing face π
0:00 Geocoding and maps recap
0:35 Example search by current location
1:08 Browser Geolocation API
1:40 Stimulus Geolocation Controller
4:04 Button to get location
5:10 Search near me (use browser coordinates in query)
6:40 Works! DEMO
7:18 Geolocation accuracy problems?!
0
Featured in playlists
![#106 How to use gem Geocoder, GPS coordinates, distance calculation, map markers](https://superails.com/rails/active_storage/representations/redirect/eyJfcmFpbHMiOnsiZGF0YSI6MTgxMywicHVyIjoiYmxvYl9pZCJ9fQ==--fa5854971fac389163e676e7b0b7e156f2cc91a3/eyJfcmFpbHMiOnsiZGF0YSI6eyJmb3JtYXQiOiJqcGciLCJyZXNpemVfdG9fbGltaXQiOls0MDAsNjAwXX0sInB1ciI6InZhcmlhdGlvbiJ9fQ==--2d7cd3a4d9675c7f4c17dad7856d799792bd3595/maxresdefault.jpg)
![#107 How to display locations on a map with Mapbox API and gem Mapkick like AirBnB](https://superails.com/rails/active_storage/representations/redirect/eyJfcmFpbHMiOnsiZGF0YSI6MTgzOSwicHVyIjoiYmxvYl9pZCJ9fQ==--40f3c2cf7034cb0bfd4b3cf58b48de87cf84a0c1/eyJfcmFpbHMiOnsiZGF0YSI6eyJmb3JtYXQiOiJqcGciLCJyZXNpemVfdG9fbGltaXQiOls0MDAsNjAwXX0sInB1ciI6InZhcmlhdGlvbiJ9fQ==--2d7cd3a4d9675c7f4c17dad7856d799792bd3595/maxresdefault.jpg)
![#108 How to use the Browser Geolocation API with Rails](https://superails.com/rails/active_storage/representations/redirect/eyJfcmFpbHMiOnsiZGF0YSI6MTg3MSwicHVyIjoiYmxvYl9pZCJ9fQ==--dd678d29d1065aaf26bb39c50fb4f1c877d75ad1/eyJfcmFpbHMiOnsiZGF0YSI6eyJmb3JtYXQiOiJqcGciLCJyZXNpemVfdG9fbGltaXQiOls0MDAsNjAwXX0sInB1ciI6InZhcmlhdGlvbiJ9fQ==--2d7cd3a4d9675c7f4c17dad7856d799792bd3595/maxresdefault.jpg)