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);
|
oblastSel.addEventListener("change", function() {
|
||||||
rayonSel.addEventListener("change", updateVillages);
|
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) {
|
function goToVillage(name) {
|
||||||
if (!name) return;
|
if (!name) return;
|
||||||
const oblast = KZ_DATA.find((o) => o.oblast === oblastSel.value);
|
const oblast = KZ_DATA.find((o) => o.oblast === oblastSel.value);
|
||||||
if (!oblast) return;
|
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()
|
L.popup()
|
||||||
.setLatLng(oblast.center)
|
.setLatLng(center)
|
||||||
.setContent(`<b>${name}</b><br>${oblast.oblast}, ${rayonSel.value}`)
|
.setContent(`<b>${name}</b><br>${oblast.oblast}, ${rayon ? rayon.rayon : ''}`)
|
||||||
.openOn(map);
|
.openOn(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -173,7 +186,7 @@ function initSelectors() {
|
|||||||
o.rayons.forEach((r) => {
|
o.rayons.forEach((r) => {
|
||||||
r.villages.forEach((v) => {
|
r.villages.forEach((v) => {
|
||||||
if (v.toLowerCase().includes(q)) {
|
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