-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathalabama-map.html
More file actions
409 lines (362 loc) · 17.1 KB
/
Copy pathalabama-map.html
File metadata and controls
409 lines (362 loc) · 17.1 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
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
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Alabama Cities Map - Moving to Alabama Guide</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
}
header {
background-color: #333;
color: #fff;
padding: 10px;
text-align: center;
}
nav {
background-color: #444;
padding: 10px;
text-align: center;
}
nav a {
color: #fff;
text-decoration: none;
margin: 0 15px;
font-weight: bold;
}
nav a:hover {
color: #ddd;
}
main {
padding: 20px;
max-width: 1000px;
margin: 0 auto;
padding-bottom: 80px;
}
h2 {
color: #333;
text-align: center;
}
.map-container {
position: relative;
width: 100%;
max-width: 800px;
margin: 0 auto;
}
.map-image {
width: 100%;
height: auto;
border: 2px solid #333;
}
.city-marker {
position: absolute;
background-color: #ff4444;
color: white;
padding: 5px 10px;
border-radius: 15px;
font-size: 12px;
font-weight: bold;
cursor: pointer;
transform: translate(-50%, -50%);
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
border: 2px solid white;
}
.city-marker:hover {
background-color: #cc3333;
z-index: 10;
}
.city-info {
position: absolute;
background-color: rgba(0, 0, 0, 0.8);
color: white;
padding: 10px;
border-radius: 5px;
font-size: 11px;
width: 200px;
display: none;
z-index: 20;
}
.city-marker:hover .city-info {
display: block;
}
/* Positioning for each city (approximate percentages) */
/* top : pct away from top */
/* left: pct away from left */
.huntsville {
top: 6%;
left: 53%;
}
.birmingham {
top: 30%;
left: 47%;
}
.tuscaloosa {
top: 37%;
left: 27%;
}
.columbiana {
top: 38%;
left: 52%;
}
.auburn {
top: 50%;
left: 85%;
}
.montgomery {
top: 59%;
left: 63%;
}
.mobile {
top: 90%;
left: 9%;
}
.gulf-shores {
top: 98%;
left: 18%;
}
footer {
background-color: #333;
color: #fff;
padding: 10px;
text-align: center;
position: fixed;
bottom: 0;
width: 100%;
}
/* Styles for the old file content section */
.file-content-section { /* Original class, still applies */
margin-top: 40px;
border-top: 1px solid #ccc;
padding-top: 20px;
}
.file-content-section h3 {
text-align: center;
color: #333;
margin-bottom: 15px;
}
/* Styles for the new JSON content sections */
#status-messages p { margin: 5px 0; font-size: 0.9em; }
#status-messages .warning { color: orange; }
#status-messages .error { color: red; }
#status-messages .success { color: green; }
#output-data pre { /* Styling for the JSON output */
background-color: #e9e9e9;
padding: 15px;
border-radius: 5px;
overflow-x: auto;
font-size: 0.85em;
line-height: 1.4;
border: 1px solid #ddd;
}
</style>
</head>
<body>
<header>
<h1>Moving to Alabama Guide</h1>
</header>
<nav>
<a href="index.html">Home</a>
<a href="why-move.html">Why Move to Alabama?</a>
<a href="best-cities.html">Best Cities to Live in Alabama</a>
<a href="moving-guide.html">Moving Guide</a>
<a href="resources.html">Resources</a>
<a href="alabama-map.html">Alabama Map</a>
<a href="contact.html">Contact</a>
</nav>
<main>
<h2>Interactive Alabama Cities Map</h2>
<p style="text-align: center">
Hover over the city markers to see median home prices.
</p>
<div class="map-container">
<img
src="https://upload.wikimedia.org/wikipedia/commons/7/71/Alabama_counties.svg"
alt="Alabama State Map"
class="map-image"
/>
<!-- City markers with data overlays -->
<div class="city-marker huntsville" style="text-align: center">
Huntsville<br>
$168/sf
<div class="city-info">Median Home Price: $355,900</div>
</div>
<div class="city-marker birmingham" style="text-align: center">
Birmingham<br>
$143/sf
<div class="city-info">Median Home Price: $249,900</div>
</div>
<div class="city-marker tuscaloosa" style="text-align: center">
Tuscaloosa<br>
$178/sf
<div class="city-info">Median Home Price: $315,000</div>
</div>
<div class="city-marker columbiana" style="text-align: center">
Columbiana<br>
$180/sf
<div class="city-info">Median Home Price: $399,000</div>
</div>
<div class="city-marker auburn" style="text-align: center">
Auburn<br>
$198/sf
<div class="city-info">Median Home Price: $404,950</div>
</div>
<div class="city-marker montgomery" style="text-align: center">
Montgomery<br>
$114/sf
<div class="city-info">Median Home Price: $225,650</div>
</div>
<div class="city-marker mobile" style="text-align: center">
Mobile<br>
$146/sf
<div class="city-info">Median Home Price: $235,000</div>
</div>
<div class="city-marker gulf-shores" style="text-align: center">
Gulf Shores<br>
$323/sf
<div class="city-info">Median Home Price: $499,000</div>
</div>
</div>
<p style="text-align: center; margin-top: 20px; color: #666">
<em
>Interactive map showing major Alabama cities and their key
information.</em
>
</p>
<div class="file-content-section">
<!-- <h3>Monthly Data Load Status and Output</h3> -->
<div id="status-messages">
<!-- <p><strong>Initializing monthly data load...</strong></p> -->
</div>
<hr>
<div id="output-data">
<p>Data will appear here once loaded.</p>
</div>
</div>
</main>
<footer>
<p>© 2025 Moving to Alabama Guide</p>
</footer>
<script>
// --- Helper Functions ---
// Converts a "Month Year" string (e.g., "April 2025") to a JavaScript Date object
function monthYearStr2DateObj(monthYearString) {
const [monthName, year] = monthYearString.split(' ');
const monthIndex = new Date(Date.parse(`${monthName} 1, ${year}`)).getMonth();
return new Date(year, monthIndex, 1);
}
// Formats a Date object into "YYYY_MM_DD" string for filename
function formatDateForFilename(dateObj) {
const year = dateObj.getFullYear();
const month = String(dateObj.getMonth() + 1).padStart(2, '0');
const day = '01';
return `${year}_${month}_${day}`;
}
// --- Main Script Logic for Iterative JSON Loading ---
// 1. Define the range of months/years you want to load
const startMonthYearStr = "April 2025";
const endMonthYearStr = "June 2025"; // This will attempt to load Apr, May, Jun 2025
// Convert string dates to Date objects for iteration
let currentIterationDate = monthYearStr2DateObj(startMonthYearStr);
const endDate = monthYearStr2DateObj(endMonthYearStr);
// Initialize arrays and objects for data storage and promises
const fetchPromises = []; // Stores all the Promises from fetch requests
const allMonthlyData = {}; // Stores the aggregated data { "YYYY_MM_DD": { state: {...} } }
// Get references to HTML elements for displaying status and output
const statusDiv = document.getElementById('status-messages');
const outputDiv = document.getElementById('output-data');
// Commented out: Lines that would populate the "Monthly Data Load Status and Output" section (statusDiv)
// statusDiv.innerHTML += `<p><strong>Starting iterative load from ${startMonthYearStr} to ${endMonthYearStr}...</strong></p>`;
console.log(`Starting iterative load from ${startMonthYearStr} to ${endMonthYearStr}...`);
// 2. Iterate through the date range and prepare fetch promises
while (currentIterationDate.getTime() <= endDate.getTime()) {
const fileDateFormat = formatDateForFilename(currentIterationDate);
// Correct path: files are in 'numbers/' subdirectory
const filename = `numbers/numbers_${fileDateFormat}.json`;
console.log(`Preparing to fetch: ${filename}`);
// Commented out: Lines that would populate the "Monthly Data Load Status and Output" section (statusDiv)
// statusDiv.innerHTML += `<p>Attempting to load: <code>${filename}</code></p>`;
const fetchPromise = fetch(filename)
.then(response => {
if (!response.ok) {
if (response.status === 404) {
console.warn(`File not found: ${filename}. Skipping this month.`);
// Commented out: Lines that would populate the "Monthly Data Load Status and Output" section (statusDiv)
// statusDiv.innerHTML += `<p class="warning">Warning: File <code>${filename}</code> not found. Skipping.</p>`;
return null;
}
throw new Error(`HTTP error! status: ${response.status} ${response.statusText} for ${filename}`);
}
return response.json();
})
.then(data => {
if (data) {
allMonthlyData[fileDateFormat] = data;
console.log(`Successfully fetched and parsed data for ${fileDateFormat}.`);
// Commented out: Lines that would populate the "Monthly Data Load Status and Output" section (statusDiv)
// statusDiv.innerHTML += `<p class="success">Successfully loaded: <code>${filename}</code></p>`;
}
return data;
})
.catch(error => {
console.error(`Error processing ${filename}:`, error);
// Commented out: Lines that would populate the "Monthly Data Load Status and Output" section (statusDiv)
// statusDiv.innerHTML += `<p class="error">Error loading <code>${filename}</code>: ${error.message}</p>`;
// Commented out: Lines that would populate the "Monthly Data Load Status and Output" section (outputDiv error message)
// outputDiv.textContent = `Overall loading failed: ${error.message}`;
return null;
});
fetchPromises.push(fetchPromise);
currentIterationDate.setMonth(currentIterationDate.getMonth() + 1);
}
// 3. Use Promise.all to wait for all fetch operations to complete
Promise.all(fetchPromises)
.then(results => {
console.log("\n--- All Monthly Data Loading Attempted ---");
console.log("Final aggregated data structure:", allMonthlyData);
// Commented out: Lines that would populate the "Monthly Data Load Status and Output" section (statusDiv)
// statusDiv.innerHTML += `<p><strong>All loading attempts completed. Total months loaded: ${Object.keys(allMonthlyData).length}</strong></p>`;
// --- 4. Verification Code: Print Data to Webpage (outputDiv) ---
// This section iterates through the loaded data and displays a sample for each month.
outputDiv.innerHTML = '<h3>Detailed Sample Data for Each Month:</h3>'; // Clear previous content
const sortedMonthKeys = Object.keys(allMonthlyData).sort(); // Get and sort the month keys
if (sortedMonthKeys.length === 0) {
outputDiv.innerHTML += '<p>No data was successfully loaded for any month.</p>';
return; // Exit if no data was loaded
}
for (const monthKey of sortedMonthKeys) {
outputDiv.innerHTML += `<h4>--- Month: ${monthKey} ---</h4>`; // Display month header
const currentMonthData = allMonthlyData[monthKey]; // Get data for the current month
// Attempt to print a sample from the first available state/county
const firstStateKey = Object.keys(currentMonthData)[0]; // Get the first state key
if (firstStateKey && currentMonthData[firstStateKey]) {
const firstCountyKey = Object.keys(currentMonthData[firstStateKey])[0]; // Get the first county key in that state
if (firstCountyKey && currentMonthData[firstStateKey][firstCountyKey]) {
outputDiv.innerHTML += `<p><strong>Next available data (${firstStateKey} → ${firstCountyKey}):</strong></p>`;
outputDiv.innerHTML += `<pre>${JSON.stringify(currentMonthData[firstStateKey][firstCountyKey], null, 2)}</pre>`;
} else {
outputDiv.innerHTML += `<p>No county data found for state '${firstStateKey}' in this month.</p>`;
}
} else {
outputDiv.innerHTML += `<p>No state data found for this month.</p>`;
}
}
// --- End of Verification Code ---
})
.catch(overallError => {
console.error("An overall error occurred during Promise.all:", overallError);
// Commented out: Lines that would populate the "Monthly Data Load Status and Output" section (statusDiv)
// statusDiv.innerHTML += `<p class="error">Overall loading failed: ${overallError.message}</p>`;
// Lines that would populate the "Detailed Sampled Data" section with error message (outputDiv)
outputDiv.textContent = `Overall loading failed: ${overallError.message}`;
});
</script>
</body>
</html>
<!-- https://lookups.melissa.com/home/newhomeowner/?zipcode=35810&pubyearmonth= -->
<!-- https://www.alabamarealtors.com/who-we-are/market-stats -->
<!-- https://acre.culverhouse.ua.edu/research/residential-research/ -->
<!-- https://www.fgcu.edu/cob/reri/news/reports/ -->
<!-- https://www.floridarealtors.org/tools-research/reports/florida-market-reports -->