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.
80 lines
3.2 KiB
JavaScript
80 lines
3.2 KiB
JavaScript
/* eslint-disable import/no-absolute-path */
|
|
import React, { Component, Fragment } from 'react';
|
|
import { CircleMarker, Marker, Tooltip } from 'react-leaflet';
|
|
import PropTypes from 'prop-types';
|
|
import { fireIconS, fireIconM, fireIconL, nFireIcon, industryIcon, regIndustryIcon } from '/imports/ui/components/Maps/Icons';
|
|
import { withTranslation } from 'react-i18next';
|
|
import { onMarkClick } from './MarkListeners';
|
|
import FirePopup from './FirePopup';
|
|
|
|
class FireIconMark extends Component {
|
|
constructor(props) {
|
|
super(props);
|
|
this.t = props.t;
|
|
this.onClick = this.onClick.bind(this);
|
|
}
|
|
|
|
onClick() {
|
|
const { history, nasa, id } = this.props;
|
|
onMarkClick(history, nasa, id);
|
|
}
|
|
|
|
// Some docs:
|
|
// https://earthdata.nasa.gov/what-is-new-collection-6-modis-active-fire-data
|
|
// https://cdn.earthdata.nasa.gov/conduit/upload/3865/MODIS_C6_Fire_User_Guide_A.pdf
|
|
getIcon(scan) {
|
|
if (scan <= 1) return fireIconS;
|
|
if (scan <= 2) return fireIconM;
|
|
return fireIconL;
|
|
}
|
|
|
|
render() {
|
|
const {
|
|
lat, lon, scan, track, nasa, id, history, falsePositives, industries, neighbour, when, t
|
|
} = this.props;
|
|
return (
|
|
<Fragment>
|
|
{ !falsePositives && !industries &&
|
|
<Marker position={[lat, lon]} icon={nasa ? this.getIcon(scan) : nFireIcon} eventHandlers={{ click: this.onClick }} >
|
|
<FirePopup t={t} history={history} id={id} nasa={nasa} lat={lat} lon={lon} when={when} />
|
|
</Marker> }
|
|
{ industries && <Marker position={[lat, lon]} icon={regIndustryIcon}>
|
|
<Tooltip><Fragment>{t('Es una industria (fuente: registro oficial)')}</Fragment></Tooltip>
|
|
</Marker> }
|
|
{ /* disabled */ industries && false && <CircleMarker
|
|
center={[lat, lon]}
|
|
radius={1}
|
|
pathOptions={{ color: 'violet', stroke: false, fillOpacity: 1, fill: true }}
|
|
/>}
|
|
{ falsePositives && !industries &&
|
|
<Marker position={[lat, lon]} icon={industryIcon} eventHandlers={{ click: this.onClick }}>
|
|
<Tooltip><Fragment>{t('Es una industria (fuente: nuestros usuarios/as)')}</Fragment></Tooltip>
|
|
{ /* disabled because was a past fire (and can be marked multiple times) */ false && <FirePopup t={t} history={history} id={id} lat={lat} lon={lon} /> }
|
|
</Marker>
|
|
}
|
|
{ !falsePositives && !industries &&
|
|
<CircleMarker center={[lat, lon]} radius={1} pathOptions={{ color: nasa ? 'red' : '#D35400', stroke: false, fillOpacity: 1, fill: true }} eventHandlers={{ click: this.onClick }}>
|
|
<FirePopup t={t} history={history} id={id} nasa={nasa} lat={lat} lon={lon} when={when} />
|
|
</CircleMarker> }
|
|
</Fragment>
|
|
);
|
|
}
|
|
}
|
|
|
|
FireIconMark.propTypes = {
|
|
// https://github.com/PaulLeCam/react-leaflet/tree/master/src/propTypes
|
|
lat: PropTypes.number.isRequired,
|
|
lon: PropTypes.number.isRequired,
|
|
scan: PropTypes.number,
|
|
track: PropTypes.number,
|
|
nasa: PropTypes.bool,
|
|
falsePositives: PropTypes.bool.isRequired,
|
|
industries: PropTypes.bool.isRequired,
|
|
neighbour: PropTypes.bool.isRequired,
|
|
id: PropTypes.object.isRequired,
|
|
history: PropTypes.object.isRequired,
|
|
when: PropTypes.instanceOf(Date),
|
|
t: PropTypes.func.isRequired
|
|
};
|
|
|
|
export default withTranslation()(FireIconMark);
|