nakas Claude commited on
Commit
1adad60
Β·
1 Parent(s): fe7643c

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>

Files changed (1) hide show
  1. app.py +52 -11
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 7: Map refreshed to ensure proper particle rendering");
266
  }}, 500);
267
 
268
  console.log("========================================");
269
  console.log("βœ… SUCCESS: Real ECMWF wind particles active!");
270
- console.log("Particles are now geographically locked and won't move when panning/zooming");
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 geographically locked particles**
322
 
323
  βœ… **Real ECMWF-style wind data** (fetched from reliable sources)
324
- βœ… **Geographically locked particles** (stay in place when panning/zooming)
 
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
- ### 🌍 Real Data Features:
346
  - **Live wind patterns** from meteorological sources
347
- - **Global coverage** with realistic wind flows
348
- - **Geographic locking** - particles stay positioned correctly
349
  - **Professional quality** matching weather services
350
 
351
- ### πŸ” Browser Console (F12):
352
- - "🌍 REAL ECMWF WIND PARTICLE INITIALIZATION"
353
- - "βœ… Real ECMWF wind particles active!"
354
- - Data source and time information
 
 
 
 
 
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):