Spaces:
Running

File size: 32,399 Bytes
cb778a9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Live Satellite Imagery Viewer</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <script src="https://cdn.jsdelivr.net/npm/leaflet@1.9.4/dist/leaflet.js"></script>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/leaflet@1.9.4/dist/leaflet.css">
    <style>
        #map {
            height: 70vh;
            width: 100%;
            border-radius: 0.5rem;
            box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
        }
        .satellite-layer {
            filter: brightness(1.1) contrast(1.1);
        }
        .timeline-container {
            scrollbar-width: thin;
            scrollbar-color: #4b5563 #1f2937;
        }
        .timeline-container::-webkit-scrollbar {
            height: 8px;
        }
        .timeline-container::-webkit-scrollbar-track {
            background: #1f2937;
            border-radius: 10px;
        }
        .timeline-container::-webkit-scrollbar-thumb {
            background-color: #4b5563;
            border-radius: 10px;
        }
        .loading-spinner {
            border-top-color: #3b82f6;
            animation: spin 1s linear infinite;
        }
        @keyframes spin {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
        }
    </style>
</head>
<body class="bg-gray-900 text-gray-100">
    <div class="container mx-auto px-4 py-8">
        <!-- Header -->
        <header class="mb-8">
            <div class="flex justify-between items-center">
                <div>
                    <h1 class="text-3xl font-bold text-blue-400">OrbitView</h1>
                    <p class="text-gray-400">Live & Historical Satellite Imagery Platform</p>
                </div>
                <div class="flex items-center space-x-4">
                    <button id="loginBtn" class="px-4 py-2 bg-blue-600 hover:bg-blue-700 rounded-lg transition">
                        <i class="fas fa-sign-in-alt mr-2"></i>Sign In
                    </button>
                    <button class="px-4 py-2 bg-gray-700 hover:bg-gray-600 rounded-lg transition">
                        <i class="fas fa-question-circle mr-2"></i>Help
                    </button>
                </div>
            </div>
        </header>

        <!-- Main Content -->
        <main>
            <!-- Search and Controls -->
            <div class="grid grid-cols-1 lg:grid-cols-4 gap-6 mb-6">
                <!-- Search Box -->
                <div class="lg:col-span-3 bg-gray-800 p-4 rounded-lg">
                    <div class="flex">
                        <input type="text" id="locationSearch" placeholder="Search location or coordinates (e.g., 52.52, 13.41)" 
                               class="flex-grow px-4 py-2 bg-gray-700 rounded-l-lg focus:outline-none focus:ring-2 focus:ring-blue-500">
                        <button id="searchBtn" class="px-4 py-2 bg-blue-600 hover:bg-blue-700 rounded-r-lg transition">
                            <i class="fas fa-search"></i>
                        </button>
                    </div>
                    <div class="mt-4 grid grid-cols-2 md:grid-cols-4 gap-3">
                        <button data-location="europe" class="px-3 py-2 bg-gray-700 hover:bg-gray-600 rounded-lg text-sm flex items-center justify-center">
                            <i class="fas fa-globe-europe mr-2"></i>Europe
                        </button>
                        <button data-location="north-america" class="px-3 py-2 bg-gray-700 hover:bg-gray-600 rounded-lg text-sm flex items-center justify-center">
                            <i class="fas fa-globe-americas mr-2"></i>North America
                        </button>
                        <button data-location="asia" class="px-3 py-2 bg-gray-700 hover:bg-gray-600 rounded-lg text-sm flex items-center justify-center">
                            <i class="fas fa-globe-asia mr-2"></i>Asia
                        </button>
                        <button id="currentLocationBtn" class="px-3 py-2 bg-gray-700 hover:bg-gray-600 rounded-lg text-sm flex items-center justify-center">
                            <i class="fas fa-crosshairs mr-2"></i>My Location
                        </button>
                    </div>
                </div>

                <!-- Date and Provider Selection -->
                <div class="bg-gray-800 p-4 rounded-lg">
                    <div class="mb-4">
                        <label class="block text-sm font-medium mb-1">Date Range</label>
                        <div class="flex">
                            <input type="date" id="startDate" class="flex-grow px-2 py-1 bg-gray-700 rounded-l-lg text-sm">
                            <input type="date" id="endDate" class="flex-grow px-2 py-1 bg-gray-700 rounded-r-lg text-sm">
                        </div>
                    </div>
                    <div>
                        <label class="block text-sm font-medium mb-1">Imagery Source</label>
                        <select id="providerSelect" class="w-full px-2 py-1 bg-gray-700 rounded-lg text-sm">
                            <option value="maxar">Maxar (Premium)</option>
                            <option value="planet">Planet Labs</option>
                            <option value="sentinel">Sentinel-2</option>
                            <option value="landsat">Landsat 9</option>
                            <option value="up42">UP42 Marketplace</option>
                        </select>
                    </div>
                    <button id="applyBtn" class="mt-4 w-full py-2 bg-blue-600 hover:bg-blue-700 rounded-lg transition">
                        <i class="fas fa-sync-alt mr-2"></i>Apply Filters
                    </button>
                </div>
            </div>

            <!-- Map Container -->
            <div class="relative mb-6">
                <div id="map"></div>
                <div id="loadingOverlay" class="absolute inset-0 bg-black bg-opacity-50 flex items-center justify-center hidden">
                    <div class="loading-spinner h-12 w-12 border-4 border-gray-600 rounded-full"></div>
                </div>
            </div>

            <!-- Timeline -->
            <div class="bg-gray-800 p-4 rounded-lg mb-6">
                <h3 class="text-lg font-medium mb-3">Historical Timeline</h3>
                <div class="timeline-container overflow-x-auto pb-2">
                    <div id="timelineItems" class="flex space-x-2" style="min-width: max-content;">
                        <!-- Timeline items will be added here dynamically -->
                    </div>
                </div>
            </div>

            <!-- Imagery Details -->
            <div class="grid grid-cols-1 lg:grid-cols-3 gap-6">
                <!-- Current Image Details -->
                <div class="bg-gray-800 p-4 rounded-lg">
                    <h3 class="text-lg font-medium mb-3">Current Image Details</h3>
                    <div class="space-y-2">
                        <div class="flex justify-between">
                            <span class="text-gray-400">Provider:</span>
                            <span id="currentProvider" class="font-medium">Maxar</span>
                        </div>
                        <div class="flex justify-between">
                            <span class="text-gray-400">Resolution:</span>
                            <span id="currentResolution" class="font-medium">0.3m</span>
                        </div>
                        <div class="flex justify-between">
                            <span class="text-gray-400">Capture Date:</span>
                            <span id="currentDate" class="font-medium">2023-06-15</span>
                        </div>
                        <div class="flex justify-between">
                            <span class="text-gray-400">Cloud Cover:</span>
                            <span id="currentCloudCover" class="font-medium">5%</span>
                        </div>
                        <div class="flex justify-between">
                            <span class="text-gray-400">Coordinates:</span>
                            <span id="currentCoords" class="font-medium">52.52, 13.41</span>
                        </div>
                    </div>
                </div>

                <!-- Analysis Tools -->
                <div class="bg-gray-800 p-4 rounded-lg">
                    <h3 class="text-lg font-medium mb-3">Analysis Tools</h3>
                    <div class="grid grid-cols-2 gap-3">
                        <button class="px-3 py-2 bg-gray-700 hover:bg-gray-600 rounded-lg text-sm flex items-center justify-center">
                            <i class="fas fa-ruler-combined mr-2"></i>Measure
                        </button>
                        <button class="px-3 py-2 bg-gray-700 hover:bg-gray-600 rounded-lg text-sm flex items-center justify-center">
                            <i class="fas fa-layer-group mr-2"></i>Compare
                        </button>
                        <button class="px-3 py-2 bg-gray-700 hover:bg-gray-600 rounded-lg text-sm flex items-center justify-center">
                            <i class="fas fa-chart-line mr-2"></i>NDVI
                        </button>
                        <button class="px-3 py-2 bg-gray-700 hover:bg-gray-600 rounded-lg text-sm flex items-center justify-center">
                            <i class="fas fa-water mr-2"></i>Water Mask
                        </button>
                    </div>
                    <div class="mt-4">
                        <label class="block text-sm font-medium mb-1">Image Enhancement</label>
                        <select id="enhancementSelect" class="w-full px-2 py-1 bg-gray-700 rounded-lg text-sm">
                            <option value="natural">Natural Color</option>
                            <option value="urban">False Color (Urban)</option>
                            <option value="vegetation">Vegetation Analysis</option>
                            <option value="atmospheric">Atmospheric Penetration</option>
                        </select>
                    </div>
                </div>

                <!-- Order Options -->
                <div class="bg-gray-800 p-4 rounded-lg">
                    <h3 class="text-lg font-medium mb-3">Order Options</h3>
                    <div class="space-y-3">
                        <div class="flex items-center justify-between">
                            <div>
                                <div class="font-medium">High-Res Download</div>
                                <div class="text-sm text-gray-400">GeoTIFF format</div>
                            </div>
                            <button class="px-3 py-1 bg-blue-600 hover:bg-blue-700 rounded-lg text-sm">
                                $49.99
                            </button>
                        </div>
                        <div class="flex items-center justify-between">
                            <div>
                                <div class="font-medium">Time Series Analysis</div>
                                <div class="text-sm text-gray-400">5-image package</div>
                            </div>
                            <button class="px-3 py-1 bg-blue-600 hover:bg-blue-700 rounded-lg text-sm">
                                $199.99
                            </button>
                        </div>
                        <div class="flex items-center justify-between">
                            <div>
                                <div class="font-medium">UP42 API Access</div>
                                <div class="text-sm text-gray-400">Monthly subscription</div>
                            </div>
                            <button class="px-3 py-1 bg-blue-600 hover:bg-blue-700 rounded-lg text-sm">
                                $299.99/mo
                            </button>
                        </div>
                        <button id="addToCartBtn" class="w-full py-2 bg-green-600 hover:bg-green-700 rounded-lg transition mt-2">
                            <i class="fas fa-shopping-cart mr-2"></i>Add to Cart
                        </button>
                    </div>
                </div>
            </div>
        </main>

        <!-- Footer -->
        <footer class="mt-12 pt-6 border-t border-gray-800">
            <div class="grid grid-cols-1 md:grid-cols-4 gap-8">
                <div>
                    <h4 class="text-lg font-medium mb-3">OrbitView</h4>
                    <p class="text-gray-400 text-sm">The premier platform for accessing live and historical satellite imagery from leading providers worldwide.</p>
                </div>
                <div>
                    <h4 class="text-lg font-medium mb-3">Providers</h4>
                    <ul class="space-y-2 text-gray-400 text-sm">
                        <li><a href="https://www.maxar.com/" target="_blank" class="hover:text-blue-400">Maxar</a></li>
                        <li><a href="https://www.planet.com/" target="_blank" class="hover:text-blue-400">Planet Labs</a></li>
                        <li><a href="https://www.sentinel-hub.com/" target="_blank" class="hover:text-blue-400">Sentinel Hub</a></li>
                        <li><a href="https://up42.com/" target="_blank" class="hover:text-blue-400">UP42 Marketplace</a></li>
                    </ul>
                </div>
                <div>
                    <h4 class="text-lg font-medium mb-3">Resources</h4>
                    <ul class="space-y-2 text-gray-400 text-sm">
                        <li><a href="https://developers.planet.com/docs/" target="_blank" class="hover:text-blue-400">API Documentation</a></li>
                        <li><a href="https://www.satimagingcorp.com/satellite-sensors/" target="_blank" class="hover:text-blue-400">Satellite Sensors</a></li>
                        <li><a href="https://earthdata.nasa.gov/learn" target="_blank" class="hover:text-blue-400">NASA Earthdata</a></li>
                        <li><a href="https://eos.com/blog/satellite-imagery/" target="_blank" class="hover:text-blue-400">Imagery Blog</a></li>
                    </ul>
                </div>
                <div>
                    <h4 class="text-lg font-medium mb-3">Contact</h4>
                    <ul class="space-y-2 text-gray-400 text-sm">
                        <li><i class="fas fa-envelope mr-2"></i> support@orbitview.com</li>
                        <li><i class="fas fa-phone mr-2"></i> +1 (555) 123-4567</li>
                        <li><i class="fas fa-map-marker-alt mr-2"></i> San Francisco, CA</li>
                        <li class="flex space-x-4 mt-4">
                            <a href="#"><i class="fab fa-twitter text-xl hover:text-blue-400"></i></a>
                            <a href="#"><i class="fab fa-linkedin text-xl hover:text-blue-400"></i></a>
                            <a href="#"><i class="fab fa-github text-xl hover:text-blue-400"></i></a>
                        </li>
                    </ul>
                </div>
            </div>
            <div class="mt-8 text-center text-gray-500 text-sm">
                <p>© 2023 OrbitView. All rights reserved. | <a href="#" class="hover:text-blue-400">Privacy Policy</a> | <a href="#" class="hover:text-blue-400">Terms of Service</a></p>
            </div>
        </footer>
    </div>

    <!-- Login Modal -->
    <div id="loginModal" class="fixed inset-0 bg-black bg-opacity-75 flex items-center justify-center z-50 hidden">
        <div class="bg-gray-800 rounded-lg p-6 w-full max-w-md">
            <div class="flex justify-between items-center mb-4">
                <h3 class="text-xl font-bold">Sign In</h3>
                <button id="closeModal" class="text-gray-400 hover:text-white">
                    <i class="fas fa-times"></i>
                </button>
            </div>
            <form>
                <div class="mb-4">
                    <label class="block text-sm font-medium mb-1">Email</label>
                    <input type="email" class="w-full px-3 py-2 bg-gray-700 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500">
                </div>
                <div class="mb-4">
                    <label class="block text-sm font-medium mb-1">Password</label>
                    <input type="password" class="w-full px-3 py-2 bg-gray-700 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500">
                </div>
                <div class="flex items-center justify-between mb-4">
                    <div class="flex items-center">
                        <input type="checkbox" id="rememberMe" class="mr-2">
                        <label for="rememberMe" class="text-sm">Remember me</label>
                    </div>
                    <a href="#" class="text-sm text-blue-400 hover:underline">Forgot password?</a>
                </div>
                <button type="submit" class="w-full py-2 bg-blue-600 hover:bg-blue-700 rounded-lg transition">
                    Sign In
                </button>
            </form>
            <div class="mt-4 text-center text-sm">
                <p>Don't have an account? <a href="#" class="text-blue-400 hover:underline">Sign up</a></p>
            </div>
            <div class="mt-6 pt-4 border-t border-gray-700">
                <p class="text-xs text-gray-400">By signing in, you agree to our <a href="#" class="text-blue-400 hover:underline">Terms of Service</a> and <a href="#" class="text-blue-400 hover:underline">Privacy Policy</a>.</p>
            </div>
        </div>
    </div>

    <script>
        // Initialize map
        const map = L.map('map').setView([52.52, 13.41], 12);
        
        // Add base layer
        L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
            attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
        }).addTo(map);

        // Satellite layers from different providers
        const satelliteLayers = {
            maxar: L.tileLayer('https://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}', {
                attribution: 'Tiles &copy; Esri &mdash; Source: Esri, Maxar, Earthstar Geographics',
                className: 'satellite-layer'
            }),
            planet: L.tileLayer('https://tiles.planet.com/basemaps/v1/planet-tiles/global_monthly_{month}_{year}_mosaic/gmap/{z}/{x}/{y}.png?api_key=YOUR_PLANET_API_KEY', {
                attribution: '&copy; Planet Labs',
                className: 'satellite-layer'
            }),
            sentinel: L.tileLayer('https://tiles.maps.eox.at/wmts/1.0.0/s2cloudless-2020_3857/default/g/{z}/{y}/{x}.jpg', {
                attribution: 'Contains modified Copernicus Sentinel data 2020',
                className: 'satellite-layer'
            }),
            landsat: L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/Landsat/World_NDVI/MapServer/tile/{z}/{y}/{x}', {
                attribution: 'Source: USGS/NASA Landsat',
                className: 'satellite-layer'
            }),
            up42: L.tileLayer('https://tiles.up42.com/up42-ogc/wmts/1.0.0/ortho_30cm/{z}/{y}/{x}.png?token=YOUR_UP42_TOKEN', {
                attribution: '&copy; UP42',
                className: 'satellite-layer'
            })
        };

        // Add default layer
        satelliteLayers.maxar.addTo(map);
        let currentLayer = 'maxar';

        // Modal functionality
        const loginBtn = document.getElementById('loginBtn');
        const loginModal = document.getElementById('loginModal');
        const closeModal = document.getElementById('closeModal');

        loginBtn.addEventListener('click', () => {
            loginModal.classList.remove('hidden');
        });

        closeModal.addEventListener('click', () => {
            loginModal.classList.add('hidden');
        });

        // Search functionality
        const searchBtn = document.getElementById('searchBtn');
        const locationSearch = document.getElementById('locationSearch');
        const currentLocationBtn = document.getElementById('currentLocationBtn');

        // Quick location buttons
        document.querySelectorAll('[data-location]').forEach(btn => {
            btn.addEventListener('click', () => {
                const location = btn.dataset.location;
                let coords, zoom;
                
                switch(location) {
                    case 'europe':
                        coords = [48.8566, 2.3522]; // Paris
                        zoom = 5;
                        break;
                    case 'north-america':
                        coords = [40.7128, -74.0060]; // New York
                        zoom = 4;
                        break;
                    case 'asia':
                        coords = [35.6762, 139.6503]; // Tokyo
                        zoom = 4;
                        break;
                }
                
                map.setView(coords, zoom);
                updateImageDetails('Maxar', '0.3m', getCurrentDate(), '5%', `${coords[0].toFixed(2)}, ${coords[1].toFixed(2)}`);
                updateTimeline(coords);
            });
        });

        // Current location button
        currentLocationBtn.addEventListener('click', () => {
            if (navigator.geolocation) {
                const loadingOverlay = document.getElementById('loadingOverlay');
                loadingOverlay.classList.remove('hidden');
                
                navigator.geolocation.getCurrentPosition(
                    position => {
                        const coords = [position.coords.latitude, position.coords.longitude];
                        map.setView(coords, 15);
                        updateImageDetails('Maxar', '0.3m', getCurrentDate(), '5%', `${coords[0].toFixed(2)}, ${coords[1].toFixed(2)}`);
                        updateTimeline(coords);
                        loadingOverlay.classList.add('hidden');
                    },
                    error => {
                        alert('Could not get your location: ' + error.message);
                        loadingOverlay.classList.add('hidden');
                    }
                );
            } else {
                alert('Geolocation is not supported by your browser');
            }
        });

        searchBtn.addEventListener('click', () => {
            const query = locationSearch.value.trim();
            if (query) {
                const loadingOverlay = document.getElementById('loadingOverlay');
                loadingOverlay.classList.remove('hidden');
                
                if (query.includes(',')) {
                    // Handle coordinates
                    const [lat, lng] = query.split(',').map(coord => parseFloat(coord.trim()));
                    if (!isNaN(lat) && !isNaN(lng)) {
                        map.setView([lat, lng], 15);
                        updateImageDetails('Maxar', '0.3m', getCurrentDate(), '5%', `${lat.toFixed(2)}, ${lng.toFixed(2)}`);
                        updateTimeline([lat, lng]);
                    }
                } else {
                    // Handle place names using Nominatim API
                    fetch(`https://nominatim.openstreetmap.org/search?format=json&q=${encodeURIComponent(query)}`)
                        .then(response => response.json())
                        .then(data => {
                            if (data.length > 0) {
                                const result = data[0];
                                const coords = [parseFloat(result.lat), parseFloat(result.lon)];
                                map.setView(coords, 12);
                                updateImageDetails('Maxar', '0.3m', getCurrentDate(), '5%', `${coords[0].toFixed(2)}, ${coords[1].toFixed(2)}`);
                                updateTimeline(coords);
                            } else {
                                alert('Location not found');
                            }
                        })
                        .catch(error => {
                            console.error('Error fetching location:', error);
                            alert('Error searching for location');
                        })
                        .finally(() => {
                            loadingOverlay.classList.add('hidden');
                        });
                }
            }
        });

        // Provider selection
        const providerSelect = document.getElementById('providerSelect');
        const applyBtn = document.getElementById('applyBtn');

        applyBtn.addEventListener('click', () => {
            const provider = providerSelect.value;
            const loadingOverlay = document.getElementById('loadingOverlay');
            loadingOverlay.classList.remove('hidden');
            
            // Remove current layer
            satelliteLayers[currentLayer].remove();
            
            // Add new layer
            satelliteLayers[provider].addTo(map);
            currentLayer = provider;
            
            // Update details based on provider
            const center = map.getCenter();
            let resolution, cloudCover;
            
            switch(provider) {
                case 'maxar':
                    resolution = '0.3m';
                    cloudCover = '5%';
                    break;
                case 'planet':
                    resolution = '0.5m';
                    cloudCover = '15%';
                    break;
                case 'sentinel':
                    resolution = '10m';
                    cloudCover = '20%';
                    break;
                case 'landsat':
                    resolution = '15m';
                    cloudCover = '8%';
                    break;
                case 'up42':
                    resolution = '0.5m';
                    cloudCover = '12%';
                    break;
            }
            
            updateImageDetails(
                provider.charAt(0).toUpperCase() + provider.slice(1), 
                resolution, 
                getCurrentDate(), 
                cloudCover, 
                `${center.lat.toFixed(2)}, ${center.lng.toFixed(2)}`
            );
            
            loadingOverlay.classList.add('hidden');
        });

        // Image enhancement
        const enhancementSelect = document.getElementById('enhancementSelect');
        enhancementSelect.addEventListener('change', () => {
            const enhancement = enhancementSelect.value;
            const layer = document.querySelector('.satellite-layer');
            
            switch(enhancement) {
                case 'natural':
                    layer.style.filter = 'brightness(1.1) contrast(1.1)';
                    break;
                case 'urban':
                    layer.style.filter = 'brightness(1.2) contrast(1.2) saturate(1.5)';
                    break;
                case 'vegetation':
                    layer.style.filter = 'brightness(1.1) contrast(1.3) hue-rotate(90deg)';
                    break;
                case 'atmospheric':
                    layer.style.filter = 'brightness(1.3) contrast(1.3)';
                    break;
            }
        });

        // Update image details panel
        function updateImageDetails(provider, resolution, date, cloudCover, coords) {
            document.getElementById('currentProvider').textContent = provider;
            document.getElementById('currentResolution').textContent = resolution;
            document.getElementById('currentDate').textContent = date;
            document.getElementById('currentCloudCover').textContent = cloudCover;
            document.getElementById('currentCoords').textContent = coords;
        }

        // Update timeline with historical images
        function updateTimeline(coords) {
            const timelineItems = document.getElementById('timelineItems');
            timelineItems.innerHTML = '';
            
            // Generate 5 historical dates
            const dates = [];
            const today = new Date();
            for (let i = 0; i < 5; i++) {
                const date = new Date(today);
                date.setMonth(date.getMonth() - (i * 2));
                dates.push(date.toISOString().split('T')[0]);
            }
            
            // Add timeline items
            dates.forEach((date, index) => {
                const provider = ['Maxar', 'Planet', 'Sentinel-2', 'Landsat 9', 'UP42'][index];
                const resolution = ['0.3m', '0.5m', '10m', '15m', '0.5m'][index];
                const cloudCover = ['5%', '15%', '20%', '8%', '12%'][index];
                
                const item = document.createElement('div');
                item.className = 'timeline-item flex-shrink-0 w-32 h-24 bg-gray-700 rounded-lg overflow-hidden relative cursor-pointer hover:ring-2 hover:ring-blue-500';
                
                // Generate thumbnail URL based on provider
                let thumbnailUrl;
                if (provider === 'Maxar') {
                    thumbnailUrl = `https://maps.googleapis.com/maps/api/staticmap?center=${coords[0]},${coords[1]}&zoom=14&size=300x200&maptype=satellite&key=YOUR_GOOGLE_API_KEY`;
                } else if (provider === 'Planet') {
                    thumbnailUrl = `https://tiles.planet.com/basemaps/v1/planet-tiles/global_monthly_${date.substring(5,7)}_${date.substring(0,4)}_mosaic/thumb/{z}/{x}/{y}.png?api_key=YOUR_PLANET_API_KEY`;
                } else {
                    // Fallback to generic placeholder
                    thumbnailUrl = `https://maps.googleapis.com/maps/api/staticmap?center=${coords[0]},${coords[1]}&zoom=14&size=300x200&maptype=satellite&key=YOUR_GOOGLE_API_KEY`;
                }
                
                item.innerHTML = `
                    <img src="${thumbnailUrl}" class="w-full h-full object-cover">
                    <div class="absolute bottom-0 left-0 right-0 bg-black bg-opacity-70 p-1 text-xs">
                        <div>${provider} • ${date}</div>
                    </div>
                `;
                
                item.addEventListener('click', () => {
                    // When clicked, update the main map view
                    map.setView(coords, 14);
                    updateImageDetails(provider, resolution, date, cloudCover, `${coords[0].toFixed(2)}, ${coords[1].toFixed(2)}`);
                });
                
                timelineItems.appendChild(item);
            });
        }

        // Get current date in YYYY-MM-DD format
        function getCurrentDate() {
            const today = new Date();
            return today.toISOString().split('T')[0];
        }

        // Initialize with default values
        updateImageDetails('Maxar', '0.3m', getCurrentDate(), '5%', '52.52, 13.41');
        updateTimeline([52.52, 13.41]);

        // Set today's date as default
        document.getElementById('startDate').value = getCurrentDate();
        document.getElementById('endDate').value = getCurrentDate();

        // Add to cart functionality
        document.getElementById('addToCartBtn').addEventListener('click', () => {
            alert('Added current image to your cart');
        });
    </script>
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=LuHof/testspace" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>