调整环境变量参数,支持项目切换
This commit is contained in:
@@ -7,6 +7,7 @@ import { Stroke } from "ol/style";
|
||||
import GeoJson from "ol/format/GeoJSON";
|
||||
import config from "@config/config";
|
||||
import { useMap } from "@app/OlMap/MapComponent";
|
||||
import { useProject } from "@/contexts/ProjectContext";
|
||||
|
||||
interface PropertyItem {
|
||||
key: string;
|
||||
@@ -26,6 +27,8 @@ const ZonePropsPanel: React.FC<ZonePropsPanelProps> = ({
|
||||
onClose,
|
||||
}) => {
|
||||
const map = useMap();
|
||||
const project = useProject();
|
||||
const workspace = project?.workspace;
|
||||
|
||||
const [props, setProps] = React.useState<
|
||||
PropertyItem[] | Record<string, any>
|
||||
@@ -103,9 +106,10 @@ const ZonePropsPanel: React.FC<ZonePropsPanelProps> = ({
|
||||
if (!map) {
|
||||
return;
|
||||
}
|
||||
const workspaceValue = workspace || config.MAP_WORKSPACE;
|
||||
const networkZoneLayer = new VectorLayer({
|
||||
source: new VectorSource({
|
||||
url: `${config.MAP_URL}/${config.MAP_WORKSPACE}/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=${config.MAP_WORKSPACE}:network_zone&outputFormat=application/json`,
|
||||
url: `${config.MAP_URL}/${workspaceValue}/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=${workspaceValue}:network_zone&outputFormat=application/json`,
|
||||
format: new GeoJson(),
|
||||
}),
|
||||
style: new Style({
|
||||
@@ -155,7 +159,7 @@ const ZonePropsPanel: React.FC<ZonePropsPanelProps> = ({
|
||||
map.removeLayer(highlightLayer);
|
||||
map.un("click", clickListener);
|
||||
};
|
||||
}, [map, handleMapClickSelectFeatures]);
|
||||
}, [map, handleMapClickSelectFeatures, workspace]);
|
||||
// 获取中文标签
|
||||
const getChineseLabel = (key: string): string => {
|
||||
const labelMap: Record<string, string> = {
|
||||
|
||||
Reference in New Issue
Block a user