v7: увеличен зум, навигация через findVillageData
This commit is contained in:
parent
655784582f
commit
a2d748e985
15
js/app.js
15
js/app.js
@ -179,7 +179,7 @@ function initSelectors() {
|
|||||||
rayonSel.value = found.rayon;
|
rayonSel.value = found.rayon;
|
||||||
updateVillages();
|
updateVillages();
|
||||||
villageSel.value = found.village;
|
villageSel.value = found.village;
|
||||||
map.setView(found.center, 13);
|
map.setView(found.center, 15);
|
||||||
L.popup()
|
L.popup()
|
||||||
.setLatLng(found.center)
|
.setLatLng(found.center)
|
||||||
.setContent(`<b>${found.village}</b><br>${found.oblast}, ${found.rayon}`)
|
.setContent(`<b>${found.village}</b><br>${found.oblast}, ${found.rayon}`)
|
||||||
@ -200,15 +200,10 @@ function initSelectors() {
|
|||||||
villageSel.addEventListener("change", function () {
|
villageSel.addEventListener("change", function () {
|
||||||
const name = this.value;
|
const name = this.value;
|
||||||
if (!name) return;
|
if (!name) return;
|
||||||
const oblast = KZ_DATA.find((o) => o.oblast === oblastSel.value);
|
const found = findVillageData(name);
|
||||||
if (!oblast) return;
|
if (found && found.center) {
|
||||||
const rayon = oblast.rayons.find((r) => r.rayon === rayonSel.value);
|
map.setView(found.center, 15);
|
||||||
if (!rayon) return;
|
L.popup().setLatLng(found.center).setContent(`<b>${found.village}</b><br>${found.oblast}, ${found.rayon}`).openOn(map);
|
||||||
const village = rayon.villages.find((v) => (typeof v === "string" ? v : v.name) === name);
|
|
||||||
const center = getVillageCenter(village) || (rayon ? rayon.center : null) || oblast.center;
|
|
||||||
if (center) {
|
|
||||||
map.setView(center, 14);
|
|
||||||
L.popup().setLatLng(center).setContent(`<b>${name}</b><br>${oblast.oblast}, ${rayon.rayon}`).openOn(map);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user