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?!