-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathearthquakes_pr.html
More file actions
196 lines (172 loc) · 7.62 KB
/
earthquakes_pr.html
File metadata and controls
196 lines (172 loc) · 7.62 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description"
content="Interactive visualization of earthquake data in Puerto Rico using PyScript and Folium">
<meta name="keywords" content="earthquake visualization, data visualization, folium, pyscript, interactive map">
<title>Earthquake Visualization</title>
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-0L5LLER0MH"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() { dataLayer.push(arguments); }
gtag('js', new Date());
gtag('config', 'G-0L5LLER0MH');
</script>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;700&display=swap">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/tailwindcss/dist/tailwind.min.css">
<!-- Relative path (correct) -->
<link rel="stylesheet" href="./assets/css/main.css">
<link rel="stylesheet" href="https://pyscript.net/releases/2025.3.1/core.css">
<script type="module" src="https://pyscript.net/releases/2025.3.1/core.js"></script>
<style>
/* Master layout fix that works at all viewport widths */
html, body {
font-family: 'JetBrains Mono', monospace;
height: 100%;
margin: 0;
padding: 0;
overflow-x: hidden;
}
body {
display: flex;
flex-direction: column;
min-height: 100vh;
padding-top: 64px; /* Account for fixed navbar */
}
/* Force proper layout container for map */
.pyscript {
flex: 1 0 auto;
display: flex;
flex-direction: column;
position: relative;
width: 100%;
min-height: calc(100vh - 64px); /* Full height minus navbar */
}
/* Force Leaflet container to respect parent dimensions */
#folium {
flex: 1 0 auto;
width: 100% !important;
height: 100% !important;
min-height: calc(100vh - 64px) !important; /* Full height minus navbar */
position: relative;
z-index: 1;
}
/* Make sure Leaflet's internal elements behave */
.leaflet-container {
height: 100% !important;
width: 100% !important;
}
/* Increase specificity for legend positioning */
.legend.legend {
position: fixed !important;
bottom: 20px !important; /* Moved up since no footer */
right: 25px !important;
z-index: 9999 !important;
}
/* Handle large screens specifically */
@media (min-width: 1200px) {
#folium {
height: calc(100vh - 124px) !important; /* Fixed height on large screens */
}
}
</style>
</head>
<body class="text-white bg-[#0d1117]">
<!-- Navigation -->
<nav class="w-full p-4 bg-opacity-100 bg-gray-900 shadow-md fixed top-0 left-0 z-50">
<div class="max-w-6xl mx-auto flex justify-between items-center">
<div class="text-xl font-mono font-bold"><a href="index.html" class="hover:text-[#6ee7b7] transition-colors">Earthquakes Visualization</a></div>
<ul class="flex space-x-6">
<li><a href="index.html" class="hover:text-[#6ee7b7] transition-colors">Home</a></li>
<li><a href="index.html#projects" class="hover:text-[#6ee7b7] transition-colors">Projects</a></li>
<li><a href="index.html#contact" class="hover:text-[#6ee7b7] transition-colors">Contact</a></li>
</ul>
</div>
</nav>
<main class="pt-16 min-h-screen" style="
padding-top: 0px;">
<!-- Loading Dialog -->
<dialog id="loading" class="bg-transparent outline-none border-none">
<div class="flex flex-col items-center justify-center p-8 text-white">
<div class="spinner"></div>
<div class="loading-text mt-4">Loading visualization...</div>
</div>
</dialog>
<!-- Map Container -->
<div id="folium" class="w-full h-screen"></div>
</main>
<!-- Map Legends -->
<div class="fixed bottom-4 right-4 bg-gray-900 bg-opacity-75 rounded-lg p-3 z-10 shadow-lg">
<h4 class="text-sm font-bold mb-2">Earthquake Magnitude</h4>
<div class="grid grid-cols-2 gap-x-3 gap-y-1">
<div class="flex items-center"><span class="inline-block w-3 h-3 rounded-full bg-green-500 mr-2"></span> < 3.0</div>
<div class="flex items-center"><span class="inline-block w-3 h-3 rounded-full bg-yellow-400 mr-2"></span> 3.0 - 4.0</div>
<div class="flex items-center"><span class="inline-block w-3 h-3 rounded-full bg-orange-500 mr-2"></span> 4.1 - 5.0</div>
<div class="flex items-center"><span class="inline-block w-3 h-3 rounded-full bg-red-500 mr-2"></span> > 5.0</div>
</div>
</div>
<!-- PyScript configuration -->
<py-config>
packages = ["folium", "pandas"]
</py-config>
<py-script src="./projects/earthquake-map/main.py"></py-script>
<script>
// Get loading dialog
const loading = document.getElementById('loading');
// Show the loading dialog immediately
document.addEventListener('DOMContentLoaded', () => {
loading.showModal();
console.log("Loading dialog opened");
});
// Multiple approaches to detect map loading
// 1. Listen for our custom event
document.addEventListener('map:loaded', () => {
console.log("Map loaded event received");
setTimeout(() => {
loading.close();
console.log("Loading dialog closed");
}, 500); // Small delay to ensure map is rendered
});
// 2. Timer-based fallback
setTimeout(() => {
if (loading.open) {
console.log("Fallback timer closing loading dialog");
loading.close();
}
}, 20000); // 20 second timeout
// 3. DOM-based detection
const checkMapInterval = setInterval(() => {
if (document.querySelector('.leaflet-container') &&
document.querySelector('.leaflet-tile-loaded')) {
console.log("Leaflet map detected in DOM");
if (loading.open) {
loading.close();
clearInterval(checkMapInterval);
}
}
}, 1000);
// 4. Observe the folium container for changes
const foliumObserver = new MutationObserver((mutations) => {
for (const mutation of mutations) {
if (mutation.type === 'childList' &&
document.querySelector('.leaflet-container')) {
console.log("Map container detected via MutationObserver");
setTimeout(() => {
if (loading.open) loading.close();
foliumObserver.disconnect();
}, 1000);
}
}
});
// Start observing the folium element
const foliumElement = document.getElementById('folium');
if (foliumElement) {
foliumObserver.observe(foliumElement, { childList: true, subtree: true });
}
</script>
</body>
</html>