-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to set bounding box to map? #30
Comments
Hello @eruiz67 the zoom should be determined automatically - in Your case it is calculated to 15.
Cheers, |
def render_cairo(self, width: int, height: int, bounds: LatLngRect) -> typing.Any:
"""Render area using cairo
:param width: width of static map
:type width: int
:param height: height of static map
:type height: int
:return: cairo image
:rtype: cairo.ImageSurface
:raises RuntimeError: raises runtime error if cairo is not available
:raises RuntimeError: raises runtime error if map has no center and zoom
"""
center, zoom = self.determine_center_zoom(width, height)
if center is None or zoom is None:
raise RuntimeError("Cannot render map without center/zoom.")
trans = Transformer(width, height, zoom, center, self._tile_provider.tile_size())
x, y = trans.ll2pixel(bounds.lo())
a, b = trans.ll2pixel(bounds.hi())
renderer = CairoRenderer(trans)
renderer.render_background(self._background_color)
renderer.render_tiles(self._fetch_tile)
renderer.render_objects(self._objects)
renderer.render_attribution(self._tile_provider.attribution())
return crop_image_surface(renderer.image_surface(), int(x), int(b), int(a-x), int(y-b) )
staticmaps.Context.render_cairo = render_cairo This monkey patch worked for me for the cairo renderer |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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: