-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmap.html
More file actions
648 lines (612 loc) · 26.2 KB
/
map.html
File metadata and controls
648 lines (612 loc) · 26.2 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
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
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
<!DOCTYPE html>
<html lang="ar" dir="rtl">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" type="image/svg+xml" href="images/icon-192.svg">
<title>خريطة أماكن الرياض التفاعلية | وين نروح بالرياض؟</title>
<meta name="description" content="خريطة تفاعلية لأفضل أماكن الرياض. اكتشف الكافيهات والمطاعم والأماكن الترفيهية القريبة منك على الخريطة.">
<meta property="og:title" content="خريطة أماكن الرياض التفاعلية | وين نروح بالرياض؟">
<meta property="og:description" content="خريطة تفاعلية لأفضل أماكن الرياض. اكتشف الكافيهات والمطاعم والأماكن الترفيهية القريبة منك.">
<meta property="og:type" content="website">
<meta property="og:url" content="https://treklaps.github.io/riyadh-places/map.html">
<meta property="og:locale" content="ar_SA">
<meta property="og:image" content="https://treklaps.github.io/riyadh-places/images/icon-512.svg">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:title" content="خريطة أماكن الرياض التفاعلية | وين نروح بالرياض؟">
<meta name="twitter:description" content="خريطة تفاعلية لأفضل أماكن الرياض. اكتشف الكافيهات والمطاعم والأماكن الترفيهية القريبة منك.">
<meta name="twitter:image" content="https://treklaps.github.io/riyadh-places/images/icon-512.svg">
<link rel="canonical" href="https://treklaps.github.io/riyadh-places/map.html">
<link rel="manifest" href="manifest.json">
<meta name="theme-color" content="#0a1628">
<!-- Performance: preconnect & preload -->
<link rel="preconnect" href="https://images.unsplash.com" crossorigin>
<link rel="preconnect" href="https://fonts.googleapis.com" crossorigin>
<link rel="dns-prefetch" href="https://images.unsplash.com">
<link rel="preload" href="data/places-light.json" as="fetch" crossorigin>
<!-- Critical inline CSS for above-the-fold -->
<style>
*{margin:0;padding:0;box-sizing:border-box}
body{font-family:'Tajawal',sans-serif;background:#0a1628;color:#e0e0e0;direction:rtl}
.header{background:linear-gradient(135deg,#0a1628 0%,#1a2a4a 100%);padding:12px 20px;position:sticky;top:0;z-index:100}
.header-inner{display:flex;align-items:center;justify-content:space-between;max-width:1400px;margin:auto}
.logo{text-decoration:none;color:#c9a84c;display:flex;align-items:center;gap:8px}
.logo h1{font-size:1.2rem;margin:0}
.cards-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(300px,1fr));gap:20px}
.place-card{background:#111b2e;border-radius:16px;overflow:hidden;transition:transform .2s}
.place-card-image{height:180px;background:#1a2a4a;position:relative;overflow:hidden}
.card-image{width:100%;height:100%;object-fit:cover}
.skeleton{animation:skeleton-pulse 1.5s ease-in-out infinite}
@keyframes skeleton-pulse{0%,100%{opacity:.4}50%{opacity:.8}}
.place-card{content-visibility:auto;contain-intrinsic-size:0 420px}
</style>
<link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css" />
<link rel="stylesheet" href="https://unpkg.com/leaflet.markercluster@1.5.3/dist/MarkerCluster.css" />
<link rel="stylesheet" href="https://unpkg.com/leaflet.markercluster@1.5.3/dist/MarkerCluster.Default.css" />
<style>
#map-container {
max-width: var(--max-width);
margin: 0 auto;
padding: 20px;
}
#map {
width: 100%;
height: 70vh;
min-height: 400px;
border-radius: var(--radius);
box-shadow: var(--shadow);
z-index: 1;
}
.map-controls {
display: flex;
flex-wrap: wrap;
gap: 8px;
margin-bottom: 16px;
align-items: center;
}
.map-filter-chip {
padding: 8px 16px;
border: 2px solid var(--border);
border-radius: 50px;
background: var(--card-bg);
cursor: pointer;
font-family: 'Tajawal', sans-serif;
font-size: 13px;
font-weight: 600;
transition: var(--transition);
color: var(--text);
display: inline-flex;
align-items: center;
gap: 6px;
min-height: 40px;
white-space: nowrap;
}
.map-filter-chip:hover {
border-color: var(--gold);
color: var(--gold-dark);
}
.map-filter-chip.active {
background: var(--gold);
border-color: var(--gold);
color: var(--primary);
}
.map-locate-btn {
padding: 8px 18px;
background: var(--primary);
color: var(--gold);
border: 2px solid var(--primary);
border-radius: 50px;
cursor: pointer;
font-family: 'Tajawal', sans-serif;
font-size: 13px;
font-weight: 700;
transition: var(--transition);
display: inline-flex;
align-items: center;
gap: 6px;
min-height: 40px;
margin-right: auto;
}
.map-locate-btn:hover {
background: var(--primary-light);
transform: translateY(-1px);
}
.map-locate-btn.locating {
opacity: 0.7;
pointer-events: none;
}
.map-stats {
display: flex;
gap: 16px;
margin-top: 16px;
flex-wrap: wrap;
}
.map-stat {
background: var(--card-bg);
padding: 12px 20px;
border-radius: var(--radius-sm);
box-shadow: var(--shadow);
font-size: 14px;
font-weight: 600;
color: var(--text);
border-top: 3px solid var(--gold);
}
.map-stat strong {
color: var(--gold-dark);
font-size: 18px;
}
/* Leaflet popup styling */
.leaflet-popup-content-wrapper {
border-radius: var(--radius-sm) !important;
font-family: 'Tajawal', sans-serif !important;
direction: rtl;
}
.leaflet-popup-content {
margin: 12px 16px !important;
font-size: 14px;
line-height: 1.6;
min-width: 220px;
}
.popup-name {
font-size: 16px;
font-weight: 800;
color: var(--primary);
margin-bottom: 4px;
}
.popup-category {
font-size: 12px;
color: var(--text-muted);
margin-bottom: 6px;
}
.popup-rating {
display: flex;
align-items: center;
gap: 6px;
margin-bottom: 6px;
}
.popup-rating .stars {
color: var(--gold);
font-size: 13px;
}
.popup-rating .score {
font-weight: 800;
color: var(--primary);
}
.popup-desc {
font-size: 13px;
color: var(--text-light);
margin-bottom: 8px;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
}
.popup-actions {
display: flex;
gap: 8px;
}
.popup-actions a {
padding: 6px 12px;
border-radius: var(--radius-sm);
font-size: 12px;
font-weight: 700;
text-decoration: none;
transition: var(--transition);
}
.popup-link {
background: var(--gold);
color: var(--primary);
}
.popup-map-link {
background: rgba(10,22,40,0.06);
color: var(--primary);
}
.popup-trending {
display: inline-block;
background: var(--gold);
color: var(--primary);
padding: 2px 8px;
border-radius: 4px;
font-size: 11px;
font-weight: 700;
margin-bottom: 6px;
}
/* Heat Legend */
.heat-legend {
display: flex;
align-items: center;
gap: 14px;
padding: 10px 16px;
background: var(--card-bg);
border-radius: var(--radius-sm);
margin-bottom: 10px;
box-shadow: var(--shadow);
font-size: 13px;
flex-wrap: wrap;
}
.hl-title { font-weight: 700; color: var(--primary); }
.hl-item { display: inline-flex; align-items: center; gap: 5px; color: var(--text-light); }
.hl-dot { width: 12px; height: 12px; border-radius: 50%; }
.heat-marker-inner:hover { transform: scale(1.15); }
@media (max-width: 768px) {
#map-container { padding: 12px; }
#map { height: 60vh; min-height: 350px; }
.map-controls { gap: 6px; }
.map-filter-chip { padding: 6px 12px; font-size: 12px; min-height: 36px; }
.map-locate-btn { padding: 6px 14px; font-size: 12px; min-height: 36px; }
.map-stats { gap: 8px; }
.map-stat { padding: 8px 14px; font-size: 13px; }
}
</style>
<link rel="stylesheet" href="css/ramadan.css">
<link rel="stylesheet" href="css/search-header.css">
</head>
<body>
<header class="header">
<div class="header-inner">
<a href="index.html" class="logo"><span>🏙️</span><h1>وين نروح بالرياض؟</h1></a>
<button class="dark-mode-toggle" aria-label="الوضع الليلي">🌙</button>
<button class="menu-toggle" aria-label="القائمة">☰</button>
<nav class="nav">
<a href="index.html">الرئيسية</a>
<a href="cafes.html">كافيهات</a>
<a href="restaurants.html">مطاعم</a>
<a href="activities.html">ترفيه</a>
<a href="events.html">فعاليات</a>
<a href="new-places.html">جديد</a>
<a href="discover.html">🎲 وين نروح؟</a>
<a href="lists.html">📋 قوائمي</a>
<div class="nav-dropdown">
<a href="#">المزيد</a>
<div class="dropdown-menu">
<a href="shopping.html">🛍️ تسوق</a>
<a href="nature.html">🏞️ طبيعة</a>
<a href="desserts.html">🍰 حلويات</a>
<a href="top-rated.html">⭐ الأعلى تقييماً</a>
<div class="dropdown-divider"></div>
<a href="trending.html">🔥 هابّ الحين</a>
<a href="events.html">🇸🇦 يوم التأسيس</a>
<a href="riyadh-season.html">✨ موسم الرياض</a>
<div class="dropdown-divider"></div>
<div class="dropdown-submenu">
<a href="#">🏘️ الأحياء</a>
<div class="submenu">
<a href="neighborhood-olaya.html">حي العليا</a>
<a href="neighborhood-malqa.html">حي الملقا</a>
<a href="neighborhood-hittin.html">حي حطين</a>
<a href="neighborhood-yasmin.html">حي الياسمين</a>
<a href="neighborhood-rabee.html">حي الربيع</a>
</div>
</div>
</div>
</div>
</nav>
</div>
</header>
<section class="page-header">
<h2>🗺️ خريطة أماكن <span>الرياض</span></h2>
<p>اكتشف أقرب الأماكن المميزة إليك على الخريطة التفاعلية</p>
</section>
<div id="map-container">
<div class="map-controls" id="map-controls">
<button class="map-filter-chip active" data-category="all">📍 الكل</button>
<button class="map-filter-chip" data-category="كافيه">☕ كافيهات</button>
<button class="map-filter-chip" data-category="مطعم">🍽️ مطاعم</button>
<button class="map-filter-chip" data-category="ترفيه">🎭 ترفيه</button>
<button class="map-filter-chip" data-category="تسوق">🛍️ تسوق</button>
<button class="map-filter-chip" data-category="طبيعة">🏞️ طبيعة</button>
<button class="map-filter-chip" data-category="حلويات">🍰 حلويات</button>
<button class="map-filter-chip" data-category="فعاليات">🎪 فعاليات</button>
<button class="map-filter-chip" id="heat-toggle" data-category="heat" style="border-color:#e74c3c;color:#e74c3c;">🔥 خريطة الحرارة</button>
<button class="map-locate-btn" id="locate-btn">📍 موقعي</button>
</div>
<!-- Heat Legend (hidden by default) -->
<div id="heat-legend" class="heat-legend" style="display:none;">
<span class="hl-title">مفتاح الحرارة:</span>
<span class="hl-item"><span class="hl-dot" style="background:#e74c3c;"></span> حار جداً</span>
<span class="hl-item"><span class="hl-dot" style="background:#f39c12;"></span> رائج</span>
<span class="hl-item"><span class="hl-dot" style="background:#2ecc71;"></span> عادي</span>
</div>
<div id="map"></div>
<div class="map-stats" id="map-stats"></div>
</div>
<footer class="footer">
<div class="footer-inner">
<div>
<h3>وين نروح بالرياض؟</h3>
<p>دليلك الشامل لأفضل الأماكن في الرياض. محدث يومياً.</p>
</div>
<div>
<h3>الأقسام</h3>
<ul>
<li><a href="cafes.html">كافيهات الرياض</a></li>
<li><a href="restaurants.html">مطاعم الرياض</a></li>
<li><a href="activities.html">ترفيه وأنشطة</a></li>
<li><a href="map.html">🗺️ الخريطة</a></li>
<li><a href="favorites.html">❤️ المفضلة</a></li>
</ul>
</div>
<div>
<h3>روابط مفيدة</h3>
<ul>
<li><a href="sitemap.xml">خريطة الموقع</a></li>
<li><a href="#">سياسة الخصوصية</a></li>
<li><a href="#">تواصل معنا</a></li>
</ul>
</div>
</div>
<div class="footer-heart">صنع بـ <span>❤️</span> في الرياض</div>
<div class="footer-bottom"><p>© 2025-2026 وين نروح بالرياض؟ جميع الحقوق محفوظة.</p></div>
</footer>
<button class="scroll-top" id="scrollTop" aria-label="العودة للأعلى">↑</button>
<script defer src="js/darkmode.js"></script>
<script defer src="js/main.js"></script>
<script defer src="js/crowd.js"></script>
<script defer src="js/hotness.js"></script>
<script defer src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"></script>
<script defer src="https://unpkg.com/leaflet.markercluster@1.5.3/dist/leaflet.markercluster.js"></script>
<script>
// Leaflet CDN fallback
if (typeof L === 'undefined') {
document.getElementById('map').innerHTML = '<div style="display:flex;align-items:center;justify-content:center;height:100%;background:#0a1628;color:#e0e0e0;font-family:Tajawal,sans-serif;text-align:center;padding:40px;"><div><h2 style="color:#c9a84c;margin-bottom:16px;">⚠️ تعذر تحميل الخريطة</h2><p>فشل تحميل مكتبة الخرائط. تأكد من اتصالك بالإنترنت وأعد المحاولة.</p><button onclick="location.reload()" style="margin-top:16px;padding:10px 24px;background:#c9a84c;color:#0a1628;border:none;border-radius:8px;font-family:Tajawal;font-size:16px;cursor:pointer;">🔄 إعادة المحاولة</button></div></div>';
}
</script>
<script>
const CATEGORY_COLORS = {
'كافيه': { color: '#8B4513', icon: '☕', bg: '#F5DEB3' },
'مطعم': { color: '#DC143C', icon: '🍽️', bg: '#FFE4E1' },
'ترفيه': { color: '#4B0082', icon: '🎭', bg: '#E6E6FA' },
'تسوق': { color: '#FF69B4', icon: '🛍️', bg: '#FFF0F5' },
'طبيعة': { color: '#228B22', icon: '🏞️', bg: '#F0FFF0' },
'حلويات': { color: '#FF8C00', icon: '🍰', bg: '#FFF8DC' },
'فعاليات': { color: '#4169E1', icon: '🎪', bg: '#F0F8FF' },
};
function createCategoryIcon(category) {
const cat = CATEGORY_COLORS[category] || { color: '#c9a84c', icon: '📍', bg: '#fff' };
return L.divIcon({
html: `<div style="
background:${cat.bg};
border:3px solid ${cat.color};
border-radius:50%;
width:36px;height:36px;
display:flex;align-items:center;justify-content:center;
font-size:18px;
box-shadow:0 2px 8px rgba(0,0,0,0.25);
">${cat.icon}</div>`,
className: 'custom-marker',
iconSize: [36, 36],
iconAnchor: [18, 18],
popupAnchor: [0, -20],
});
}
function createPopupContent(place) {
const stars = '★'.repeat(Math.floor(place.google_rating)) + (place.google_rating % 1 >= 0.3 ? '★' : '') + '☆'.repeat(5 - Math.floor(place.google_rating) - (place.google_rating % 1 >= 0.3 ? 1 : 0));
const catNames = { 'كافيه': 'كافيه', 'مطعم': 'مطعم', 'ترفيه': 'ترفيه', 'تسوق': 'تسوق', 'طبيعة': 'طبيعة', 'حلويات': 'حلويات', 'فعاليات': 'فعاليات' };
return `
<div>
${place.trending ? '<span class="popup-trending">🔥 رائج</span>' : ''}
<div class="popup-name">${place.name_ar}</div>
<div class="popup-category">${CATEGORY_COLORS[place.category]?.icon || '📍'} ${catNames[place.category] || place.category} · ${place.neighborhood}</div>
<div class="popup-rating">
<span class="score">${place.google_rating}</span>
<span class="stars">${stars}</span>
<span style="font-size:12px;color:#888;">(${place.review_count.toLocaleString('ar-SA')})</span>
</div>
<div class="popup-desc">${place.description_ar}</div>
<div style="font-size:13px;color:var(--gold-dark);font-weight:700;margin-bottom:8px;">${place.price_level}</div>
<div class="popup-actions">
<a href="place.html?id=${place.id}" class="popup-link">اعرف أكثر</a>
<a href="${place.google_maps_url}" target="_blank" class="popup-map-link">📍 خرائط قوقل</a>
</div>
</div>
`;
}
document.addEventListener('DOMContentLoaded', async () => {
const places = await loadPlaces();
// Initialize map centered on Riyadh
const map = L.map('map', {
zoomControl: true,
}).setView([24.7136, 46.6753], 11);
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '© OpenStreetMap',
maxZoom: 18,
}).addTo(map);
// Create marker cluster group
const clusterGroup = L.markerClusterGroup({
maxClusterRadius: 50,
spiderfyOnMaxZoom: true,
showCoverageOnHover: false,
chunkedLoading: true,
iconCreateFunction: function(cluster) {
const count = cluster.getChildCount();
let size = 'small';
if (count > 10) size = 'medium';
if (count > 50) size = 'large';
const sizes = { small: 36, medium: 44, large: 52 };
return L.divIcon({
html: `<div style="
background:linear-gradient(135deg, #c9a84c, #b08d3a);
color:#0a1628;
border-radius:50%;
width:${sizes[size]}px;height:${sizes[size]}px;
display:flex;align-items:center;justify-content:center;
font-size:${size === 'large' ? 16 : 14}px;
font-weight:900;
font-family:'Tajawal',sans-serif;
box-shadow:0 3px 12px rgba(201,168,76,0.4);
border:3px solid #0a1628;
">${count}</div>`,
className: 'custom-cluster',
iconSize: [sizes[size], sizes[size]],
});
}
});
// Create markers
const allMarkers = {};
places.forEach(place => {
if (!place.lat || !place.lng) return;
const marker = L.marker([place.lat, place.lng], {
icon: createCategoryIcon(place.category),
});
marker.bindPopup(createPopupContent(place), { maxWidth: 300 });
marker.placeData = place;
if (!allMarkers[place.category]) allMarkers[place.category] = [];
allMarkers[place.category].push(marker);
});
// Add all markers initially
Object.values(allMarkers).flat().forEach(m => clusterGroup.addLayer(m));
map.addLayer(clusterGroup);
// Category filter
let activeCategory = 'all';
document.querySelectorAll('.map-filter-chip').forEach(chip => {
chip.addEventListener('click', () => {
document.querySelectorAll('.map-filter-chip').forEach(c => c.classList.remove('active'));
chip.classList.add('active');
activeCategory = chip.dataset.category;
clusterGroup.clearLayers();
if (activeCategory === 'all') {
Object.values(allMarkers).flat().forEach(m => clusterGroup.addLayer(m));
} else {
(allMarkers[activeCategory] || []).forEach(m => clusterGroup.addLayer(m));
}
updateStats(activeCategory);
});
});
// Location button
const locateBtn = document.getElementById('locate-btn');
let userMarker = null;
locateBtn.addEventListener('click', () => {
if (!navigator.geolocation) {
alert('المتصفح لا يدعم تحديد الموقع');
return;
}
locateBtn.classList.add('locating');
locateBtn.innerHTML = '⏳ جاري التحديد...';
navigator.geolocation.getCurrentPosition(
(pos) => {
const { latitude, longitude } = pos.coords;
if (userMarker) map.removeLayer(userMarker);
userMarker = L.marker([latitude, longitude], {
icon: L.divIcon({
html: `<div style="
width:20px;height:20px;
background:#4285F4;
border:4px solid white;
border-radius:50%;
box-shadow:0 2px 8px rgba(66,133,244,0.5);
"></div>`,
className: 'user-marker',
iconSize: [20, 20],
iconAnchor: [10, 10],
})
}).addTo(map);
userMarker.bindPopup('<div style="text-align:center;font-family:Tajawal,sans-serif;"><strong>📍 موقعك الحالي</strong></div>').openPopup();
map.setView([latitude, longitude], 14);
locateBtn.classList.remove('locating');
locateBtn.innerHTML = '📍 موقعي';
},
(err) => {
locateBtn.classList.remove('locating');
locateBtn.innerHTML = '📍 موقعي';
alert('تعذر تحديد موقعك. تأكد من تفعيل خدمة الموقع.');
},
{ enableHighAccuracy: true, timeout: 10000 }
);
});
// Stats
function updateStats(category) {
const filtered = category === 'all' ? places : places.filter(p => p.category === category);
const avgRating = (filtered.reduce((s, p) => s + p.google_rating, 0) / filtered.length).toFixed(1);
const trending = filtered.filter(p => p.trending).length;
document.getElementById('map-stats').innerHTML = `
<div class="map-stat">📍 <strong>${filtered.length}</strong> مكان على الخريطة</div>
<div class="map-stat">⭐ متوسط التقييم <strong>${avgRating}</strong></div>
<div class="map-stat">🔥 <strong>${trending}</strong> رائج الآن</div>
`;
}
updateStats('all');
// ===== Heat Mode Toggle =====
let heatMode = false;
let heatMarkerLayer = null;
const heatToggle = document.getElementById('heat-toggle');
const heatLegend = document.getElementById('heat-legend');
heatToggle.addEventListener('click', () => {
heatMode = !heatMode;
heatToggle.classList.toggle('active', heatMode);
if (heatMode) {
heatLegend.style.display = 'flex';
// Remove normal markers
map.removeLayer(clusterGroup);
// Create heat markers
heatMarkerLayer = L.markerClusterGroup({
maxClusterRadius: 40,
spiderfyOnMaxZoom: true,
showCoverageOnHover: false,
chunkedLoading: true,
iconCreateFunction: function(cluster) {
const count = cluster.getChildCount();
const size = count > 10 ? 48 : 40;
return L.divIcon({
html: '<div style="background:linear-gradient(135deg,#e74c3c,#c0392b);color:#fff;border-radius:50%;width:'+size+'px;height:'+size+'px;display:flex;align-items:center;justify-content:center;font-size:14px;font-weight:900;font-family:Tajawal,sans-serif;box-shadow:0 3px 12px rgba(231,76,60,0.4);border:3px solid rgba(255,255,255,0.9);">'+count+'</div>',
className: 'heat-cluster',
iconSize: [size, size],
});
}
});
// Add heat-colored markers for all places
const hotPlaces = getHottestPlaces(places, places.length);
hotPlaces.forEach((place, index) => {
if (!place.lat || !place.lng) return;
const rank = index < 20 ? index + 1 : null;
const marker = L.marker([place.lat, place.lng], {
icon: createHeatMarkerIcon(place, rank)
});
marker.bindPopup(createHeatPopup(place, rank), { maxWidth: 320 });
heatMarkerLayer.addLayer(marker);
});
map.addLayer(heatMarkerLayer);
} else {
heatLegend.style.display = 'none';
// Remove heat markers, restore normal
if (heatMarkerLayer) {
map.removeLayer(heatMarkerLayer);
heatMarkerLayer = null;
}
// Re-add normal cluster based on current filter
clusterGroup.clearLayers();
if (activeCategory === 'all') {
Object.values(allMarkers).flat().forEach(m => clusterGroup.addLayer(m));
} else {
(allMarkers[activeCategory] || []).forEach(m => clusterGroup.addLayer(m));
}
map.addLayer(clusterGroup);
}
});
});
</script>
<script>
document.querySelectorAll('.nav-dropdown > a').forEach(a => {
a.addEventListener('click', (e) => {
if (window.innerWidth <= 768) {
e.preventDefault();
a.parentElement.classList.toggle('open');
}
});
});
document.querySelectorAll('.dropdown-submenu > a').forEach(a => {
a.addEventListener('click', (e) => {
if (window.innerWidth <= 768) {
e.preventDefault();
a.nextElementSibling.style.display = a.nextElementSibling.style.display === 'block' ? 'none' : 'block';
}
});
});
</script>
<script src="js/analytics.js" defer></script>
<script src="js/ramadan.js" defer></script>
<script>
if('serviceWorker' in navigator){navigator.serviceWorker.register('sw.js').catch(function(){});}
</script>
</body>
</html>