Skip to content

Commit

Permalink
Allow posts to define zoom level
Browse files Browse the repository at this point in the history
  • Loading branch information
pwhittlesea committed Sep 28, 2024
1 parent 5ea6cbb commit 1f6f8d2
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 57 deletions.
5 changes: 4 additions & 1 deletion .generate_maps.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def bounds(self) -> s2sphere.LatLngRect:
def extra_pixel_bounds(self) -> staticmaps.PixelBoundsT:
w = len(self._text) * self._font_size
h = self._font_size
return (int(-w / 2), int(-h / 2), int(w / 2), int(h / 2))
return (int(w / 2), int(h / 2), int(w / 2), int(h / 2))

def render_svg(self, renderer: staticmaps.SvgRenderer) -> None:
x, y = renderer.transformer().ll2pixel(self.latlng())
Expand Down Expand Up @@ -111,6 +111,9 @@ def render_svg(self, renderer: staticmaps.SvgRenderer) -> None:
for label in labels:
context.add_object(label)

if "zoom" in post_map:
context.set_zoom(int(post_map["zoom"]))

map_name = post_map["name"]
map_path = f"{IMAGE_DIR}/{map_name}.svg"
exists_already = os.path.isfile(map_path)
Expand Down
2 changes: 1 addition & 1 deletion _includes/map.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% assign point_names = "Unknown" | split: "," %}
{% for map in page.maps %}
{% if map.name == include.name %}
{% assign point_names = map.points | map: "name" %}
{% assign point_names = map.points | map: "name" | compact %}
{% endif %}
{% endfor %}

Expand Down
Loading

0 comments on commit 1f6f8d2

Please sign in to comment.