leaflet——地图事件

leaflet的地图事件主要有以下几类: 

1. 图层事件:

baselayerchange,overlayadd,overlayremove,layeradd,layerremove

2.地图状态改变事件 
load,upload,move,zoom,zoomed,moveed,resize等

3.弹出框事件 
popupopen,popupclose,autopanstart

4.交互事件 
click,dbclick,mousedown,mouseup,mouseover,mouseout,mousemove,keypress等 

//显示鼠标点击位置的经纬度
map.on(‘click’,function (e) {
        L.popup().setLatLng(e.latlng).setContent(e.latlng.toString()).openOn(map)
    })
//双击添加注记
 map.on(‘dblclick’,function (e){
       L.marker(e.latlng).addTo(map)
    } )
 

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

You may also like...