How to geolocate Users?

Hey guys, hope you are having a ball of a day.
Here’s my question I want to geolocate the user on the site and display the location of the user in plain text on my website.

How can I achieve this using corvid?

Thanking you in advance!

https://www.wix.com/corvid/reference/wix-window/getcurrentgeolocation

Hey, J.D thanks for replying!

I want to display the name of the user’s city in the text.

Is there any way that I take the data of the latitudes and the longitudes and somehow use Google Maps API to get the user’s city location??

And the thing I noticed when I used #getcurrentgeolocation is that when I visited my site it pops up notification from the lock beside the domain name which saying (MY SITE’S NAME) WANT’S TO KNOW YOUR LOCATION and the problem I found was, that all the users won’t allow that popup to access their location.

Is there any other way to achieve what I want ?

Again thank you for helping!

There’re 2 ways to know the users location:

  1. To use the device location. For that every decent OS requires user’s consent. It’s imposed by the OS in order to protect the users’ privacy and you have nothing to do about it. And this is the way getcurrentgeolocation() works.

  2. To deduce it from the user IP. In that way no user’s consent is required (from the technical aspect). The downside of this method is that it’s not accurate and it can give you the location of an adjacent city. But it’s OK if you need the location in the country/state level.

In both ways you’ll need to use a third party to get the location name.
For the first method I guess you can install Google Maps npm and use it to get the user’s city.
For the second method there’re several solutions out there.