誰かがこの質問への回答にまだ興味がある場合は、次のコードで要求された要件を満たす必要があります (この種の問題にしばらく苦労したため)。
// Create the icon feature
var iconFeature = new ol.Feature({
geometry: new ol.geom.Point([lng, lat])
});
// Set the style for the icon feature
iconFeature.setStyle(new ol.style.Style({
image: new ol.style.Icon(({
anchor: [0.5, 35],
anchorXUnits: 'fraction',
anchorYUnits: 'pixels',
opacity: 1,
src: markerGraphics
}))
}));
// Create the vector layer with it's source
var vectorLayer = new ol.layer.Vector({
source: new ol.source.Vector({
features: [iconFeature]
})
});
// Drag and drop feature
var dragInteraction = new ol.interaction.Modify({
features: new ol.Collection([iconFeature]),
style: null,
pixelTolerance: 20
});
// Add the event to the drag and drop feature
dragInteraction.on('modifyend',function(){
callYourFunction();
},iconFeature);
// Add the vector layer and the refering drag and drop interaction
map.addLayer(vectorLayer);
map.addInteraction(dragInteraction);
変更イベントに基づいて、レイヤー/アイコン機能の代わりにリスナーをドラッグ アンド ドロップ インタラクションに追加できます。このソリューションを使用すると、レイヤー/アイコンのドラッグが停止した後に関数を実行できます (OpenLayers 2 で知られている「dragend」のように動作します)。