You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

39 lines
1.2 KiB

# https://github.com/flopp/py-staticmaps
import staticmaps
from typing import NamedTuple
class CardMarker(NamedTuple):
lat: float
lon: float
imagefile: str | None
name: str
def make_map_icons(markers: list[CardMarker], path: str):
context = staticmaps.Context()
context.set_tile_provider(staticmaps.tile_provider_OSM)
for m in markers:
pos = staticmaps.create_latlng(m.lat, m.lon)
if m.imagefile is not None:
context.add_object(staticmaps.ImageMarker(pos, m.imagefile, 0, 0))
else:
context.add_object(staticmaps.Marker(pos, color=staticmaps.GREEN, size=12))
# render anti-aliased png (this only works if pycairo is installed)
image = context.render_cairo(500, 500)
image.write_to_png(path + ".png")
def make_map_icon(lat: float, long: float, path: str):
context = staticmaps.Context()
context.set_tile_provider(staticmaps.tile_provider_OSM)
frankfurt = staticmaps.create_latlng(lat, long)
context.add_object(staticmaps.Marker(frankfurt, color=staticmaps.GREEN, size=12))
# render anti-aliased png (this only works if pycairo is installed)
image = context.render_cairo(500, 500)
image.write_to_png(path + ".png")