// import Overlay from 'ol/Overlay'
// import '../assets/scss/devicealarm.css'
// export function addAlarmFlash(map, config, callback) {
//     const { geom, attributes, symbol } = config
//     const coordinate = [parseFloat(geom.points.split(',')[0]), parseFloat(geom.points.split(',')[1])]
//     let ele = document.createElement('div')
//     let size = symbol.image.size
//     ele.className = 'static_imgs'
//     ele.style.background = 'url(' + symbol.image.src + ')'
//     ele.style.backgroundRepeat = 'no-repeat'
//     ele.style.width = size[0] + 'px'
//     ele.style.height = size[1] + 'px'
//     if (callback) {
//         ele.addEventListener("click", function() {
//             callback(attributes)
//         })
//     }
//     var marker = new Overlay({
//         id: attributes.id,
//         attributes,
//         positioning: 'center-bottom',
//         element: ele, //绑定上面添加的元素
//         stopEvent: false,
//         offset: [-13.5, -40] //图片偏移量
//     })
//     map.addOverlay(marker)
//     marker.setPosition(coordinate)
// }
// export function removeOverLayeById(map, id) {
//     let overlayer = map.getOverlayById(id)
//     if (overlayer) {
//         map.removeOverlay(overlayer)
//     }
// }
import Overlay from 'ol/Overlay'
export function addAlarmFlash(map, config, callback) {
    const { geom, attributes, symbol } = config
    const coordinate = [parseFloat(geom.points.split(',')[0]), parseFloat(geom.points.split(',')[1])]
    let ele = document.createElement('div')
    ele.style.background = 'url(' + symbol.image.src + ') 0px 0px no-repeat'
    ele.style.width = '100px'
    ele.style.height = '100px'
    if (callback) {
        ele.addEventListener("mouseover", function(event) {
            console.log("移入......")
            callback(attributes, event.type)
        })
        ele.addEventListener("mouseout", function(event) {
            console.log("移出.....")
            callback(attributes, event.type)
        })
        ele.addEventListener("click", function(event) {
            console.log("点击事件......")
            callback(attributes, event.type)
        })
    }
    var marker = new Overlay({
        id: attributes.id,
        attributes,
        positioning: 'center-bottom',
        element: ele, //绑定上面添加的元素
        stopEvent: false,
        offset: [-48.5, -50] //图片偏移量
    })
    map.addOverlay(marker)
    marker.setPosition(coordinate)
}
export function removeOverLayeById(map, id) {
    let overlayer = map.getOverlayById(id)
    if (overlayer) {
        map.removeOverlay(overlayer)
    }
}