python - Kivy Mapview - 无法加载集成地图
问题描述
我目前正在尝试使用 garden.mapview 模块在 kivy 中显示地图。
到目前为止,这是我的代码:
Python:
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.screenmanager import ScreenManager, Screen
from mapview import *
class WeatherRoot(ScreenManager, BoxLayout):
pass
class RegisterPage(Screen, BoxLayout):
pass
class WeatherApp(App):
pass
class Map(MapView):
try:
mapview = MapView(zoom=1, lat=67, lon=42, cache_dir="cache")
except:
print(1)
if __name__ == "__main__":
WeatherApp().run()
基维:
WeatherRoot:
<WeatherRoot>:
RegisterPage:
<RegisterPage>:
BoxLayout:
padding: [100, 50, 100, 50]
Map:
id: map
zoom: 2
lat: 67
lon: 42
TextInput:
font_size: 30
运行此代码时,屏幕上会显示以下内容:
然后我收到以下错误:
requests.exceptions.ConnectTimeout: HTTPConnectionPool(host='a.tile.openstreetmap.org', port=80): Max retries exceeded with url: /2/3/1.png (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0x000001AE5C370D68>, 'Connection to a.tile.openstreetmap.org timed out. (connect timeout=5)'))
我是 mapview 模块的新手,我无法在互联网上找到任何答案。
我该如何解决这个错误?
提前致谢。