From 10f075bb71cc6d608013c438a0152de39e946618 Mon Sep 17 00:00:00 2001 From: Rassmagin Alexander Date: Mon, 25 Nov 2024 02:15:21 +0300 Subject: [PATCH] map center on move --- public/components/Search/Search.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/public/components/Search/Search.js b/public/components/Search/Search.js index 753c0d2..a545979 100644 --- a/public/components/Search/Search.js +++ b/public/components/Search/Search.js @@ -233,8 +233,22 @@ export class Search { }); // Добавляем новую метку на карту myMap.geoObjects.add(this.currentPlacemark); + // Smoothly move the map to the selected coordinates + myMap.setCenter(coords, zoom, { + checkZoomRange: true, + duration: 300 // duration in milliseconds + }); + console.log(myMap.getCenter()); console.log(selectedPoint); }); + myMap.events.add('boundschange', (e) => { + // Получаем текущий центр карты + const currentCenter = myMap.getCenter(); + const currentZoom = myMap.getZoom(); + + console.log("Current Center after change:", currentCenter); + console.log("Current Zoom Level:", currentZoom); + }); } } \ No newline at end of file