fix(geoportal): show UAT name in search results + fix map snap-back
Search results now JOIN GisUat to display UAT name prominently instead of just SIRUTA codes. Map flyTo uses imperative handle instead of stateful props that re-triggered on re-renders. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -32,8 +32,6 @@ export function GeoportalModule() {
|
||||
const [clickedFeature, setClickedFeature] = useState<ClickedFeature | null>(null);
|
||||
const [selectionMode, setSelectionMode] = useState<SelectionMode>("off");
|
||||
const [selectedFeatures, setSelectedFeatures] = useState<SelectedFeature[]>([]);
|
||||
const [flyTarget, setFlyTarget] = useState<{ center: [number, number]; zoom?: number } | undefined>();
|
||||
|
||||
const handleFeatureClick = useCallback((feature: ClickedFeature | null) => {
|
||||
// null = clicked on empty space, close panel
|
||||
if (!feature || !feature.properties) {
|
||||
@@ -45,7 +43,7 @@ export function GeoportalModule() {
|
||||
|
||||
const handleSearchResult = useCallback((result: SearchResult) => {
|
||||
if (result.coordinates) {
|
||||
setFlyTarget({ center: result.coordinates, zoom: result.type === "uat" ? 12 : 17 });
|
||||
mapHandleRef.current?.flyTo(result.coordinates, result.type === "uat" ? 12 : 17);
|
||||
}
|
||||
}, []);
|
||||
|
||||
@@ -67,8 +65,6 @@ export function GeoportalModule() {
|
||||
onFeatureClick={handleFeatureClick}
|
||||
onSelectionChange={setSelectedFeatures}
|
||||
layerVisibility={layerVisibility}
|
||||
center={flyTarget?.center}
|
||||
zoom={flyTarget?.zoom}
|
||||
/>
|
||||
|
||||
{/* Setup banner (auto-hides when ready) */}
|
||||
|
||||
@@ -845,12 +845,6 @@ export const MapViewer = forwardRef<MapViewerHandle, MapViewerProps>(
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [resolvedMartinUrl, basemap]);
|
||||
|
||||
/* ---- Sync center/zoom prop changes (from search flyTo) ---- */
|
||||
useEffect(() => {
|
||||
if (!mapReady || !mapRef.current || !center) return;
|
||||
mapRef.current.flyTo({ center, zoom: zoom ?? mapRef.current.getZoom(), duration: 1500 });
|
||||
}, [center, zoom, mapReady]);
|
||||
|
||||
/* ---- Disable interactions when in drawing modes ---- */
|
||||
useEffect(() => {
|
||||
const map = mapRef.current;
|
||||
|
||||
Reference in New Issue
Block a user