クリックやシングルクリック、またはポインタの移動時に行うことができることが分かりますが、mousedown/mouseupで実行できることはありますか?要するに、ユーザーはマウスボタンがクリックされている間は機能を編集できるようにしたいが、マウスボタンを離すと保存/停止する。OL interaction - mousedown
featureRotateDown = new ol.interaction.Select({
condition: ol.events.condition.pointerdown
});
featureRotateUp = new ol.interaction.Select({
condition: ol.events.condition.pointerup
});
map.addInteraction(featureRotateDown);
map.addInteraction(featureRotateUp);
featureRotateDown.on('select', function(event) {
$.each(event.selected, function (index, feature) {
console.log(feature);
console.log('1');
});
});
featureRotateUp.on('select', function(event) {
$.each(event.selected, function (index, feature) {
console.log(feature);
console.log('3');
});
});
つまり、矢印である地図上にマーカーを配置したとします。私は、カーソルがマーカー上にあり、マウスボタンが押されている間に、私が望むくらい回転させる機能が必要です。あなたがforEachFeatureAtPixel
やgetClosestFeatureToCoordinate
を使用して機能にアクセスできる機能で
map.on('pointerdown', function (event) {
// doStuff...
// ALTERNATIVE 1: get a feature at click position (with very small tolerance)
map.forEachFeatureAtPixel(event.pixel, function(feature, layer){
// doStuff with your feature at click position
});
// ALTERNATIVE 2: get the closest feature
closestFeature = yourVectorSource.getClosestFeatureToCoordinate(event.coordinate);
})
map.on('pointerup', function (event) {
// doStuff...
})
:
ol.interaction.PointerとそのhandleDownEventおよびhandleUpEvent関数を見てください。マウスを下に移動させるには、forEachFeatureAtPixelメソッドを使用します。 – itsyahani