const lineFeature = parsedLine?.map((itemLine: any, index: any) => {
let geometry;
if (itemLine.layerType === 'LineString') {
const viewLine = JSON.parse(itemLine.content);
geometry = new LineString(viewLine);
} else if (itemLine.layerType === 'Polygon') {
const viewLine = JSON.parse(itemLine.content);
geometry = new Polygon(viewLine);
}
return new Feature({
geometry: geometry,
name: `Line Geometry ${index + 1}`,
style: new Style({
stroke: new Stroke({
color: itemLine.hexColor,
width: 10,
}),
}),
});
});
vectorSourceRef?.current?.clear();
// if (!vectorSourceRef.current) return;
vectorSourceRef?.current?.addFeatures(lineFeature);