Custom Geolocation Input

Hi everyone,

I just finished implementing a custom Observable Input to obtain the user’s geographic location (latitude and longitude) using the Geolocation API, it might be useful for incorporating the user’s location on maps and other applications. Here is the notebook:

I would appreciate any feedback if you have it. Happy holidays!

1 Like

Very cool!

I had been thinking about this sort of localized input for a while. When I have more time, I’ll try to find the one or two other notebooks to implement similar in case you’re interested to compare.

A bit differently… I was also talking with Saneef about how these global maps are often far too ‘distant’ to be interesting for geolocation. We ideated a bit on how to localize map areas… With the idea of eventually merging a feature such as you implement here. In case you’re interested:

1 Like

As promised, I reached back to 2018 and found the implementation I remembered:

And a fork of the original with some embellishments:

Your approach is more elaborate, which is well appreciated. Nice work incorporating Plot to render the output!

1 Like

That’s a good alternative approach! I liked that the promise just executes and doesn’t need to wait for the user to click the button every time the page loads.

I agree that knowing the precise location of the user is not super useful on maps representing large areas, in my case, I needed the location to calculate the sunset and sunrise times (I wanted to know how much more or less daylight I will get tomorrow, but I started the experiment too close to the Winter solstice, when the difference is minimal). Thanks for sharing your notebooks!

1 Like