[OpenLayers-Users] Destroy/Delete a vector feature

Eric Lemoine eric.c2c at gmail.com
Tue Dec 16 16:11:31 EST 2008


On Tue, Dec 16, 2008 at 10:00 PM, Yves Moisan <yves.moisan at boreal-is.com> wrote:
> Unless I'm mistaken, which I probably am, this only has to do with
> styling and not with assigning values to the 'state' property of a
> Layer.Vector.

Right. My response applies more to David's issue.

> I'm pretty confident that style will apply given I can
> get values in features[i].state.  I tried to read the article on
> closures in a bid to understand, but at any rate all I want is
>
> 1) make sure all the points from my service are loaded (which does take
> a bit of time) and then
>
> 2) assign the state property (e.g. to "unknown") on all features
> retrieved from my service

The state of features read from your web service is null, isn't it? Do
you really need it to be "unknown"?

> The idea here is that new points added by the user and not yet committed
> to the server will clearly show.

As I said in another post features drawn with the draw feature control
get the INSERT state automatically.

If you still want to set the UNKNOWN state yourself you can do:

vectorLayer.events.on({
    "featureadded": function(o) {
        var feature = o.feature;
        if (feature.state != OpenLayers.State.INSERT) {
            feature.state = OpenLayers.State.UNKNOWN;
        }
    }
});

--
Eric



More information about the Users mailing list