
import defaultsDeep from "lodash/defaultsDeep";
export default function getMap(
    mapData,
    mapType,
    labelText,
    formatter,
    changeOpt,
    mapOpt
) {
    let opt = {
        tooltip: {
            trigger: 'item',
            formatter
        },
        legend: {
            show: false
        },
        geo: {
            map: mapType,
            label: {
                emphasis: {
                    show: false
                }
            },
            itemStyle: {
                normal: {
                    areaColor: '#09146f78',
                    borderColor: '#1362d0',
                    borderWidth: 0.8
                },
                emphasis: {
                    areaColor: '#080d5c8c'
                }
            }
        },
        series: [
            {
                type: 'effectScatter',
                coordinateSystem: 'geo',
                data: mapData,
                symbolSize: 10,
                showEffectOn: 'render',
                rippleEffect: {
                    brushType: 'stroke'
                },
                hoverAnimation: true,
                label: {
                    normal: {
                        color: "#fff",
                        formatter: '{b}',
                        position: 'bottom',
                        show: labelText
                    }
                },
                itemStyle: {
                    normal: {
                        color: {
                            type: 'linear',
                            x: 0,
                            y: 0,
                            x2: 0,
                            y2: 1,
                            colorStops: [
                                {
                                    offset: 0,
                                    color: '#f9f11b'
                                },
                                {
                                    offset: 1,
                                    color: '#feb10b'
                                }
                            ],
                            global: false
                        },
                        shadowBlur: 10,
                        shadowColor: '#333'
                    }
                },
                zlevel: 1
            }
        ]
    }
    if (changeOpt) {
        opt = defaultsDeep({}, changeOpt, opt)
    }
    if (mapOpt) {
        opt.series[0] = defaultsDeep({}, mapOpt, opt.series[0])
    }
    return opt
}