From cdc66330916461aefca105354d712ec520f5614e Mon Sep 17 00:00:00 2001 From: Davron Chetin Date: Wed, 8 Oct 2025 15:11:25 +0500 Subject: [PATCH] maps --- app/page.tsx | 2 + components/google.map.tsx | 77 +++++++++++++++++++++++++++++++ components/pageParts/faq.tsx | 2 +- components/pageParts/map.tsx | 42 +++++++++++++++++ components/pageParts/offer.tsx | 2 +- components/pageParts/partners.tsx | 9 +++- components/pageParts/products.tsx | 2 +- components/pageParts/texnika.tsx | 15 +++--- components/{tools => }/title.tsx | 2 +- package-lock.json | 70 +++++++++++++++++++++++----- package.json | 5 +- 11 files changed, 204 insertions(+), 24 deletions(-) create mode 100644 components/google.map.tsx create mode 100644 components/pageParts/map.tsx rename components/{tools => }/title.tsx (90%) diff --git a/app/page.tsx b/app/page.tsx index c64354e..3571fd1 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -6,6 +6,7 @@ import Texnika from "@/components/pageParts/texnika"; import Offer from "@/components/pageParts/offer"; import Faq from "@/components/pageParts/faq"; import Partners from "@/components/pageParts/partners"; +import Map from "@/components/pageParts/map"; export default function Home() { return ( @@ -19,6 +20,7 @@ export default function Home() { + ); } diff --git a/components/google.map.tsx b/components/google.map.tsx new file mode 100644 index 0000000..0498b08 --- /dev/null +++ b/components/google.map.tsx @@ -0,0 +1,77 @@ +"use client"; +/// + +import { useEffect, useRef } from "react"; +import Script from "next/script"; + +declare global { + interface Window { + initMap?: () => void; + google?: typeof google; + } +} + +type Props = { lat?: number; lng?: number; zoom?: number }; + +export default function GoogleMap({ + lat = 41.2628056, // rasmda ko‘rsatilgan koordinata (41°15'46.1"N 69°13'08.8"E) + lng = 69.2191111, + zoom = 17, +}: Props) { + const mapRef = useRef(null); + + useEffect(() => { + window.initMap = () => { + if (!mapRef.current || !window.google) return; + + const center = new google.maps.LatLng(lat, lng); + const map = new google.maps.Map(mapRef.current, { + center, + zoom, + mapTypeControl: true, // 🛰 Satellite tugmasi + streetViewControl: true, // Street View tugmasi + fullscreenControl: true, // Fullscreen + zoomControl: true, // Zoom tugmalari + mapTypeControlOptions: { + style: google.maps.MapTypeControlStyle.DEFAULT, + position: google.maps.ControlPosition.RIGHT_BOTTOM, // Chap pastga Satellite + }, + }); + + // 📌 Marker + new google.maps.Marker({ + position: center, + map, + title: "Bizning manzil", + }); + + // 🧭 Koordinata oynasini yaratamiz + const coordDiv = document.createElement("div"); + coordDiv.style.background = "#fff"; + coordDiv.style.padding = "15px 30px"; + coordDiv.style.margin = "15px 30px"; + coordDiv.style.boxShadow = "0 2px 6px rgba(0,0,0,0.3)"; + coordDiv.innerHTML = ` +
+ 41°15'46.1"N 69°13'08.8"E
+ View larger map +
+ `; + map.controls[google.maps.ControlPosition.TOP_LEFT].push(coordDiv); + }; + + if (window.google && window.google.maps && typeof window.initMap === "function") { + window.initMap(); + } + }, [lat, lng, zoom]); + + return ( + <> +