Select City
â¾
5G
`,
className: '',
iconSize: [28, 34],
iconAnchor: [14, 34],
popupAnchor: [0, -36],
});
/* Cities dropdown */
const cities = [...new Set(LOCS.map(l => l.city))].sort();
const sel = document.getElementById('citySelect');
cities.forEach(c => {
const o = document.createElement('option');
o.value = c; o.textContent = c;
sel.appendChild(o);
});
/* Create markers */
LOCS.forEach(loc => {
const marker = L.marker([loc.lat, loc.lng], { icon: mkIcon, title: loc.name });
marker.bindPopup(infoContent(loc), { maxWidth: 240, minWidth: 200 });
marker.addTo(map);
markers.push({ marker, data: loc });
});
document.getElementById('statusText').textContent = LOCS.length + ' SITES â 5G ACTIVE ACROSS PAKISTAN';
/* Fit Pakistan */
fitBounds(LOCS);
/* Hide loader */
setTimeout(() => document.getElementById('loading').classList.add('hide'), 1200);
}
/* âââââââââââââââââââââââââââââââââââââââââââ
INFO WINDOW HTML
âââââââââââââââââââââââââââââââââââââââââââ */
function infoContent(loc) {
return `
5G ACTIVE SITE
${loc.name}
${loc.city}
${loc.lat.toFixed(4)}, ${loc.lng.toFixed(4)}
`;
}
/* âââââââââââââââââââââââââââââââââââââââââââ
FILTER
âââââââââââââââââââââââââââââââââââââââââââ */
function filterCity(city) {
activeCity = city;
map.closePopup();
const filtered = city === 'all' ? LOCS : LOCS.filter(l => l.city === city);
markers.forEach(({ marker, data }) => {
const show = city === 'all' || data.city === city;
if (show && !map.hasLayer(marker)) marker.addTo(map);
if (!show && map.hasLayer(marker)) map.removeLayer(marker);
});
document.getElementById('statusText').textContent =
city === 'all'
? filtered.length + ' SITES â 5G ACTIVE ACROSS PAKISTAN'
: filtered.length + ' SITES IN ' + city.toUpperCase();
fitBounds(filtered, city !== 'all');
}
/* âââââââââââââââââââââââââââââââââââââââââââ
FIT BOUNDS
âââââââââââââââââââââââââââââââââââââââââââ */
function fitBounds(locs, tight) {
if (!locs.length) return;
const bounds = L.latLngBounds(locs.map(l => [l.lat, l.lng]));
const pad = { padding: [80, 60] };
map.fitBounds(bounds, pad);
if (locs.length === 1) map.setZoom(15);
}