Spaces:
Runtime error
Runtime error
Suchinthana
commited on
Commit
Β·
4b1e4e3
1
Parent(s):
8f22ee9
Updating empty map lat long
Browse files
app.py
CHANGED
|
@@ -116,13 +116,17 @@ def generate_static_map(geojson_data, bounds=None):
|
|
| 116 |
# If bounds are provided, set the center of the map
|
| 117 |
center_lat = (bounds[0][0] + bounds[1][0]) / 2
|
| 118 |
center_lng = (bounds[0][1] + bounds[1][1]) / 2
|
| 119 |
-
zoom = 10 # Adjust zoom level as needed
|
| 120 |
-
m.set_center(center_lat, center_lng) #zoom
|
|
|
|
|
|
|
|
|
|
|
|
|
| 121 |
|
| 122 |
# Check if there are no features to avoid an empty map
|
| 123 |
if not geojson_data["features"]:
|
| 124 |
# Add a small invisible marker to prevent rendering error
|
| 125 |
-
m.add_marker(CircleMarker((
|
| 126 |
|
| 127 |
# Process each feature in the GeoJSON
|
| 128 |
for feature in geojson_data["features"]:
|
|
@@ -209,7 +213,7 @@ def handle_query(query):
|
|
| 209 |
"type": "FeatureCollection",
|
| 210 |
"features": [] # Empty map contains no features
|
| 211 |
}
|
| 212 |
-
empty_map_image = generate_static_map(empty_geojson) # Empty map with the same bounds
|
| 213 |
|
| 214 |
# Create the mask
|
| 215 |
difference = np.abs(np.array(map_image.convert("RGB")) - np.array(empty_map_image.convert("RGB")))
|
|
|
|
| 116 |
# If bounds are provided, set the center of the map
|
| 117 |
center_lat = (bounds[0][0] + bounds[1][0]) / 2
|
| 118 |
center_lng = (bounds[0][1] + bounds[1][1]) / 2
|
| 119 |
+
#zoom = 10 # Adjust zoom level as needed
|
| 120 |
+
#m.set_center(center_lat, center_lng) #zoom
|
| 121 |
+
else:
|
| 122 |
+
# Default center and zoom level
|
| 123 |
+
center_lat, center_lng = 0, 0
|
| 124 |
+
#zoom = 1
|
| 125 |
|
| 126 |
# Check if there are no features to avoid an empty map
|
| 127 |
if not geojson_data["features"]:
|
| 128 |
# Add a small invisible marker to prevent rendering error
|
| 129 |
+
m.add_marker(CircleMarker((center_lat, center_lng), '#FFFFFF', 0)) # White marker with size 0
|
| 130 |
|
| 131 |
# Process each feature in the GeoJSON
|
| 132 |
for feature in geojson_data["features"]:
|
|
|
|
| 213 |
"type": "FeatureCollection",
|
| 214 |
"features": [] # Empty map contains no features
|
| 215 |
}
|
| 216 |
+
empty_map_image = generate_static_map(empty_geojson, bounds=bounds) # Empty map with the same bounds
|
| 217 |
|
| 218 |
# Create the mask
|
| 219 |
difference = np.abs(np.array(map_image.convert("RGB")) - np.array(empty_map_image.convert("RGB")))
|