Ruby on Rails #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?!
Comments
Recommended based on what you are watching now

Ruby on Rails #100 Browser tab title notifications

Ruby on Rails #145 StimulusJS Hotkeys without any external libraries. It just works!

Rails 7 #119 Trello Clone. Advanced Drag and Drop Sortable Lists with Hotwire

Rails World - Hotwire Cookbook - Yaroslav Shmarov: Common Uses, Essential Patterns & Best Practices -
