Spaces:
Running
Running
feat: allow generating poster with no text by leaving fields blank
Browse files- app.py +1 -1
- create_map_poster.py +22 -20
app.py
CHANGED
|
@@ -198,7 +198,7 @@ def generate_poster(
|
|
| 198 |
return None, "❌ 请输入有效的经纬度"
|
| 199 |
|
| 200 |
coords = (float(custom_lat), float(custom_lon))
|
| 201 |
-
display_city = custom_city_name if custom_city_name else "
|
| 202 |
display_country = custom_country_name if custom_country_name else ""
|
| 203 |
|
| 204 |
# Determine output filename component
|
|
|
|
| 198 |
return None, "❌ 请输入有效的经纬度"
|
| 199 |
|
| 200 |
coords = (float(custom_lat), float(custom_lon))
|
| 201 |
+
display_city = custom_city_name if custom_city_name else ""
|
| 202 |
display_country = custom_country_name if custom_country_name else ""
|
| 203 |
|
| 204 |
# Determine output filename component
|
create_map_poster.py
CHANGED
|
@@ -590,26 +590,28 @@ def create_poster(
|
|
| 590 |
)
|
| 591 |
|
| 592 |
# Coordinates (Third line, smaller)
|
| 593 |
-
|
| 594 |
-
|
| 595 |
-
|
| 596 |
-
|
| 597 |
-
|
| 598 |
-
|
| 599 |
-
|
| 600 |
-
|
| 601 |
-
|
| 602 |
-
|
| 603 |
-
|
| 604 |
-
|
| 605 |
-
|
| 606 |
-
|
| 607 |
-
|
| 608 |
-
|
| 609 |
-
|
| 610 |
-
|
| 611 |
-
|
| 612 |
-
|
|
|
|
|
|
|
| 613 |
|
| 614 |
# --- ATTRIBUTION (bottom right) ---
|
| 615 |
attr_font = font_sub_base.copy()
|
|
|
|
| 590 |
)
|
| 591 |
|
| 592 |
# Coordinates (Third line, smaller)
|
| 593 |
+
# Only show if there is at least a title or subtitle, or if specifically desired
|
| 594 |
+
if display_city or display_country:
|
| 595 |
+
lat, lon = point
|
| 596 |
+
coords_text = (
|
| 597 |
+
f"{lat:.4f}° N / {lon:.4f}° E"
|
| 598 |
+
if lat >= 0
|
| 599 |
+
else f"{abs(lat):.4f}° S / {lon:.4f}° E"
|
| 600 |
+
)
|
| 601 |
+
if lon < 0:
|
| 602 |
+
coords_text = coords_text.replace("E", "W")
|
| 603 |
+
|
| 604 |
+
ax.text(
|
| 605 |
+
0.5,
|
| 606 |
+
0.07,
|
| 607 |
+
coords_text,
|
| 608 |
+
transform=ax.transAxes,
|
| 609 |
+
color=THEME["text"],
|
| 610 |
+
alpha=0.7,
|
| 611 |
+
ha="center",
|
| 612 |
+
fontproperties=font_coords,
|
| 613 |
+
zorder=11,
|
| 614 |
+
)
|
| 615 |
|
| 616 |
# --- ATTRIBUTION (bottom right) ---
|
| 617 |
attr_font = font_sub_base.copy()
|