Skip to content

Commit

Permalink
Update name
Browse files Browse the repository at this point in the history
Signed-off-by: Junqiu Lei <[email protected]>
  • Loading branch information
junqiu-lei committed Jan 3, 2023
1 parent 69027a3 commit b24353d
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ export const CustomMapSource = ({
setSelectedLayerConfig,
setIsUpdateDisabled,
}: Props) => {
const customMapProtocolOptions = [
const customMapTypeOptions = [
{ value: 'tms', text: 'Tile Map Service (TMS)' },
{ value: 'wms', text: 'Web Map Service (WMS)' },
];

const [customMapURL, setCustomMapURL] = useState<string>('');
const [customMapAttribution, setCustomMapAttribution] = useState<string>('');
const [protocol, setProtocol] = useState(customMapProtocolOptions[1].value);
const [customType, setCustomType] = useState(customMapTypeOptions[1].value);
const [WMSLayers, setWMSLayers] = useState<string>('');
const [WMSVersion, setWMSVersion] = useState<string>('');
const [WMSFormat, setWMSFormat] = useState<string>('');
Expand Down Expand Up @@ -67,13 +67,13 @@ export const CustomMapSource = ({
});
};

const onChangeProtocol = (e: any) => {
setProtocol(e.target.value);
const onChangeCustomType = (e: any) => {
setCustomType(e.target.value);
setSelectedLayerConfig({
...selectedLayerConfig,
source: {
...selectedLayerConfig?.source,
protocol: e.target.value,
customType: e.target.value,
},
});
};
Expand Down Expand Up @@ -156,9 +156,9 @@ export const CustomMapSource = ({

useEffect(() => {
setCustomMapURL(selectedLayerConfig.source.url);
setProtocol(selectedLayerConfig.source.protocol);
setCustomType(selectedLayerConfig.source.customType);
setCustomMapAttribution(selectedLayerConfig.source.attribution);
if (selectedLayerConfig.source.protocol === 'wms') {
if (selectedLayerConfig.source.customType === 'wms') {
setWMSLayers(selectedLayerConfig.source.layers);
setWMSVersion(selectedLayerConfig.source.version);
setWMSFormat(selectedLayerConfig.source.format);
Expand All @@ -173,7 +173,7 @@ export const CustomMapSource = ({
}, [selectedLayerConfig.source.attribution]);

useEffect(() => {
if (protocol === 'wms') {
if (customType === 'wms') {
setIsUpdateDisabled(isInvalidURL(customMapURL) || WMSLayers === '' || WMSVersion === '');
} else {
setIsUpdateDisabled(isInvalidURL(customMapURL));
Expand All @@ -186,7 +186,7 @@ export const CustomMapSource = ({
WMSStyles,
WMSVersion,
customMapURL,
protocol,
customType,
setIsUpdateDisabled,
]);

Expand All @@ -196,16 +196,16 @@ export const CustomMapSource = ({
<EuiForm>
<EuiFlexGrid columns={1}>
<EuiFlexItem>
<EuiFormLabel>Protocol</EuiFormLabel>
<EuiFormLabel>Custom type</EuiFormLabel>
<EuiSpacer size="xs" />
<EuiSelect
options={customMapProtocolOptions}
value={protocol}
onChange={onChangeProtocol}
options={customMapTypeOptions}
value={customType}
onChange={onChangeCustomType}
fullWidth
/>
</EuiFlexItem>
{selectedLayerConfig.source.protocol === 'tms' && (
{selectedLayerConfig.source.customType === 'tms' && (
<>
<EuiFlexItem>
<EuiFormLabel>TMS URL</EuiFormLabel>
Expand Down Expand Up @@ -237,7 +237,7 @@ export const CustomMapSource = ({
</EuiFlexItem>
</>
)}
{selectedLayerConfig.source.protocol === 'wms' && (
{selectedLayerConfig.source.customType === 'wms' && (
<>
<EuiFlexItem>
<EuiFormLabel>WMS URL</EuiFormLabel>
Expand Down
4 changes: 2 additions & 2 deletions maps_dashboards/public/model/customLayerFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ const addNewLayer = (

const getCustomMapURL = (layerConfig: CustomLayerSpecification) => {
const layerSource = layerConfig?.source;
if (layerSource?.protocol === 'tms') {
if (layerSource?.customType === 'tms') {
return layerSource?.url;
} else if (layerSource?.protocol === 'wms') {
} else if (layerSource?.customType === 'wms') {
const referenceSystemName = layerSource.version === '1.3.0' ? 'crs' : 'srs';
return `${layerSource?.url}?service=WMS&version=${layerSource.version}&request=GetMap&format=${layerSource.format}&transparent=true&layers=${layerSource?.layers}&styles=${layerSource.styles}&${referenceSystemName}=${layerSource.crs}&width=256&height=256&bbox={bbox-epsg-3857}`;
} else {
Expand Down
4 changes: 2 additions & 2 deletions maps_dashboards/public/model/mapLayerType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export type CustomTMSLayerSpecification = {
visibility: string;
source: {
url: string;
protocol: 'tms';
customType: 'tms';
attribution: string;
};
};
Expand All @@ -80,7 +80,7 @@ export type CustomWMSLayerSpecification = {
visibility: string;
source: {
url: string;
protocol: 'wms';
customType: 'wms';
attribution: string;
layers: string;
styles: string;
Expand Down
2 changes: 1 addition & 1 deletion maps_dashboards/public/utils/getIntialConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export const getLayerConfigMap = () => ({
visibility: LAYER_VISIBILITY.VISIBLE,
source: {
url: '',
protocol: 'wms',
customType: 'wms',
attribution: '',
layers: '',
styles: '',
Expand Down

0 comments on commit b24353d

Please sign in to comment.