Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 49 additions & 1 deletion apps/geoportal/src/app/components/GeoportalMap/GeoportalMap.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import L from "leaflet";
import proj4 from "proj4";
import { getFromWebMercatorToWGS84 } from "@carma-geo/proj";
import { FeatureInfoRectangleLayer } from "@carma-appframeworks/envirometrics";
import {
useCallback,
useContext,
Expand Down Expand Up @@ -110,7 +112,10 @@ import { useObliqueInitializer } from "../../oblique/hooks/useObliqueInitializer
import { useCameraOrbit } from "../../hooks/useCameraOrbit.ts";
import { useGeoportalInitialValues } from "../../hooks/useGeoportalInitialValues.ts";

import { onClickTopicMap } from "./topicmap.utils.ts";
import {
onClickTopicMap,
type FeatureInfoRectangle,
} from "./topicmap.utils.ts";
import { useGeoportalCesiumNavigationRestore } from "./hooks/useGeoportalCesiumNavigationRestore.ts";
import { useCreateCismapLayers } from "./hooks/useCreateCismapLayer.ts";

Expand Down Expand Up @@ -368,6 +373,8 @@ const GeoportalMapInner = ({ height, width, allow3d }: MapProps) => {
const markerRef = useRef(undefined);
const markerAccentRef = useRef(undefined);
const [pos, setPos] = useState<[number, number] | null>(null);
const [featureInfoRectangle, setFeatureInfoRectangle] =
useState<FeatureInfoRectangle | null>(null);
// TODO: move all these to a custom hook and collect all calls to updateFeatureInfo there
const [shouldUpdateFeatureInfo, setShouldUpdateFeatureInfo] =
useState<boolean>(false);
Expand Down Expand Up @@ -815,6 +822,36 @@ const GeoportalMapInner = ({ height, width, allow3d }: MapProps) => {
}
}, [maplibreMaps]);

useEffect(() => {
if (uiMode !== UIMode.DEFAULT) {
setFeatureInfoRectangle(null);
}
}, [uiMode]);

useEffect(() => {
if (uiMode !== UIMode.DEFAULT || !selectedFeature) {
return;
}
const layerWithSelectedFeature = layers.find(
(l) => l.id === selectedFeature.id
);
if (layerWithSelectedFeature && !layerWithSelectedFeature.visible) {
dispatch(setSelectedFeature(null));
dispatch(setSecondaryInfoBoxElements([]));
dispatch(setFeatures([]));
setFeatureInfoRectangle(null);
}
}, [layers, selectedFeature, uiMode, dispatch]);

const hasPointInfoLayer = useMemo(
() =>
layers.some(
(layer) =>
layer.visible && layer.conf !== undefined && "pointInfo" in layer.conf
),
[layers]
);

useEffect(() => {
const leaflet = getLeafletMap();

Expand Down Expand Up @@ -1227,6 +1264,7 @@ const GeoportalMapInner = ({ height, width, allow3d }: MapProps) => {
zoom: getLeafletZoom(),
map: map,
maplibreMapsRef,
setFeatureInfoRectangle,
});
}}
gazetteerSearchControl={true}
Expand All @@ -1243,6 +1281,16 @@ const GeoportalMapInner = ({ height, width, allow3d }: MapProps) => {
)}

{useCreateCismapLayers(layers, createLayerOptions)}
{hasPointInfoLayer &&
uiMode === UIMode.DEFAULT &&
featureInfoRectangle && (
<FeatureInfoRectangleLayer
position={featureInfoRectangle.position}
upperleftX={featureInfoRectangle.upperleftX}
upperleftY={featureInfoRectangle.upperleftY}
pixelsize={featureInfoRectangle.pixelsize}
/>
)}
<PrintPreview />
<Measurements snappingLayers={maplibreMaps} />
</TopicMapComponent>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,7 @@ const LibreGeoportalMap = ({
store,
zoom: map.current?.getZoom() + 1,
map: map.current,
setFeatureInfoRectangle: () => undefined,
}
);
} else {
Expand Down
Loading
Loading