[OpenLayers-Users] vector layer - featureadded event called twice
Max Demars
burton449geo at gmail.com
Wed Sep 3 10:11:48 PDT 2014
Hi list!
I have a problem with the featureadded event of the vector layer. I have a
drawfeature control that is linked with a vector layer. I want to send the
drawn feature by ajax when the drawn feature is added to the vector layer.
However, the on featureadded event is triggered once after the first
drawing is complete, twice after the second drawing, three times after the
third drawing...etc... It should only be triggered once after each drawing.
I have tried with the on sketchcomplete event, but the drawn feature is not
yet added in the vector layer when it is triggered. What is the problem?
var tempLayer = new OpenLayers.Layer.Vector('Temp');
var eraseCtrl = new OpenLayers.Control.DrawFeature(tempLayer,
OpenLayers.Handler.Polygon);
tempLayer.events.on({featureadded : function(){
Ext.Ajax.request({
url: '/basqui/layer/shapefile/split',
method: 'POST',
params: {
'feature': vectorLayerToGeoJson(),
'mask':
geoJsonFormat.write(tempLayer.features[0].geometry)
},
success: function(r){
tempLayer.removeAllFeatures();
}
});
-Max Demars
--
Stack Overflow: http://stackoverflow.com/users/1914034/burton449
GIS Overflow: http://gis.stackexchange.com/users/14426/burton449
LastFm: http://www.lastfm.fr/user/burton449
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/openlayers-users/attachments/20140903/2f7b8d43/attachment.html>
More information about the Users
mailing list