добавил отправку variant_map и красоты немножко
This commit is contained in:
@@ -1,20 +1,22 @@
|
|||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
import requests
|
import requests
|
||||||
from PIL import Image
|
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 = {
|
params = {
|
||||||
"ll": ",".join([str(cords[0]), str(cords[1])]),
|
"ll": ",".join([str(cords[0]), str(cords[1])]),
|
||||||
"spn": ",".join([str(delta), str(delta)]),
|
"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(
|
Image.open(BytesIO(
|
||||||
response.content)).save("image.png")
|
response.content)).save("image.png")
|
||||||
|
|||||||
@@ -15,7 +15,8 @@ class Window(QMainWindow):
|
|||||||
self.delta = 0.02
|
self.delta = 0.02
|
||||||
self.lon = 37.530887
|
self.lon = 37.530887
|
||||||
self.lat = 55.703118
|
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.pixmap = QPixmap('image.png')
|
||||||
self.label.setPixmap(self.pixmap)
|
self.label.setPixmap(self.pixmap)
|
||||||
self.label.resize(self.pixmap.width(), self.pixmap.height())
|
self.label.resize(self.pixmap.width(), self.pixmap.height())
|
||||||
@@ -46,7 +47,7 @@ class Window(QMainWindow):
|
|||||||
print(e)
|
print(e)
|
||||||
|
|
||||||
def update(self):
|
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.pixmap = QPixmap('image.png')
|
||||||
self.label.setPixmap(self.pixmap)
|
self.label.setPixmap(self.pixmap)
|
||||||
self.label.resize(self.pixmap.width(), self.pixmap.height())
|
self.label.resize(self.pixmap.width(), self.pixmap.height())
|
||||||
|
|||||||
Reference in New Issue
Block a user