如何在使用 OpenLayers 修改结束之前减慢鼠标速度
How to slow down mouse before modifyend with OpenLayers
我有一张带有可拖动标记的地图(ol.style.icon 事实上)。
有一个奇怪的问题:
如果我尝试移动标记,这就像试图卷起一条马林鱼,但在 zoomin/out 或第一次拖动(点击紧然后点击释放)之后,标记自然会减慢。
我试着玩 PixelTolerance 但有任何区别。
请问为什么以及如何立即减慢这个标记?
var mark_style = new ol.style.Style({
image: new ol.style.Icon({
anchor: [.5, 48],
anchorXUnits: 'fraction',
anchorYUnits: 'pixels',
opacity: 0.75,
src: mark_path
})
});
var iconFeature = new ol.Feature(position);
iconFeature.set('style', mark_style);
var vectorLayer = new ol.layer.Vector({
style: function(feature) {
return feature.get('style');
},
source: new ol.source.Vector({features: [iconFeature]})
})
var dragInteraction = new ol.interaction.Modify({
features: new ol.Collection([iconFeature]),
style: null,
pixelTolerance: 10//?
});
dragInteraction.on('modifyend',function(f){
var coordf = f.features.getArray()[0].getGeometry().getCoordinates();
ol.View-view.setCenter(coordf);
GMapWidget.prototype.A = coordf;
GMapWidget.prototype.updatePosition(position);
},iconFeature);
map.addInteraction(dragInteraction);
经过多次尝试,这似乎是一个'modifyend'问题:在第一次拖动交互结束之前鼠标速度很快。请问怎么办?使用 modifystart,不再加速,但是,如何在第一次点击后访问所有鼠标位置?
好吧,dragInteraction.on(['modifyend', 'modifystart']
似乎还不错
我是初学者,我不知道为什么我的代码现在可以了。经过多次尝试,我成功了。
我有一张带有可拖动标记的地图(ol.style.icon 事实上)。 有一个奇怪的问题: 如果我尝试移动标记,这就像试图卷起一条马林鱼,但在 zoomin/out 或第一次拖动(点击紧然后点击释放)之后,标记自然会减慢。 我试着玩 PixelTolerance 但有任何区别。 请问为什么以及如何立即减慢这个标记?
var mark_style = new ol.style.Style({
image: new ol.style.Icon({
anchor: [.5, 48],
anchorXUnits: 'fraction',
anchorYUnits: 'pixels',
opacity: 0.75,
src: mark_path
})
});
var iconFeature = new ol.Feature(position);
iconFeature.set('style', mark_style);
var vectorLayer = new ol.layer.Vector({
style: function(feature) {
return feature.get('style');
},
source: new ol.source.Vector({features: [iconFeature]})
})
var dragInteraction = new ol.interaction.Modify({
features: new ol.Collection([iconFeature]),
style: null,
pixelTolerance: 10//?
});
dragInteraction.on('modifyend',function(f){
var coordf = f.features.getArray()[0].getGeometry().getCoordinates();
ol.View-view.setCenter(coordf);
GMapWidget.prototype.A = coordf;
GMapWidget.prototype.updatePosition(position);
},iconFeature);
map.addInteraction(dragInteraction);
经过多次尝试,这似乎是一个'modifyend'问题:在第一次拖动交互结束之前鼠标速度很快。请问怎么办?使用 modifystart,不再加速,但是,如何在第一次点击后访问所有鼠标位置?
好吧,dragInteraction.on(['modifyend', 'modifystart']
似乎还不错
我是初学者,我不知道为什么我的代码现在可以了。经过多次尝试,我成功了。