Skip to content

Commit 1d0a262

Browse files
committed
Add missing examples file
1 parent 49d2a81 commit 1d0a262

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

examples/tile_providers.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env python
2+
3+
# py-staticmaps
4+
# Copyright (c) 2020 Florian Pigorsch; see /LICENSE for licensing information
5+
6+
import staticmaps
7+
8+
context = staticmaps.Context()
9+
10+
p1 = staticmaps.create_latlng(48.005774, 7.834042)
11+
p2 = staticmaps.create_latlng(47.988716, 7.868804)
12+
p3 = staticmaps.create_latlng(47.985958, 7.824601)
13+
14+
context.add_object(staticmaps.Area([p1, p2, p3, p1], color=staticmaps.RED, fill_color=staticmaps.TRANSPARENT, width=2))
15+
context.add_object(staticmaps.Marker(p1, color=staticmaps.BLUE))
16+
context.add_object(staticmaps.Marker(p2, color=staticmaps.GREEN))
17+
context.add_object(staticmaps.Marker(p3, color=staticmaps.YELLOW))
18+
19+
for name, provider in staticmaps.default_tile_providers.items():
20+
context.set_tile_provider(provider)
21+
22+
# render png
23+
image = context.render_cairo(800, 500)
24+
image.write_to_png(f"provider_{name}.png")
25+
26+
# render svg
27+
svg_image = context.render_svg(800, 500)
28+
with open(f"provider_{name}.svg", "w", encoding="utf-8") as f:
29+
svg_image.write(f, pretty=True)

0 commit comments

Comments
 (0)