2014-05-06 41 views
0

我試圖讓這一個功能的頂點已被修改。看來,featuremodified事件不會提供這些信息。獲取該功能的頂點被修改

這是重要的,因爲我將要發佈的修改到服務器。由於單個頂點更改,我不想發佈整個要素對象。

我使用的OpenLayers v2.13.1

回答

1

你需要掛接到OpenLayers.Layer.Vector的vertexmodified回調。這是由OpenLayers.Control.ModifyFeature的dragVertex功能觸發,看到479線在這裏http://trac.osgeo.org/openlayers/browser/trunk/openlayers/lib/OpenLayers/Control/ModifyFeature.js

的vertexmodified函數接收到一個頂點,功能和像素,所以你會寫這樣的事情,假設OpenLayers.Layer。矢量稱爲矢量:

vector.events.register('vertexmodified', this, function(vertex, feature, pixel){ 
    //do something with the vertex 
}); 
+0

謝謝,它的工作。然而,問題是,只要頂點移動一點,它就會觸發。我需要一個我找不到的'aftervertexmodified'事件。我想我需要'vertexmodified'和'featuremodified'一個小調整。 – Mohayemin

+0

是的,我不能看到比合並vertexmodified和featuremodified任何其他方式。 –