добавил отправку variant_map и красоты немножко

This commit is contained in:
2023-01-30 19:09:33 +07:00
parent 1327186099
commit b95d3e4680
2 changed files with 14 additions and 11 deletions
+11 -9
View File
@@ -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")
+3 -2
View File
@@ -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())