Openlayers 3中的鼠标滚轮事件(The mouse scroll wheel event in Openlayers 3)

编程入门 行业动态 更新时间:2024-10-22 13:32:05
Openlayers 3中的鼠标滚轮事件(The mouse scroll wheel event in Openlayers 3)

我开发了一个包含两个部分的网站:按列表显示和地图显示。 我的地图上有很多标记。 现在,当鼠标滚轮放大或缩小时,我需要获取地图的标记坐标。 通过moveend可以实现。 尽管我进行了搜索,但我无法做到这一点。 任何人都可以帮助我。

提前致谢。

I develop a web site that has two parts: the display by list and the map display. I have many markers on my map. Now I need to get the marker's coordinates of my map when the mouse scroll wheel zoom in or zoom out. It's possible by moveend. I am not able to do it despite my searches. Anybody can help me please.

Thanks in advance.

最满意答案

目前还不清楚你要做什么以及这些标记是什么; 他们是ol.geom.Point吗? 如果是这样 ,您可以执行以下操作:

map.getView().on('change:resolution', function(evt){ //layerFeatures is a reference of a ol.layer.Vector layerFeatures.getSource().forEachFeature(function(feature){ var geom = feature.getGeometry(); var coord = geom.getCoordinates(); //this is valid for a ol.geom.Point console.info(coord); }); });

It is unclear what you're trying to do as well as what these markers are; Are they ol.geom.Point? If so, you can do something like:

map.getView().on('change:resolution', function(evt){ //layerFeatures is a reference of a ol.layer.Vector layerFeatures.getSource().forEachFeature(function(feature){ var geom = feature.getGeometry(); var coord = geom.getCoordinates(); //this is valid for a ol.geom.Point console.info(coord); }); });

更多推荐

本文发布于:2023-08-05 19:35:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1439320.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:鼠标   滚轮   事件   Openlayers   event

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!