Improve
This commit is contained in:
parent
ea1e8a520d
commit
e34ba23f18
@ -5,69 +5,69 @@ import React, {
|
||||
useMemo,
|
||||
useState,
|
||||
useRef,
|
||||
} from "react";
|
||||
import {
|
||||
} from "react";
|
||||
import {
|
||||
AttributionControl,
|
||||
MapContainer,
|
||||
ZoomControl,
|
||||
useMapEvent,
|
||||
Pane,
|
||||
useMap,
|
||||
} from "react-leaflet";
|
||||
} from "react-leaflet";
|
||||
|
||||
import 'leaflet/dist/leaflet.css';
|
||||
import "./map.css";
|
||||
import "leaflet/dist/leaflet.css";
|
||||
import "./map.css";
|
||||
|
||||
import { apiGet } from "../apiHelpers";
|
||||
import {
|
||||
import { apiGet } from "../apiHelpers";
|
||||
import {
|
||||
initialMapViewport,
|
||||
mapBackgroundColor,
|
||||
MapTheme,
|
||||
LayerEnablementState,
|
||||
} from "../config/map-config";
|
||||
} from "../config/map-config";
|
||||
|
||||
import mapboxgl from "mapbox-gl";
|
||||
import mapboxgl from "mapbox-gl";
|
||||
|
||||
import { Building } from "../models/building";
|
||||
import { Building } from "../models/building";
|
||||
|
||||
import { CityMap } from "./layers/city-base-map-layer";
|
||||
import { CityBoundaryLayer } from "./layers/city-boundary-layer";
|
||||
import { BoroughBoundaryLayer } from "./layers/borough-boundary-layer";
|
||||
import { BoroughLabelLayer } from "./layers/borough-label-layer";
|
||||
import { ParcelBoundaryLayer } from "./layers/parcel-boundary-layer";
|
||||
import { HistoricDataLayer } from "./layers/historic-data-layer";
|
||||
import { HistoricMapLayer } from "./layers/historic-map-layer";
|
||||
import { FloodBoundaryLayer } from "./layers/flood-boundary-layer";
|
||||
import { ConservationAreaBoundaryLayer } from "./layers/conservation-boundary-layer";
|
||||
import { VistaBoundaryLayer } from "./layers/vista-boundary-layer";
|
||||
import { HousingBoundaryLayer } from "./layers/housing-boundary-layer";
|
||||
import { CreativeBoundaryLayer } from "./layers/creative-boundary-layer";
|
||||
import { BuildingBaseLayer } from "./layers/building-base-layer";
|
||||
import { BuildingDataLayer } from "./layers/building-data-layer";
|
||||
import { BuildingNumbersLayer } from "./layers/building-numbers-layer";
|
||||
import { BuildingHighlightLayer } from "./layers/building-highlight-layer";
|
||||
import { CityMap } from "./layers/city-base-map-layer";
|
||||
import { CityBoundaryLayer } from "./layers/city-boundary-layer";
|
||||
import { BoroughBoundaryLayer } from "./layers/borough-boundary-layer";
|
||||
import { BoroughLabelLayer } from "./layers/borough-label-layer";
|
||||
import { ParcelBoundaryLayer } from "./layers/parcel-boundary-layer";
|
||||
import { HistoricDataLayer } from "./layers/historic-data-layer";
|
||||
import { HistoricMapLayer } from "./layers/historic-map-layer";
|
||||
import { FloodBoundaryLayer } from "./layers/flood-boundary-layer";
|
||||
import { ConservationAreaBoundaryLayer } from "./layers/conservation-boundary-layer";
|
||||
import { VistaBoundaryLayer } from "./layers/vista-boundary-layer";
|
||||
import { HousingBoundaryLayer } from "./layers/housing-boundary-layer";
|
||||
import { CreativeBoundaryLayer } from "./layers/creative-boundary-layer";
|
||||
import { BuildingBaseLayer } from "./layers/building-base-layer";
|
||||
import { BuildingDataLayer } from "./layers/building-data-layer";
|
||||
import { BuildingNumbersLayer } from "./layers/building-numbers-layer";
|
||||
import { BuildingHighlightLayer } from "./layers/building-highlight-layer";
|
||||
|
||||
import { Legend } from "./legend";
|
||||
import SearchBox from "./search-box";
|
||||
import ThemeSwitcher from "./theme-switcher";
|
||||
import DataLayerSwitcher from "./data-switcher";
|
||||
import { BoroughSwitcher } from "./borough-switcher";
|
||||
import { ParcelSwitcher } from "./parcel-switcher";
|
||||
import { FloodSwitcher } from "./flood-switcher";
|
||||
import { ConservationAreaSwitcher } from "./conservation-switcher";
|
||||
import { HistoricDataSwitcher } from "./historic-data-switcher";
|
||||
import { HistoricMapSwitcher } from "./historic-map-switcher";
|
||||
import { VistaSwitcher } from "./vista-switcher";
|
||||
import { CreativeSwitcher } from "./creative-switcher";
|
||||
import { HousingSwitcher } from "./housing-switcher";
|
||||
import { BuildingMapTileset } from "../config/tileserver-config";
|
||||
import { useDisplayPreferences } from "../displayPreferences-context";
|
||||
import { CategoryMapDefinition } from "../config/category-maps-config";
|
||||
import { Legend } from "./legend";
|
||||
import SearchBox from "./search-box";
|
||||
import ThemeSwitcher from "./theme-switcher";
|
||||
import DataLayerSwitcher from "./data-switcher";
|
||||
import { BoroughSwitcher } from "./borough-switcher";
|
||||
import { ParcelSwitcher } from "./parcel-switcher";
|
||||
import { FloodSwitcher } from "./flood-switcher";
|
||||
import { ConservationAreaSwitcher } from "./conservation-switcher";
|
||||
import { HistoricDataSwitcher } from "./historic-data-switcher";
|
||||
import { HistoricMapSwitcher } from "./historic-map-switcher";
|
||||
import { VistaSwitcher } from "./vista-switcher";
|
||||
import { CreativeSwitcher } from "./creative-switcher";
|
||||
import { HousingSwitcher } from "./housing-switcher";
|
||||
import { BuildingMapTileset } from "../config/tileserver-config";
|
||||
import { useDisplayPreferences } from "../displayPreferences-context";
|
||||
import { CategoryMapDefinition } from "../config/category-maps-config";
|
||||
|
||||
mapboxgl.accessToken =
|
||||
mapboxgl.accessToken =
|
||||
"pk.eyJ1IjoiYWxpLWFkbGkiLCJhIjoiY2xuM2JtYjV1MGE5djJrb2d5OGp1ZWNyNiJ9.gENyP4xX6ElLAeZFlE0aDg";
|
||||
|
||||
interface ColouringMapProps {
|
||||
interface ColouringMapProps {
|
||||
selectedBuildingId: number;
|
||||
mode: "basic" | "view" | "edit" | "multi-edit";
|
||||
revisionId: string;
|
||||
@ -75,9 +75,9 @@ import React, {
|
||||
mapColourScale: BuildingMapTileset;
|
||||
onMapColourScale: (x: BuildingMapTileset) => void;
|
||||
categoryMapDefinitions: CategoryMapDefinition[];
|
||||
}
|
||||
}
|
||||
|
||||
export const ColouringMap: FC<ColouringMapProps> = ({
|
||||
export const ColouringMap: FC<ColouringMapProps> = ({
|
||||
mode,
|
||||
revisionId,
|
||||
onBuildingAction,
|
||||
@ -86,7 +86,7 @@ import React, {
|
||||
onMapColourScale,
|
||||
categoryMapDefinitions,
|
||||
children,
|
||||
}) => {
|
||||
}) => {
|
||||
const { darkLightTheme, darkLightThemeSwitch, showLayerSelection } =
|
||||
useDisplayPreferences();
|
||||
const [position, setPosition] = useState(initialMapViewport.position);
|
||||
@ -128,7 +128,7 @@ import React, {
|
||||
setLat(map.current.getCenter().lat.toFixed(4));
|
||||
setZoom(map.current.getZoom().toFixed(2));
|
||||
});
|
||||
});
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div
|
||||
@ -175,30 +175,30 @@ import React, {
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
};
|
||||
|
||||
function ClickHandler({ onClick }: { onClick: (e) => void }) {
|
||||
function ClickHandler({ onClick }: { onClick: (e) => void }) {
|
||||
useMapEvent("click", (e) => onClick(e));
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
function MapBackgroundColor({ theme }: { theme: MapTheme }) {
|
||||
function MapBackgroundColor({ theme }: { theme: MapTheme }) {
|
||||
const map = useMap();
|
||||
useEffect(() => {
|
||||
map.getContainer().style.backgroundColor = mapBackgroundColor[theme];
|
||||
});
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
function MapViewport({
|
||||
function MapViewport({
|
||||
position,
|
||||
zoom,
|
||||
}: {
|
||||
}: {
|
||||
position: [number, number];
|
||||
zoom: number;
|
||||
}) {
|
||||
}) {
|
||||
const map = useMap();
|
||||
|
||||
useEffect(() => {
|
||||
@ -206,5 +206,4 @@ import React, {
|
||||
}, [position, zoom]);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user