isaachwf commited on
Commit
72afff5
·
1 Parent(s): d1e54f6

feat: allow generating poster with no text by leaving fields blank

Browse files
Files changed (2) hide show
  1. app.py +1 -1
  2. 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 "Custom Location"
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
- lat, lon = point
594
- coords_text = (
595
- f"{lat:.4f}° N / {lon:.4f}° E"
596
- if lat >= 0
597
- else f"{abs(lat):.4f}° S / {lon:.4f}° E"
598
- )
599
- if lon < 0:
600
- coords_text = coords_text.replace("E", "W")
601
-
602
- ax.text(
603
- 0.5,
604
- 0.07,
605
- coords_text,
606
- transform=ax.transAxes,
607
- color=THEME["text"],
608
- alpha=0.7,
609
- ha="center",
610
- fontproperties=font_coords,
611
- zorder=11,
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()