"use client"; import React, { useEffect, useRef } from "react"; interface YandexMapProps { lat?: number; lng?: number; zoom?: number; } export default function YandexMap({ lat = 41.3111, lng = 69.2406, zoom = 12, }: YandexMapProps) { const mapRef = useRef(null); useEffect(() => { // Yandex Map scriptini dinamik yuklash if (!window.ymaps) { const script = document.createElement("script"); script.src = "https://api-maps.yandex.ru/2.1/?lang=ru_RU&apikey=5169ae9d-529a-43f8-9cb1-30e1a3360dac"; script.async = true; script.onload = () => initMap(); document.body.appendChild(script); } else { initMap(); } function initMap() { if (!mapRef.current || !window.ymaps) return; window.ymaps.ready(() => { const map = new window.ymaps.Map(mapRef.current!, { center: [lat, lng], zoom, controls: ["zoomControl", "typeSelector", "fullscreenControl"], }); const placemark = new window.ymaps.Placemark( [lat, lng], { balloonContent: `
Bizning joylashuv:
Toshkent sh., Mustaqillik maydoni
Yandex xaritada ochish
`, }, { iconColor: "#ff0000", draggable: false, } ); map.geoObjects.add(placemark); }); } }, [lat, lng, zoom]); return (
); }