[OpenLayers-Dev] DrawFeature.featureAdded() - called in wrong place?

Christopher Schmidt crschmidt at metacarta.com
Thu Apr 5 18:00:43 EDT 2007


On Thu, Apr 05, 2007 at 04:49:06PM -0500, Jeff Dege wrote:
> Maybe I don't understand what you intend DrawFeature.featureAdded to be
> used for, and it's possible that this whole area of functionality will
> be replaced, prior to 2.4, and it's current implementation is moot, but:
> 
> I'm trying to create two controls on a tool bar, both of which draw
> polygons, but where what happens after the polygon is drawn would be
> different.  I had noticed that in EditingToolBar.js, each control is
> assigned a featureAdded() function that sets the state of the feature to
> OpenLayers.State.INSERT.  I'd thought that I could use this function to
> set a different state, or to add my own status attribute to the feature,
> and then check on the value of that state in
> Layer.Vector.onFeatureInsert().


> But in Control\DrawFeature.js, the drawFeature() function calls
> this.featureAdded() after it calls this.layer.addFeatures(), so there's
> no way in onFeatureInsert() to distinguish which control created the
> feature.
> 
> As far as I can tell, the feature.state variable isn't actually used for
> anything.  Maybe I'm missing something, but would it break anything to
> make these calls in reverse order?

the State of the feature is used for posting to WFS servers -- depending
on the state, a feature is added, updated or deleted. 

I'd probably feel more comfortable offering advice to you if I had a
better idea why you need to know which control added a feature before
it's added -- styling, I presume?

> Or is all of this going to be scrapped and replaced?

No. With a few small exceptions (deprecation of geometry.feature
attribute), OL 2.4 API is what it will be.

Regards,
-- 
Christopher Schmidt
MetaCarta



More information about the Dev mailing list