You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Im trayin to represent a polygon in the map. But when I do so, The size of the polygon in the map is so little. I need a way to define a bounding box in the map, or a zoom level, so I can the the polygon bigger.
Here is the code:
import staticmaps
context = staticmaps.Context()
context.set_tile_provider(staticmaps.tile_provider_OSM)
polygon = [
(11.946898955783189, -86.1092862482307 ),
(11.947196373156675, -86.10915988584337 ),
(11.947196373156675, -86.10896210123707),
(11.946897164111272, -86.1088650402729),
(11.946898955783189, -86.1092862482307)
]
context.add_object(
staticmaps.Area(
[staticmaps.create_latlng(lat, lng) for lat, lng in polygon],
fill_color=staticmaps.parse_color("#00FF003F"),
width=2,
color=staticmaps.BLUE,
)
)
# render non-anti-aliased png
image = context.render_pillow(800, 500)
image.save("polygon.pillow.png")
# render anti-aliased png (this only works if pycairo is installed)
image = context.render_cairo(800, 500)
image.write_to_png("polygon.cairo.png")
# render svg
svg_image = context.render_svg(800, 500)
with open("polygon.svg", "w", encoding="utf-8") as f:
svg_image.write(f, pretty=True)
The text was updated successfully, but these errors were encountered:
the zoom should be determined automatically - in Your case it is calculated to 15.
Instead, you can set the zoom "manually" with context.set_zoom(), e.g.
...
staticmaps.context.add_object(
staticmaps.Area(
[staticmaps.create_latlng(lat, lng) for lat, lng in polygon],
fill_color=staticmaps.parse_color("#00FF003F"),
width=2,
color=staticmaps.BLUE,
)
)
staticmaps.context.set_zoom(17)
...
Im trayin to represent a polygon in the map. But when I do so, The size of the polygon in the map is so little. I need a way to define a bounding box in the map, or a zoom level, so I can the the polygon bigger.
Here is the code:
The text was updated successfully, but these errors were encountered: