2017-02-07 1 views
1

マーカーがあるレイヤーとポリラインを持つレイヤーがあります。マーカーはポリラインの最後にあります。私は、ポリラインの終わり(オーバーラップ)に同期するマーカーをドラッグするのが好きです。Openlayers 3同じ位置にある2つの異なるレイヤーから2つのフィーチャーを選択してください

var features = new ol.Collection(); 
var featureOverlay = new ol.layer.Vector({source: new ol.source.Vector({features: features}),style:styles}); 
featureOverlay.setMap(map); 

var markers = new ol.Collection(); 
var markerOverlay = new ol.layer.Vector({source: new ol.source.Vector({features: markers}),style:styles}); 
markerOverlay.setMap(map); 

var modify = new ol.interaction.Modify({features: features}); 
map.addInteraction(modify); 


var modifyn = new ol.interaction.Modify({features: markers}); 
map.addInteraction(modifyn); 

これは同期していません。ポリラインの終わりとマーカーを別々にドラッグする必要があります。

どうすれば両方同時にドラッグできますか?

ありがとうございます! Andreas。

答えて

1

私はそれを得ました!

マウスの位置ですべての機能をリアルタイムで収集し、コレクションに保存します。このコレクションは変更の機能です。

乾杯!

var allFeaturesAtPixel = new ol.Collection(); 
var modify = new ol.interaction.Modify({features: allFeaturesAtPixel}); 
map.addInteraction(modify); 

map.on('pointermove', function (evt) 
{ 
allFeaturesAtPixel.clear(); 
map.forEachFeatureAtPixel(evt.pixel, function (feature) {allFeaturesAtPixel.push(feature);}); 
}); 
関連する問題