地图添加监听:

leafletMap.on('click', function () {
        console.log('--->click 点击事件')
    });
    leafletMap.on('mousedown', function () {
        console.log('--->mousedown 按下不抬起')
    });
    leafletMap.on('mouseup', function () {
        console.log('--->mouseup 按下抬起');
    });
    leafletMap.on('dblclick', function () {
        console.log('--->dblclick 双击触发');
    });
    //    leafletMap.on('mouseover', function () {
    //        console.log('--->mouseover 鼠标移出移进地图都会触发');
    //    });
    //触发极度频繁
    //    leafletMap.on('mousemove', function () {
    //        console.log('--->mousemove 鼠标在地图上移动触发');
    //    });
    leafletMap.on('viewreset', function () {
        console.log('--->viewreset 重绘内容时触发');
        console.log('--->getCenter ' + leafletMap.getCenter());
        console.log('--->getSize' + leafletMap.getSize());
        console.log('--->hasLayer是否有此图层 ' + leafletMap.hasLayer(layout));

    });
    leafletMap.on('autopanstart', function () {
        console.log('--->autopanstart 自动平移时触发');
    });
    leafletMap.on('whenReady', function () {
        console.log('--->whenReady 页面完全加载完');
    });
    layout.on("load", function () {
        console.log("--->layout 图层被加载一次")
    });

关闭事件监听用map.off('click') 

转载自:https://blog.csdn.net/black2Girl/article/details/85263419

You may also like...