我是开放图层的新手,我正在尝试与我的 Map 进行一些互动 . 我正在使用ol扩展像longtouch一段时间后我想在 Map 上显示fetaure . 它适用于此扩展,但问题是它在释放单击后显示 .
是否有任何方法可以在释放点击后显示指针下降事件的附加功能?
我在这里有一个例子 . http://viglino.github.io/ol-ext/examples/mobile/map.interaction.longtouch.html
http://viglino.github.io/ol-ext/examples/mobile/map.interaction.longtouch.html
问题不在于交互,而在于矢量图层 . 如果要在交互时反映插入,则必须为图层设置 updateWhileInteracting 选项,否则该要素将添加到图层中,但仅在完成时(在鼠标向上时)绘制 .
updateWhileInteracting
我已经更新了示例来处理这种情况 .
真的很奇怪 . 我重新编写了函数来分解和理解它 . 即使使用它, Point 功能也仅在 pulse 功能之后显示 .
Point
pulse
这是我的代码:
map.on('pointerdown', function(e){ timeOutVar = setTimeout(test(e), 1000); }); map.on('pointerup', function(e){ clearTimeout(timeOutVar); }); function test(e){ var point = new ol.Feature(new ol.geom.Point(e.coordinate)); vector.getSource().addFeature(point); }; var touchi = new ol.interaction.LongTouch( { handleLongTouchEvent: function(e){ pulseFeature(e.coordinate); setTimeout( function(){ pulseFeature(e.coordinate); }, 400); $(".options div").text(vector.getSource().getFeatures().length+" features added!"); } }); map.addInteraction(touchi);
2 回答
问题不在于交互,而在于矢量图层 . 如果要在交互时反映插入,则必须为图层设置
updateWhileInteracting
选项,否则该要素将添加到图层中,但仅在完成时(在鼠标向上时)绘制 .我已经更新了示例来处理这种情况 .
真的很奇怪 . 我重新编写了函数来分解和理解它 . 即使使用它,
Point
功能也仅在pulse
功能之后显示 .这是我的代码: