首页>技术积累>详细

openlayers地图事件笔记

2024-01-23 12:00:00 来源:网络转载

扫一扫手机浏览

微信分享

地图点击事件

singleclick:地图单击事件。 

dblclick:地图双击事件。 

click:地图点击事件。

测试

map.on('singleclick',function(e){ console.log('单击!'); });

map.on('dblclick',function(e){ console.log('双击!'); }); 

map.on('click',function(e){ console.log('点击'); });


鼠标事件

pointerdrag:鼠标拖拽事件。 

pointermove:鼠标移动事件。

测试

map.on('pointerdrag',function(e){ console.log('鼠标拖拽了!'); });

map.on('pointermove',function(e){ console.log('鼠标移动了!'); });



地图渲染事件

postcompose:地图渲染中。 

precompose:准备渲染,未渲染。 

postrender:渲染全部结束。

//进行渲染

map.on('postcompose',function(e){ console.log('postcompose!'); }); 

//渲染全部完成 

map.on('postrender',function(e){ console.log('postrender!'); });

//准备渲染,未开始渲染

map.on('precompose',function(e){ console.log('precompose!'); });

地图初始化,整个地图渲染流程是 precompose>postcompose>postrender。 

分别对应渲染前,渲染中,渲染结束事件。


地图移动事件

moveend:地图移动结束发生,没什么好说的。

复杂的change事件

change:layerGroup :地图图层增删时触发。 

change:size :地图窗口发生变化就会触发,与我们常用的窗口resize接近。 

change:target :地图绑定的div发生更改时触发,如map.setTartget方法就会触发该事件。 

change:view :地图view对象发生变化触发。 

propertychange: Map对象中任意的property值改变时触发。 

map.on('change:size',function(e){ console.log('size改变!'); });

map.on('change:view',function(e){ console.log('view改变!'); }); 

map.on('change:target',function(e){ console.log('target改变!'); }); 

map.on('propertychange',function(e){ console.log('property改变!'); }); 



我们为您提供如下服务:

猜你喜欢

准备好开始了吗?那就联系我们吧!

010-59567245/13439526847

010-59567245 / 13439526847
北京市房山区长阳镇怡和北路5号院(熙悦广场)
542722164

在线咨询

微信公众号

手机网站

© 2019-2025 All rights reserved. 北京中泽瑞科技有限公司京ICP备19054999号-1
微信:13439526847