From b95d3e46805504b7feb8c196a0774c94cd57baf0 Mon Sep 17 00:00:00 2001 From: Dmitrium12 Date: Mon, 30 Jan 2023 19:09:33 +0700 Subject: [PATCH] =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20?= =?UTF-8?q?=D0=BE=D1=82=D0=BF=D1=80=D0=B0=D0=B2=D0=BA=D1=83=20variant=5Fma?= =?UTF-8?q?p=20=D0=B8=20=D0=BA=D1=80=D0=B0=D1=81=D0=BE=D1=82=D1=8B=20?= =?UTF-8?q?=D0=BD=D0=B5=D0=BC=D0=BD=D0=BE=D0=B6=D0=BA=D0=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- functions/get_img_map.py | 20 +++++++++++--------- main.py | 5 +++-- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/functions/get_img_map.py b/functions/get_img_map.py index fb7d509..16ef419 100644 --- a/functions/get_img_map.py +++ b/functions/get_img_map.py @@ -1,20 +1,22 @@ from io import BytesIO import requests from PIL import Image -import time - -api_server = "http://static-maps.yandex.ru/1.x/" - -lon = "37.530887" -lat = "55.703118" -def get_img_map(delta, cords): +def get_img_map(delta: float, cords: tuple, variant_map: str) -> None: + """ + Функция обращается к api yandex и создаёт картинку карты по переданным данным + + :param delta: float - разрешение карты + :param cords: tuple - 2 координаты точки + :param variant_map: str - вариант карты + :return: None + """ params = { "ll": ",".join([str(cords[0]), str(cords[1])]), "spn": ",".join([str(delta), str(delta)]), - "l": "map" + "l": variant_map } - response = requests.get(api_server, params=params) + response = requests.get("http://static-maps.yandex.ru/1.x/", params=params) Image.open(BytesIO( response.content)).save("image.png") diff --git a/main.py b/main.py index 5b5befe..b889ed8 100644 --- a/main.py +++ b/main.py @@ -15,7 +15,8 @@ class Window(QMainWindow): self.delta = 0.02 self.lon = 37.530887 self.lat = 55.703118 - get_img_map(self.delta, (self.lon, self.lat)) + self.variant_map = "map" + get_img_map(self.delta, (self.lon, self.lat), self.variant_map) self.pixmap = QPixmap('image.png') self.label.setPixmap(self.pixmap) self.label.resize(self.pixmap.width(), self.pixmap.height()) @@ -46,7 +47,7 @@ class Window(QMainWindow): print(e) def update(self): - get_img_map(self.delta, (self.lon, self.lat)) + get_img_map(self.delta, (self.lon, self.lat), self.variant_map) self.pixmap = QPixmap('image.png') self.label.setPixmap(self.pixmap) self.label.resize(self.pixmap.width(), self.pixmap.height())