您的位置:首页 > 运维架构

openlayer 3 长按事件

2016-04-10 10:34 387 查看
openlayer 3没有长按事件,通过常用事件模拟长按事件。

/***
*地图 长按事件
*/
var longpress = false;
//click 事件
map.on("click",function(){
(longpress) ? alert("Long Press") : alert("Short Press");
console.log(map.getEventCoordinate(e.pixel));
}
var startTime, endTime;
map.on('pointerdown', function () {
startTime = new Date().getTime();
});

map.on('pointerup', function () {
endTime = new Date().getTime();
console.log(endTime - startTime);
longpress = (endTime - startTime < 500) ? false : true;
});



                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: