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); }); });更多推荐
发布评论