L
L
Lorents2021-02-07 16:04:31
Geolocation
Lorents, 2021-02-07 16:04:31

How to determine the city of the user?

Good afternoon!
Tell me how you can determine the city of the user on the site with high accuracy.

I found three options:
Yandex.Locator is free (I don’t understand why it’s free). As I understood it is necessary to make a request from the server?
Yandex - JavaScript API and Geocoder, quite expensive
Google Maps Geolocation API - they give $ 200 a month for free, as I understand it, you have to pay in excess of this limit

Tell me, what other options are there, you can pay, but with high accuracy?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladimir Korotenko, 2021-02-07
@firedragon

Yes, nothing on the desktop and almost 100% on the mobile phone.
With this, almost everyone reconciled and offer the city to choose.
Separate hello to Tinder, he defines me as a bastard in Kharkov, then in Krasnodar and asks for money for the second region :)

A
Alexander Cheremkhin, 2021-02-07
@Che603000

The task is vague - "with high accuracy" is very vague.
Standard Approach
First, try the browser's Geolocation API. It's good enough to define a city.
https://developer.mozilla.org/en/docs/Web/API/Geol...
Get user coordinates. The browser itself will figure out which device it is working on and will give you coordinates with an accuracy that depends on the capabilities of the hardware.
Then getting the address by coordinates is the task of reverse geocoding.
A bunch of services. For example: https://dadata.ru/api/geolocate/
For accuracy at the level - to determine the city, it will work.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question