Dio*_*lor 3 jquery bind mouseover mouseevent leaflet
我试图给了一个弹出式鼠标悬停事件,而不是点击上的标记,并做一些一些其他的东西(如FUNC)我们得到点击的时候.
我不相信的一半成功的代码会帮助你思考这个方向:
(我只是在点击事件上添加悬停)
marker[i].on('mouseover', marker[i].bindPopup('hi').openPopup.bind(marker[i]));
Run Code Online (Sandbox Code Playgroud)
[i]只是代表一个循环
Leaflet的API:http://leaflet.cloudmade.com/reference.html#map-openpopup
InP*_*uit 10
以下代码显示标记被鼠标悬停时的弹出窗口,并在单击标记时执行其他操作:
marker[i].on('mouseover', function(evt) {
//evt.target is the marker that is being moused over
//bindPopup() does not need to be called here if it was already called
//somewhere else for this marker.
evt.target.bindPopup('hi').openPopup();
});
marker[i].on('click', function(evt) {
//again, evt.target will contain the marker that was clicked
console.log('you clicked a marker');
});
Run Code Online (Sandbox Code Playgroud)