import * as mars3d from "mars3d";
// 地图函数列表
export function mapFun() {

    /**
     * 点标绘
     * */ 
    

    // 标注文本
    const handlerDrawLabel = async () => {
        const graphic = await window.drawGraphicLayer.startDraw({
            type:"label" ,
            style: {
                text: "标注文字",
                color: "#0081c2",
                font_size: 30,
                outline: true,
                outlineColor: "#ffffff",
                outlineWidth: 2
            }
        })
    }

    // 点+标注文本
    const handlerDrawPoint = async () => {
        const graphic = await window.drawGraphicLayer.startDraw({
            type: "point",
            style: {
            pixelSize: 12,
            color: "#3388ff",
            label: {
                    text: "标注文本",
                    font_size: 20,
                    color: "#ffffff",
                    outline: true,
                    outlineColor: "#000000",
                    pixelOffsetY: -20
                }
            }
        })
    }

    const handlerDrawIconPoint = async () => {
        const graphic = await window.drawGraphicLayer.startDraw({
            type:"billboard",
            style: {
                image: "https://data.mars3d.cn/img/marker/mark-red.png",
                horizontalOrigin: Cesium.HorizontalOrigin.CENTER,
                verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
                label: {
                    text: "可以同时支持文字",
                    font_size: 26,
                    color: "#ffffff",
                    outline: true,
                    outlineColor: "#000000",
                    pixelOffsetY: -60
                }
            }
        })
    }


    /**
     * 空间标绘
     * */ 

             


    /**
     * 贴地标绘
     * */ 

    // 贴地线
    const handlerDrawLine =async () => {
        const graphic = await window.drawGraphicLayer.startDraw({
            type: "polylineP",
            style: {
                color: "#ffff00",
                width: 3,
                clampToGround:true
            }
        })
    }


    // 贴地曲线
    const handlerDrawCurve = async () => {
        const graphic = await window.drawGraphicLayer.startDraw({
            type: "polylineP",
            style: {
                color: "#ffff00",
                width: 3,
                clampToGround:true
            }
        })
    }

    // 贴地自由线
    const handlerDrawBrushLine =async ()=> {
        const graphic = await window.drawGraphicLayer.startDraw({
            type: "brushLine",
            style: {
                color: "#ffff00",
                width: 3,
                clampToGround:true
            }
        })
    }

    // 贴地面
    const handlerDrawPolygon = async () => {
        const graphic = await window.drawGraphicLayer.startDraw({
            type: "polygon",
            style: {
                color: "#3388ff",
                opacity: 0.5,
                outline: true,
                outlineColor: "#ffffff",
                outlineWidth: 2.0,
                clampToGround:true
            }
        })
    }

    // 贴地矩形
    const handlerDrawRectangle = async () => {
        const graphic = await window.drawGraphicLayer.startDraw({
            type: "rectangle" ,
            style: {
                color: "#ffff00",
                opacity: 0.6,
                outline: true,
                outlineColor: "#ffffff",
                outlineWidth: 2.0,
                clampToGround:true
            }
        })
    }

    // 贴地圆形
    const handlerDrawCircle = async () => {
        const graphic = await window.drawGraphicLayer.startDraw({
            type: "circle" ,
            style: {
                color: "#ffff00",
                opacity: 0.6,
                outline: true,
                outlineColor: "#ffffff",
                outlineWidth: 2.0,
                clampToGround:true
            }
        })
    }


    /**
     * 军事标绘
     * */ 

    // 粗直箭头
    const handlerDrawFineArrow = async () => {
        const graphic = await window.drawGraphicLayer.startDraw({
            type: "fineArrow",
            style: {
                color: "#3388ff",
                opacity: 0.5,
                outline: true,
                outlineColor: "#ffffff",
                outlineWidth: 2.0,
                clampToGround:true
            }
        })
    }

    // 粗单尖直箭头
    const handlerDrawStraightArrow = async () => {
        const graphic = await window.drawGraphicLayer.startDraw({
            type: "straightArrow",
            style: {
                color: "#3388ff",
                opacity: 0.5,
                outline: true,
                outlineColor: "#ffffff",
                outlineWidth: 2.0,
                clampToGround:true
            }
        })
    }

    // 燕尾直箭头
    const handlerDrawFineArrowYW = async () => {
        const graphic = await window.drawGraphicLayer.startDraw({
            type: "fineArrowYW",
            style: {
                color: "#3388ff",
                opacity: 0.5,
                outline: true,
                outlineColor: "#ffffff",
                outlineWidth: 2.0,
                clampToGround:true
            }
        })
    }

    // 攻击箭头
    const handlerDrawAttackArrow = async () => {
        const graphic = await window.drawGraphicLayer.startDraw({
            type: "attackArrow",
            style: {
                color: "#3388ff",
                opacity: 0.5,
                outline: true,
                outlineColor: "#ffffff",
                outlineWidth: 2.0,
                clampToGround:true
            }
        })
    }

    // 平尾攻击箭头
    const handlerDrawAttackArrowPW = async () => {
        const graphic = await window.drawGraphicLayer.startDraw({
            type: "attackArrowPW",
            style: {
                color: "#3388ff",
                opacity: 0.5,
                outline: true,
                outlineColor: "#ffffff",
                outlineWidth: 2.0,
                clampToGround:true
            }
        })
    }

    // 燕尾攻击箭头
    const handlerDrawAttackArrowYW = async () => {
        const graphic = await window.drawGraphicLayer.startDraw({
            type: "attackArrowYW",
            style: {
                color: "#3388ff",
                opacity: 0.5,
                outline: true,
                outlineColor: "#ffffff",
                outlineWidth: 2.0,
                clampToGround:true
            }
        })
    }

    // 钳击箭头
    const handlerDrawDoubleArrow = async () => {
        const graphic = await window.drawGraphicLayer.startDraw({
            type: "doubleArrow",
            style: {
                color: "#3388ff",
                opacity: 0.5,
                outline: true,
                outlineColor: "#ffffff",
                outlineWidth: 2.0,
                clampToGround:true
            }
        })
    }

    // 闭合曲面
    const handlerDrawCloseVurve = async () => {
        const graphic = await window.drawGraphicLayer.startDraw({
            type: "closeVurve",
            style: {
                color: "#3388ff",
                opacity: 0.5,
                outline: true,
                outlineColor: "#ffffff",
                outlineWidth: 2.0,
                clampToGround:true
            }
        })
    }

    // 集结地
    const handlerDrawGatheringPlace = async () => {
        const graphic = await window.drawGraphicLayer.startDraw({
            type: "gatheringPlace",
            style: {
                color: "#3388ff",
                opacity: 0.5,
                outline: true,
                outlineColor: "#ffffff",
                outlineWidth: 2.0,
                clampToGround:true
            }
        })
    }

    /**
     * 标绘操作
     * */ 

    // 清除标绘
    const handlerDrawClear = async ()=>{
        window.drawGraphicLayer.clear();
    }

    // 导出GeoJSON
    const handlerDrawExportGeoJSON = () => {
        window.drawGraphicLayer.toGeoJSON();
    }

    // 导入GeoJSON
    const handlerDrawImportGeoJSON = (geojson) => {
        window.drawGraphicLayer.loadGeoJSON(geojson);
    }

    // 抛出函数
    return {
        
        // 图标标绘
        handlerDrawLabel,
        handlerDrawPoint,
        handlerDrawIconPoint,

        // 平面标绘
        handlerDrawPolygon,

        // 军事标绘
        handlerDrawDoubleArrow,
        handlerDrawAttackArrow,

        handlerDrawCloseVurve,
        handlerDrawBrushLine,
        handlerDrawLine,
        handlerDrawPoint,
        handlerDrawRectangle,
        handlerClearDraw,
    };
}


