feat: 添加导出图层功能,支持将图层转换为位图图像并下载
This commit is contained in:
@@ -665,7 +665,19 @@ function buildContextMenuItems(layer) {
|
||||
hideContextMenu();
|
||||
},
|
||||
},
|
||||
|
||||
// 栅格化图层
|
||||
{
|
||||
label: "导出图层",
|
||||
icon: "CExport",
|
||||
disabled:
|
||||
layer.isBackground ||
|
||||
layer.isFixed ||
|
||||
!layerManager?.canRasterizeLayer?.(layer.id),
|
||||
action: () => {
|
||||
exportLayerToImage(layer.id);
|
||||
hideContextMenu();
|
||||
},
|
||||
},
|
||||
{ type: "divider" },
|
||||
// 分组操作 - 带子菜单
|
||||
{
|
||||
@@ -1107,6 +1119,25 @@ async function rasterizeLayer(layerId) {
|
||||
}
|
||||
}
|
||||
|
||||
// 导出图层
|
||||
async function exportLayerToImage(layerId) {
|
||||
if (!layerManager?.rasterizeLayer) {
|
||||
console.warn("导出图层功能不可用");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const success = await layerManager.exportLayerToImage(layerId);
|
||||
if (success) {
|
||||
console.log(`✅ 成功导出图层: ${layerId}`);
|
||||
} else {
|
||||
console.warn("导出图层失败");
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("导出图层时发生错误:", error);
|
||||
}
|
||||
}
|
||||
|
||||
// 合并组图层
|
||||
async function mergeGroupLayer(groupId) {
|
||||
if (!layerManager?.mergeGroupLayers) {
|
||||
|
||||
Reference in New Issue
Block a user