import Box from "@mui/material/Box"; import Typography from "@mui/material/Typography"; interface LegendStyleConfig { layerName: string; layerId: string; property: string; colors: string[]; type: string; // 图例类型 dimensions: number[]; // 尺寸大小 breaks: number[]; // 分段值 } // 图例组件 // 该组件用于显示图层样式的图例,包含属性名称、颜色、尺寸和分段值等信息 // 通过传入的配置对象动态生成图例内容,适用于不同的样式配置 // 使用时需要确保传入的 colors、dimensions 和 breaks 数组长度一致 const StyleLegend: React.FC = ({ layerName, layerId, property, colors, type, // 图例类型 dimensions, breaks, }) => { return ( {layerName} - {property} {[...Array(breaks.length)].map((_, index) => { const color = colors[index]; // 默认颜色为黑色 const dimension = dimensions[index]; // 默认尺寸为16 // // 处理第一个区间(小于 breaks[0]) // if (index === 0) { // return ( // // // // {"<"} {breaks[0]?.toFixed(1)} // // // ); // } // 处理中间区间(breaks[index] - breaks[index + 1]) if (index + 1 < breaks.length) { const prevValue = breaks[index]; const currentValue = breaks[index + 1]; return ( {prevValue?.toFixed(1)} - {currentValue?.toFixed(1)} ); } return null; })} ); }; export default StyleLegend; export type { LegendStyleConfig };