export const funSelectOptions = [

    // 点标绘
    {
        label:"文字",
        value:"handlerDrawLabel",
        cate:"point",
        cateName:"点标绘"
        group:"draw"
    },
    {
        label:"点",
        value:"handlerDrawLine",
        cate:"point",
        cateName:"点标绘"
        group:"draw"
    },
    {
        label:"点（带注记）",
        value:"handlerDrawLine",
        cate:"point",
        cateName:"点标绘"
        group:"draw"
    },
    {
        label:"图标点(带注记)",
        value:"handlerDrawLine",
        cate:"point",
        cateName:"点标绘"
        group:"draw"
    },


    // 二维空间标绘
    {
        label:"线",
        value:"handlerDrawLine",
        cate:"plane",
        cateName:"二维空间"
        group:"draw"
    },
    {
        label:"自由线",
        value:"handlerDrawBrushLine",
        cate:"plane",
        cateName:"二维空间"
        group:"draw"
    },
    {
        label:"面",
        value:"handlerDrawLine",
        cate:"plane",
        cateName:"二维空间"
        group:"draw"
    },
    {
        label:"圆",
        value:"handlerDrawLine",
        cate:"plane",
        cateName:"二维空间"
        group:"draw"
    },
    {
        label:"矩形",
        value:"handlerDrawRectangle",
        cate:"plane",
        cateName:"二维空间"
        group:"draw"
    },
    {
        label:"圆",
        value:"handlerDrawLine",
        cate:"plane",
        cateName:"二维空间"
        group:"draw"
    },
    {
        label:"曲线",
        value:"handlerDrawLine",
        cate:"plane",
        cateName:"二维空间"
        group:"draw"
    },


    // 二维贴地标绘
    {
        label:"线",
        value:"handlerDrawLine",
        cate:"ground",
        cateName:"二维贴地"
        group:"draw"
    },
    {
        label:"曲线",
        value:"handlerDrawCurve",
        cate:"ground",
        cateName:"二维贴地"
        group:"draw"
    },
    {
        label:"自由线",
        value:"handlerDrawBrushLine",
        cate:"ground",
        cateName:"二维贴地"
        group:"draw"
    },
    {
        label:"面",
        value:"handlerDrawLine",
        cate:"ground",
        cateName:"二维贴地"
        group:"draw"
    },
    {
        label:"矩形",
        value:"handlerDrawRectangle",
        cate:"ground",
        cateName:"二维贴地"
        group:"draw"
    },
    {
        label:"圆",
        value:"handlerDrawCircle",
        cate:"ground",
        cateName:"二维贴地"
        group:"draw"
    },


    // 军事标绘
    {
        label:"粗直箭头",
        value:"handlerDrawFineArrow",
        cate:"army",
        cateName:"军事标绘"
        group:"draw"
    },
    {
        label:"粗单尖直箭头",
        value:"handlerDrawStraightArrow", 
        cate:"army",
        cateName:"军事标绘"
        group:"draw"
    },
    {
        label:"燕尾直箭头",
        value:"handlerDrawFineArrowYW",
        cate:"army",
        cateName:"军事标绘"
        group:"draw"
    },
    {
        label:"攻击箭头",
        value:"handlerDrawAttackArrow",
        cate:"army",
        cateName:"军事标绘"
        group:"draw"
    },
    {
        label:"平尾攻击箭头",
        value:"handlerDrawAttackArrowPW",
        cate:"army",
        cateName:"军事标绘"
        group:"draw"
    },
    {
        label:"燕尾攻击箭头",
        value:"handlerDrawAttackArrowYW",
        cate:"army",
        cateName:"军事标绘"
        group:"draw"
    },
    {
        label:"钳击箭头",
        value:"handlerDrawDoubleArrow",
        cate:"army",
        cateName:"军事标绘"
        group:"draw"
    },
    {
        label:"闭合曲面",
        value:"handlerDrawCloseVurve",
        cate:"army",
        cateName:"军事标绘"
        group:"draw"
    },
    {
        label:"集结地",
        value:"handlerDrawGatheringPlace",
        cate:"army",
        cateName:"军事标绘"
        group:"draw"
    },

  
    // 标绘操作
    {
        label:"清除标绘",
        value:"handlerDrawClear",
        cate:"operate",
        cateName:"标绘操作"
        group:"draw"
    },
    {
        label:"导出GeoJSON",
        value:"handlerDrawExportGeoJSON",
        cate:"operate",
        cateName:"标绘操作"
        group:"draw"
    },
    {
        label:"导入GeoJSON",
        value:"handlerDrawImportGeoJSON",
        cate:"operate",
        cateName:"标绘操作"
        group:"draw"
    }

];