修复 lint warnings
This commit is contained in:
@@ -59,6 +59,32 @@ const AnalysisParameters: React.FC = () => {
|
||||
);
|
||||
}, [network, startTime, sourceNode, concentration, duration, schemeName]);
|
||||
|
||||
const handleMapClickSelectFeatures = useCallback(
|
||||
async (event: { coordinate: number[] }) => {
|
||||
if (!map) return;
|
||||
const feature = await mapClickSelectFeatures(event, map);
|
||||
if (!feature) return;
|
||||
|
||||
const layerId = feature.getId()?.toString().split(".")[0] || "";
|
||||
const isJunction = layerId.includes("junction");
|
||||
if (!isJunction) {
|
||||
open?.({
|
||||
type: "error",
|
||||
message: "请选择节点类型要素作为污染源。",
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
const id = feature.getProperties().id;
|
||||
if (!id) return;
|
||||
setSourceNode(id);
|
||||
setHighlightFeature(feature);
|
||||
setIsSelecting(false);
|
||||
map.un("click", handleMapClickSelectFeatures);
|
||||
},
|
||||
[map, open],
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
if (!map) return;
|
||||
|
||||
@@ -106,7 +132,7 @@ const AnalysisParameters: React.FC = () => {
|
||||
map.removeLayer(layer);
|
||||
map.un("click", handleMapClickSelectFeatures);
|
||||
};
|
||||
}, [map]);
|
||||
}, [map, handleMapClickSelectFeatures]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!highlightLayer) return;
|
||||
@@ -118,32 +144,6 @@ const AnalysisParameters: React.FC = () => {
|
||||
}
|
||||
}, [highlightFeature, highlightLayer]);
|
||||
|
||||
const handleMapClickSelectFeatures = useCallback(
|
||||
async (event: { coordinate: number[] }) => {
|
||||
if (!map) return;
|
||||
const feature = await mapClickSelectFeatures(event, map);
|
||||
if (!feature) return;
|
||||
|
||||
const layerId = feature.getId()?.toString().split(".")[0] || "";
|
||||
const isJunction = layerId.includes("junction");
|
||||
if (!isJunction) {
|
||||
open?.({
|
||||
type: "error",
|
||||
message: "请选择节点类型要素作为污染源。",
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
const id = feature.getProperties().id;
|
||||
if (!id) return;
|
||||
setSourceNode(id);
|
||||
setHighlightFeature(feature);
|
||||
setIsSelecting(false);
|
||||
map.un("click", handleMapClickSelectFeatures);
|
||||
},
|
||||
[map, open],
|
||||
);
|
||||
|
||||
const handleStartSelection = () => {
|
||||
if (!map) return;
|
||||
setIsSelecting(true);
|
||||
|
||||
Reference in New Issue
Block a user