v4: разное кол-во сёл в районах, навигация по району
This commit is contained in:
parent
e9e3b342c0
commit
b19adaf278
25
js/app.js
25
js/app.js
@ -134,17 +134,30 @@ function initSelectors() {
|
||||
});
|
||||
}
|
||||
|
||||
oblastSel.addEventListener("change", updateRayons);
|
||||
rayonSel.addEventListener("change", updateVillages);
|
||||
oblastSel.addEventListener("change", function() {
|
||||
updateRayons();
|
||||
const oblast = KZ_DATA.find((o) => o.oblast === this.value);
|
||||
if (oblast) map.setView(oblast.center, 8);
|
||||
});
|
||||
rayonSel.addEventListener("change", function() {
|
||||
updateVillages();
|
||||
const oblast = KZ_DATA.find((o) => o.oblast === oblastSel.value);
|
||||
if (!oblast) return;
|
||||
const rayon = oblast.rayons.find((r) => r.rayon === this.value);
|
||||
const center = (rayon && rayon.center) ? rayon.center : (oblast ? oblast.center : null);
|
||||
if (center) map.setView(center, 10);
|
||||
});
|
||||
|
||||
function goToVillage(name) {
|
||||
if (!name) return;
|
||||
const oblast = KZ_DATA.find((o) => o.oblast === oblastSel.value);
|
||||
if (!oblast) return;
|
||||
map.setView(oblast.center, 12);
|
||||
const rayon = oblast.rayons.find((r) => r.rayon === rayonSel.value);
|
||||
const center = (rayon && rayon.center) ? rayon.center : oblast.center;
|
||||
map.setView(center, 12);
|
||||
L.popup()
|
||||
.setLatLng(oblast.center)
|
||||
.setContent(`<b>${name}</b><br>${oblast.oblast}, ${rayonSel.value}`)
|
||||
.setLatLng(center)
|
||||
.setContent(`<b>${name}</b><br>${oblast.oblast}, ${rayon ? rayon.rayon : ''}`)
|
||||
.openOn(map);
|
||||
}
|
||||
|
||||
@ -173,7 +186,7 @@ function initSelectors() {
|
||||
o.rayons.forEach((r) => {
|
||||
r.villages.forEach((v) => {
|
||||
if (v.toLowerCase().includes(q)) {
|
||||
results.push({ village: v, rayon: r.rayon, oblast: o.oblast, center: o.center });
|
||||
results.push({ village: v, rayon: r.rayon, oblast: o.oblast, center: r.center || o.center });
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
3106
js/kz-data.js
3106
js/kz-data.js
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user