Spaces:
Sleeping
Sleeping
Add instant particle refresh on map interactions
Browse files- Clear and reload particles immediately on pan end (moveend event)
- Clear and reload particles immediately on zoom (zoomend event)
- Clear and reload particles on drag end (dragend event)
- 50ms delay for pan/zoom, 30ms for drag for optimal responsiveness
- Comprehensive console logging for each interaction type
- Update UI to highlight interactive particle refresh features
User experience:
- Pan the map β particles clear and reload instantly
- Zoom in/out β particles refresh immediately
- Drag and release β instant particle update
Matches professional weather visualization behavior
π€ Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
app.py
CHANGED
@@ -259,15 +259,50 @@ def create_wind_map(region="global"):
|
|
259 |
console.log("πΊοΈ STEP 6: Adding velocity layer to map...");
|
260 |
velocityLayer.addTo(map);
|
261 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
262 |
// Force immediate render to ensure particles appear
|
263 |
setTimeout(function() {{
|
264 |
map.invalidateSize();
|
265 |
-
console.log("π STEP
|
266 |
}}, 500);
|
267 |
|
268 |
console.log("========================================");
|
269 |
console.log("β
SUCCESS: Real ECMWF wind particles active!");
|
270 |
-
console.log("Particles
|
271 |
console.log("========================================");
|
272 |
|
273 |
}} catch (error) {{
|
@@ -318,10 +353,11 @@ with gr.Blocks(title="ECMWF Wind Particle Visualization") as app:
|
|
318 |
|
319 |
gr.Markdown("""
|
320 |
# π ECMWF Wind Particle Visualization
|
321 |
-
**Real wind data with
|
322 |
|
323 |
β
**Real ECMWF-style wind data** (fetched from reliable sources)
|
324 |
-
β
**
|
|
|
325 |
β
**Professional visualization** matching Windy.com quality
|
326 |
""")
|
327 |
|
@@ -342,16 +378,21 @@ with gr.Blocks(title="ECMWF Wind Particle Visualization") as app:
|
|
342 |
)
|
343 |
|
344 |
gr.Markdown("""
|
345 |
-
### π
|
346 |
- **Live wind patterns** from meteorological sources
|
347 |
-
- **
|
348 |
-
- **
|
349 |
- **Professional quality** matching weather services
|
350 |
|
351 |
-
### π Browser Console (F12):
|
352 |
-
- "
|
353 |
-
- "
|
354 |
-
-
|
|
|
|
|
|
|
|
|
|
|
355 |
""")
|
356 |
|
357 |
with gr.Column(scale=3):
|
|
|
259 |
console.log("πΊοΈ STEP 6: Adding velocity layer to map...");
|
260 |
velocityLayer.addTo(map);
|
261 |
|
262 |
+
// Add event listeners for particle refresh on map interactions
|
263 |
+
console.log("π― STEP 7: Setting up map interaction event listeners...");
|
264 |
+
|
265 |
+
// Clear and reload particles on pan end
|
266 |
+
map.on('moveend', function() {{
|
267 |
+
console.log("π PAN EVENT: Clearing and reloading particles...");
|
268 |
+
map.removeLayer(velocityLayer);
|
269 |
+
setTimeout(function() {{
|
270 |
+
velocityLayer.addTo(map);
|
271 |
+
console.log("β
PAN RELOAD: Particles refreshed after pan");
|
272 |
+
}}, 50);
|
273 |
+
}});
|
274 |
+
|
275 |
+
// Clear and reload particles on zoom end
|
276 |
+
map.on('zoomend', function() {{
|
277 |
+
console.log("π ZOOM EVENT: Clearing and reloading particles...");
|
278 |
+
map.removeLayer(velocityLayer);
|
279 |
+
setTimeout(function() {{
|
280 |
+
velocityLayer.addTo(map);
|
281 |
+
console.log("β
ZOOM RELOAD: Particles refreshed after zoom");
|
282 |
+
}}, 50);
|
283 |
+
}});
|
284 |
+
|
285 |
+
// Also handle drag end specifically
|
286 |
+
map.on('dragend', function() {{
|
287 |
+
console.log("π±οΈ DRAG END: Quick particle refresh...");
|
288 |
+
map.removeLayer(velocityLayer);
|
289 |
+
setTimeout(function() {{
|
290 |
+
velocityLayer.addTo(map);
|
291 |
+
console.log("β
DRAG RELOAD: Particles refreshed after drag");
|
292 |
+
}}, 30);
|
293 |
+
}});
|
294 |
+
|
295 |
+
console.log("π― Event listeners added: moveend, zoomend, dragend");
|
296 |
+
|
297 |
// Force immediate render to ensure particles appear
|
298 |
setTimeout(function() {{
|
299 |
map.invalidateSize();
|
300 |
+
console.log("π STEP 8: Map refreshed to ensure proper particle rendering");
|
301 |
}}, 500);
|
302 |
|
303 |
console.log("========================================");
|
304 |
console.log("β
SUCCESS: Real ECMWF wind particles active!");
|
305 |
+
console.log("Particles will clear and reload on pan/zoom interactions");
|
306 |
console.log("========================================");
|
307 |
|
308 |
}} catch (error) {{
|
|
|
353 |
|
354 |
gr.Markdown("""
|
355 |
# π ECMWF Wind Particle Visualization
|
356 |
+
**Real wind data with instant particle refresh on interaction**
|
357 |
|
358 |
β
**Real ECMWF-style wind data** (fetched from reliable sources)
|
359 |
+
β
**Instant particle refresh** (clears and reloads on pan/zoom)
|
360 |
+
β
**Interactive responsiveness** (particles update immediately on map interaction)
|
361 |
β
**Professional visualization** matching Windy.com quality
|
362 |
""")
|
363 |
|
|
|
378 |
)
|
379 |
|
380 |
gr.Markdown("""
|
381 |
+
### π Interactive Features:
|
382 |
- **Live wind patterns** from meteorological sources
|
383 |
+
- **Instant particle refresh** on pan/zoom interactions
|
384 |
+
- **Real-time responsiveness** - particles clear and reload immediately
|
385 |
- **Professional quality** matching weather services
|
386 |
|
387 |
+
### π Browser Console (F12) shows:
|
388 |
+
- "π PAN EVENT: Clearing and reloading particles..."
|
389 |
+
- "π ZOOM EVENT: Clearing and reloading particles..."
|
390 |
+
- "β
PAN/ZOOM RELOAD: Particles refreshed"
|
391 |
+
|
392 |
+
### π― Try it:
|
393 |
+
- **Pan the map** β particles clear and reload instantly
|
394 |
+
- **Zoom in/out** β particles refresh immediately
|
395 |
+
- **Drag and release** β instant particle update
|
396 |
""")
|
397 |
|
398 |
with gr.Column(scale=3):
|