'use client'; import React, { useEffect, useState } from 'react' import { Circle, LayerGroup, LayersControl, MapContainer, Marker, Popup, TileLayer, useMap } from 'react-leaflet' import 'leaflet-defaulticon-compatibility/dist/leaflet-defaulticon-compatibility.css' import "leaflet-defaulticon-compatibility"; import "leaflet/dist/leaflet.css"; import useGame from '@/hook/useGame'; import { useTeamContext } from '@/context/teamContext'; import { useTilesColor } from '@/hook/mapDrawing'; import { MapGridZoneSelector } from '../admin/mapZoneSelector'; import { TILE_SIZE } from '../admin/maps'; const DEFAULT_ZOOM = 17; // Pan to the center of the map when the position of the user is updated for the first time function MapPan(props) { const map = useMap(); const [initialized, setInitialized] = useState(false); useEffect(() => { if (!initialized && props.center) { map.flyTo(props.center, DEFAULT_ZOOM, { animate: false }); setInitialized(true) } }, [props.center]); return null; } export function LiveMap({ ...props }) { const {zone} = useTeamContext(); const tilesColor = useTilesColor(zone); const { currentPosition, enemyPosition } = useGame(); return ( {currentPosition && Votre position } {enemyPosition && Position de l'ennemi } {}} tileSize={TILE_SIZE}/> ) } export function PlacementMap({ ...props }) { const { currentPosition, startingArea } = useGame(); return ( {currentPosition && Votre position } {startingArea && } ) }