v5: исправлен поиск и навигация по селу
This commit is contained in:
parent
b19adaf278
commit
e44907f283
@ -29,6 +29,9 @@ body{font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Inter,system-ui,san
|
||||
.map-mode-btn.active{border-color:#0f172a;background:#0f172a;color:#fff}
|
||||
input,select{width:100%;padding:10px 14px;border:1px solid #e2e8f0;border-radius:8px;font-size:14px;background:#fff;outline:none}
|
||||
input:focus,select:focus{border-color:#0f172a}
|
||||
select{max-height:200px;overflow-y:auto}
|
||||
#village option,#rayon option{padding:4px 6px;font-size:13px}
|
||||
#searchResults{max-height:300px;overflow-y:auto}
|
||||
table{width:100%;border-collapse:collapse;font-size:14px}
|
||||
table th{text-align:left;padding:10px 16px;font-size:12px;text-transform:uppercase;letter-spacing:.05em;color:#64748b;border-bottom:2px solid #e2e8f0}
|
||||
table td{padding:10px 16px;border-bottom:1px solid #f1f5f9}
|
||||
|
||||
30
js/app.js
30
js/app.js
@ -148,8 +148,36 @@ function initSelectors() {
|
||||
if (center) map.setView(center, 10);
|
||||
});
|
||||
|
||||
function findVillageData(name) {
|
||||
const q = name.toLowerCase().trim();
|
||||
for (const o of KZ_DATA) {
|
||||
for (const r of o.rayons) {
|
||||
for (const v of r.villages) {
|
||||
if (v.toLowerCase() === q) {
|
||||
return { village: v, rayon: r.rayon, oblast: o.oblast, center: r.center || o.center };
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function goToVillage(name) {
|
||||
if (!name) return;
|
||||
const found = findVillageData(name);
|
||||
if (found) {
|
||||
oblastSel.value = found.oblast;
|
||||
updateRayons();
|
||||
rayonSel.value = found.rayon;
|
||||
updateVillages();
|
||||
villageSel.value = found.village;
|
||||
map.setView(found.center, 13);
|
||||
L.popup()
|
||||
.setLatLng(found.center)
|
||||
.setContent(`<b>${found.village}</b><br>${found.oblast}, ${found.rayon}`)
|
||||
.openOn(map);
|
||||
return;
|
||||
}
|
||||
const oblast = KZ_DATA.find((o) => o.oblast === oblastSel.value);
|
||||
if (!oblast) return;
|
||||
const rayon = oblast.rayons.find((r) => r.rayon === rayonSel.value);
|
||||
@ -195,7 +223,7 @@ function initSelectors() {
|
||||
list.innerHTML = "<li class='px-3 py-2 text-gray-500'>Не найдено</li>";
|
||||
return;
|
||||
}
|
||||
results.slice(0, 30).forEach((r) => {
|
||||
results.slice(0, 50).forEach((r) => {
|
||||
const li = document.createElement("li");
|
||||
li.className = "px-3 py-2 cursor-pointer hover:bg-cyan-50";
|
||||
li.textContent = `${r.village} — ${r.rayon}, ${r.oblast}`;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user