-
-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(mapper): better distinguish create project layer colours (#1936)
* fix(main): shift osmStyle to baselayers constant * fix(layer-switcher): user added layer vanish issue on switching to initial selected layer issue solve * fix(newDefineAreaMap): layer style color change to distinguish different layers * fix(newDefineAreaMap): update layer styles * fix(layerSwitcher): add url contains project-submissions then hide ol-controls * feat(mapControlComponent): map control component add to submissionInstanceMap
- Loading branch information
Showing
4 changed files
with
72 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
src/frontend/src/components/SubmissionMap/MapControlComponent.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import React from 'react'; | ||
import AssetModules from '@/shared/AssetModules'; | ||
import VectorLayer from 'ol/layer/Vector'; | ||
import * as olExtent from 'ol/extent'; | ||
|
||
const MapControlComponent = ({ map }) => { | ||
const btnList = [ | ||
{ | ||
id: 'Add', | ||
icon: <AssetModules.AddIcon style={{ fontSize: '20px' }} className="fmtm-text-[#666666]" />, | ||
}, | ||
{ | ||
id: 'Minus', | ||
icon: <AssetModules.RemoveIcon style={{ fontSize: '20px' }} className="fmtm-text-[#666666]" />, | ||
}, | ||
{ | ||
id: 'Zoom To Layer', | ||
icon: <AssetModules.CropFreeIcon style={{ fontSize: '20px' }} className="fmtm-text-[#666666]" />, | ||
}, | ||
]; | ||
|
||
const handleOnClick = (btnId) => { | ||
if (btnId === 'Add') { | ||
const actualZoom = map.getView().getZoom(); | ||
map.getView().setZoom(actualZoom + 1); | ||
} else if (btnId === 'Minus') { | ||
const actualZoom = map.getView().getZoom(); | ||
map.getView().setZoom(actualZoom - 1); | ||
} else if (btnId === 'Zoom To Layer') { | ||
const extent = olExtent.createEmpty(); | ||
const layers = map?.getLayers(); | ||
|
||
layers?.forEach((layer) => { | ||
if (layer instanceof VectorLayer) { | ||
olExtent.extend(extent, layer.getSource().getExtent()); | ||
} | ||
}); | ||
map?.getView()?.fit(extent, { | ||
padding: [50, 50, 50, 50], | ||
duration: 900, | ||
}); | ||
} | ||
}; | ||
|
||
return ( | ||
<div className="fmtm-absolute fmtm-top-[20px] fmtm-left-3 fmtm-z-50 fmtm-bg-white fmtm-rounded-md fmtm-p-[2px] fmtm-shadow-xl fmtm-flex fmtm-flex-col fmtm-gap-[2px]"> | ||
{btnList.map((btn) => { | ||
return ( | ||
<div key={btn.id} title={btn.id}> | ||
<div | ||
className={`fmtm-p-1 fmtm-rounded-md fmtm-duration-200 fmtm-cursor-pointer hover:fmtm-bg-red-50`} | ||
onClick={() => handleOnClick(btn.id)} | ||
> | ||
{btn.icon} | ||
</div> | ||
</div> | ||
); | ||
})} | ||
</div> | ||
); | ||
}; | ||
|
||
export default MapControlComponent; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters