From 66261ea2967d4b5a8970ee38de34ae167364818a Mon Sep 17 00:00:00 2001 From: NSUWAL123 Date: Tue, 10 Oct 2023 13:33:33 +0545 Subject: [PATCH] feat (HomePage): cluster layer added in project list map --- .../src/components/home/ProjectListMap.tsx | 67 ++++++++++++++----- .../src/types/modulesDecleration.d.ts | 1 + 2 files changed, 52 insertions(+), 16 deletions(-) diff --git a/src/frontend/src/components/home/ProjectListMap.tsx b/src/frontend/src/components/home/ProjectListMap.tsx index b7efdf7a28..961114da44 100644 --- a/src/frontend/src/components/home/ProjectListMap.tsx +++ b/src/frontend/src/components/home/ProjectListMap.tsx @@ -3,12 +3,14 @@ import { useOLMap } from '../MapComponent/OpenLayersComponent'; import { MapContainer as MapComponent } from '../MapComponent/OpenLayersComponent'; import LayerSwitcherControl from '../MapComponent/OpenLayersComponent/LayerSwitcher/index.js'; import { VectorLayer } from '../MapComponent/OpenLayersComponent/Layers'; +import { ClusterLayer } from '../MapComponent/OpenLayersComponent/Layers'; import CoreModules from '../../shared/CoreModules'; import { geojsonObjectModel } from '../../constants/geojsonObjectModal'; import { defaultStyles, getStyles } from '../MapComponent/OpenLayersComponent/helpers/styleUtils'; import MarkerIcon from '../../assets/images/red_marker.png'; import { useNavigate } from 'react-router-dom'; import environment from '../../environment'; +import { Style, Text, Icon, Fill } from 'ol/style'; type HomeProjectSummaryType = { features: { geometry: any; properties: any; type: any }[]; @@ -21,20 +23,39 @@ type HomeProjectSummaryType = { }; }; -const projectGeojsonLayerStyle = { - ...defaultStyles, - fillOpacity: 0, - lineColor: '#ffffff', - labelFontSize: 20, - lineThickness: 7, - lineOpacity: 40, - showLabel: true, - labelField: 'project_id', - labelOffsetY: 35, - labelFontWeight: 'bold', - labelMaxResolution: 10000, - icon: { scale: [0.09, 0.09], url: MarkerIcon }, +// const projectGeojsonLayerStyle = { +// ...defaultStyles, +// fillOpacity: 0, +// lineColor: '#ffffff', +// labelFontSize: 20, +// lineThickness: 7, +// lineOpacity: 40, +// showLabel: true, +// labelField: 'project_id', +// labelOffsetY: 35, +// labelFontWeight: 'bold', +// labelMaxResolution: 10000, +// icon: { scale: [0.09, 0.09], url: MarkerIcon }, +// }; + +const getIndividualStyle = (featureProperty) => { + const style = new Style({ + image: new Icon({ + src: MarkerIcon, + scale: 0.08, + }), + text: new Text({ + text: featureProperty?.project_id, + fill: new Fill({ + color: 'black', + }), + offsetY: 35, + font: '20px Times New Roman', + }), + }); + return style; }; + const ProjectListMap = () => { const navigate = useNavigate(); @@ -67,7 +88,6 @@ const ProjectListMap = () => { }, [homeProjectSummary]); const projectClickOnMap = (properties: any) => { - console.log(properties); const encodedProjectId = environment.encode(properties.id); navigate(`/project_details/${encodedProjectId}`); }; @@ -85,7 +105,7 @@ const ProjectListMap = () => { }} > - {projectGeojson && projectGeojson?.features?.length > 0 && ( + {/* {projectGeojson && projectGeojson?.features?.length > 0 && ( { // // selectedFeature.setStyle(); // }} /> + )} */} + {projectGeojson && projectGeojson?.features?.length > 0 && ( + )} - {/* )} */} diff --git a/src/frontend/src/types/modulesDecleration.d.ts b/src/frontend/src/types/modulesDecleration.d.ts index 9e675817a7..6d04b25ecc 100644 --- a/src/frontend/src/types/modulesDecleration.d.ts +++ b/src/frontend/src/types/modulesDecleration.d.ts @@ -1,2 +1,3 @@ declare module '@testing-library/react'; declare module '*.png'; +declare module 'ol/style';