Ground-up hooks rewrite of the app's core map. Removes the final batch of
React-19-blocking warnings (legacy context on Map/LayersControl/TileLayer/
Marker/CircleMarker/Circle/Tooltip + ReactDOM.render from the old controls).
Core: <Map> -> <MapContainer>; .leafletElement refs (6 files) -> the map/
layer instances directly, via a <MapReady> child (useMap) + plain refs on
Marker/Circle/GeoJSON; controlled viewport (onViewportChanged + state.center/
zoom) -> <MapEvents> (useMapEvents moveend/zoomend) + imperative setView;
onClick -> eventHandlers={{click}}; Path styling -> pathOptions/style;
subsUnion takes the L.Map directly.
The 4 v1-only plugins reimplemented (new in-repo helpers under Maps/):
- react-leaflet-control -> MapControl (L.Control + createPortal)
- react-leaflet-google -> GoogleMutantLayer (createLayerComponent +
leaflet.gridlayer.googlemutant; Google Maps API already loaded by Gkeys)
- react-leaflet-fullscreen -> createControlComponent + leaflet.fullscreen
- leaflet-sleep / leaflet-graphicscale kept as vanilla (work on leaflet 1.9)
Browser-verified: /fires (tiles, OSM+Google layer switch, custom control,
fullscreen, graphic scale, pan/zoom -> re-fetch, no NaN), fire detail
(GeoJSON rect + fitBounds), home (3 maps coexist; SelectionMap draggable
marker -> updatePosition + distance circle). Console now shows 0 React
warnings on home/fires. REST smoke byte-identical.
30 lines
966 B
JavaScript
30 lines
966 B
JavaScript
/* eslint-disable react/jsx-indent-props */
|
|
/* eslint-disable import/no-absolute-path */
|
|
|
|
import React from 'react';
|
|
import PropTypes from 'prop-types';
|
|
import { withTranslation } from 'react-i18next';
|
|
import { createControlComponent } from '@react-leaflet/core';
|
|
import L from 'leaflet';
|
|
import 'leaflet.fullscreen';
|
|
import 'leaflet.fullscreen/Control.FullScreen.css';
|
|
|
|
// Replacement for react-leaflet-fullscreen (v1-only): wrap the vanilla
|
|
// leaflet.fullscreen control with react-leaflet v4's control factory.
|
|
const FullscreenControl = createControlComponent(
|
|
({ position = 'topleft', title, titleCancel }) => L.control.fullscreen({ position, title, titleCancel })
|
|
);
|
|
|
|
const FullScreenMap = ({ t }) => (
|
|
<FullscreenControl
|
|
position="topleft"
|
|
title={t('Pantalla completa')}
|
|
titleCancel={t('Salir de pantalla completa')}
|
|
/>
|
|
);
|
|
|
|
FullScreenMap.propTypes = {
|
|
t: PropTypes.func.isRequired
|
|
};
|
|
|
|
export default withTranslation()(FullScreenMap);
|