Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
Hold on, fixed it. Works perfect. Good luck
To determine the exact address from the coordinates received from the user, use dadata
import dadata
from telebot.types import InlineKeyboardMarkup, InlineKeyboardButton
from telebot import types #для создания клавиатуры
@bot.message_handler(commands=['start'])
def start_msg(message):
#Клавиатура Geo, отправка геолакации
Geo = types.ReplyKeyboardMarkup(True, True)
button_geo = types.KeyboardButton("Отправить местоположение", request_location=True)
Geo.add(button_geo)
#Создаём объект закрытия кастомной клавиатуры
Geo_close = types.ReplyKeyboardRemove()
bot.send_message(message.chat.id, 'Поделитесь местоположением или введите адрес', reply_markup=buttons.Geo )
#------------------------------------Определение адреса юзера-----------------------------------
@bot.message_handler( content_types=["location"])
def location(message):
if message.location is not None:
#Получили координаты юзера, после отправки местоположения
print(message.location)
print("latitude: %s; longitude: %s" % (message.location.latitude, message.location.longitude))
#С помощью координат определили точный адрес юзера
dadata = Dadata(‘ключ, полученный на сайте Dadata')
full_addres = dadata.geolocate(name="address",lat=message.location.latitude, lon=message.location.longitude)
bot.send_message(message.chat.id, f'Текущий адрес: {full_addres[0]["value"]}', reply_markup = buttons.Geo_close )
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question