SPB Git

Repository Public

MapClient.tsx 2.8 KB 82 lines tsx

1/**2 * =============================================================================3 *                  SP BOUCHER | SOFTWARE & RESEARCH4 *             ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5 * =============================================================================6 *7 * Project          : KA Maps Engine8 * File             : sdk/web/tests/next-app/app/MapClient.tsx9 * Module           : sdk10 * Repository       : https://git.spboucher.ai/ka-maps-engine11 * Created          : 2026-12-0112 * Last Modified    : 2026-12-0113 *14 * Author           : Simon-Pierre Boucher15 * Position         : Professor of Finance16 * Institution      : Université du Québec en Outaouais (UQO)17 * Organization     : SP Boucher18 * Website          : https://spboucher.ai19 * Git              : https://git.spboucher.ai20 *21 * Preferred Contact: support@spboucher.ai22 * Development      : dev@spboucher.ai23 * Support          : support@spboucher.ai24 * Security/Admin   : admin@spboucher.ai25 *26 * Copyright (c) 202627 * Simon-Pierre Boucher28 * All rights reserved where applicable. This file is governed by the29 * applicable project license, copyright notices and relevant law.30 * Existing third-party rights and notices remain unaffected.31 *32 * License          : None specified (no license file in this repository)33 *34 * Do not embed credentials, private keys, access tokens,35 * certificates or confidential personal information.36 *37 * =============================================================================38 * END OF SP BOUCHER SOURCE HEADER39 * =============================================================================40 */4142'use client';43import { useState } from 'react';44import { KaLayer, KaMapView, useKaMapEvent } from '@ka/maps/react';45import type { KaMap } from '@ka/maps';4647declare global {48  interface Window {49    __kaNext?: { ready: boolean; error?: string; map?: KaMap };50  }51}5253function Ready() {54  useKaMapEvent('load', () => {55    window.__kaNext = { ...window.__kaNext, ready: true };56  });57  return null;58}5960export default function MapClient({ center }: { center: [number, number] }) {61  const [error, setError] = useState<string | null>(null);62  return (63    <KaMapView64      className="carte"65      aria-label="Carte d’essai Next.js"66      options={{ center, zoom: 15, app: 'louka', controls: true }}67      onReady={(map) => {68        window.__kaNext = { ready: map.isLoaded, map };69      }}70      onError={(e) => {71        window.__kaNext = { ready: false, error: `${e.code}: ${e.message}` };72        setError(e.message);73      }}74      fallback={<p role="alert">Carte indisponible{error ? ` : ${error}` : ''}</p>}75      loading={<p>Chargement de la carte…</p>}76    >77      <Ready />78      <KaLayer id="adresse" type="markers" data={[{ id: 'a', lon: center[0], lat: center[1], label: 'Ici', value: 1 }]} />79    </KaMapView>80  );81}82
Files main
Menu

Theme