"use client"; // Auteur : Simon-Pierre Boucher — contact@spboucher.ai // Projet : Groupe Ka / Ka Maps (intégration Vrai-Prix) // components/KaCarte.tsx : Vrai-Prix Maps — recherche par carte propulsée // par le framework partagé Ka Maps (moteur Mapbox GL, style Standard 3D par // défaut + bouton 2D). Remplace l'ancienne carte Leaflet/OSM : pastilles de // VALEURS ESTIMÉES 2026 (grappes + moyennes), chargement piloté par le // viewport (annulation, cache), aperçu React, bilingue FR/EN. // À charger via next/dynamic({ ssr: false }) — Mapbox GL est navigateur-seul. import { useState } from "react"; import { useRouter } from "next/navigation"; import "mapbox-gl/dist/mapbox-gl.css"; import "@groupe-ka/ka-maps/styles.css"; import type { MapProperty } from "@groupe-ka/ka-maps"; import { formatFullPrice } from "@groupe-ka/ka-maps"; import { KaBrandBadge, KaMapView, LoadingIndicator, LocateControl, PropertyPreview, Tilt3DControl, } from "@groupe-ka/ka-maps/react"; import { useLang } from "@/components/LangContext"; import { MAPBOX_TOKEN, MIN_ZOOM_FETCH, vraiPrixMapAdapter, vraiPrixMapTheme, } from "@/lib/kamaps"; const DEFAULT_CENTER = { lat: 45.5421, lng: -73.6646 }; // Montréal /** Aperçu d'une unité d'évaluation — valeur estimée, jamais un prix. */ function PreviewCard({ p, fr, close }: { p: MapProperty; fr: boolean; close: () => void }) { const router = useRouter(); return (
{fr ? "Estimation 2026" : "2026 estimate"}
{p.estimatedValue != null ? formatFullPrice(p.estimatedValue) : "—"}
{p.address}
{[p.city, p.propertyType].filter(Boolean).join(" · ")}
); } export default function KaCarte() { const { lang } = useLang(); const fr = lang === "fr"; const [zoom, setZoom] = useState(13); const [count, setCount] = useState(null); const zoomedOut = zoom < MIN_ZOOM_FETCH; return (
setZoom(z)} onData={(c) => setCount(c)} > } />
{zoomedOut ? fr ? "Zoomez pour voir les valeurs estimées" : "Zoom in to see estimated values" : count != null ? fr ? `${count.toLocaleString("fr-CA")} propriétés affichées` : `${count.toLocaleString("en-CA")} properties shown` : fr ? "Chargement…" : "Loading…"}
); }