[OpenLayers-Users] Remove Features By Id

Mehmet Sirin m.sirin07 at googlemail.com
Thu Nov 26 07:54:52 EST 2009


..let me try it... mylayer.removeFeatures(mylayer.getFeatureById("start"))

uuh yes its works!

thank you !

regards
mehmet sirin c.


2009/11/26 Ivan Grcic <igrcic at gmail.com>

> Hi,
>
> mylayer.removeFeatures(mylayer.getFeatureById(startpoint.id))
>
> Andreas, I think that array param is not necessary, single feature
> should also work
>
> * APIMethod: removeFeatures line 581:
> if (!(features instanceof Array)) {
>            features = [features];
> }
>
> BTW features automatically get id, so  I wouldnt asign IDs manually.
>
> Cheers
>
> On Thu, Nov 26, 2009 at 8:40 AM, Andreas Hocevar <ahocevar at opengeo.org>
> wrote:
> > Hi,
> >
> > Mehmet Sirin wrote:
> >> I'm failing when trying to remove a feature selected by its ID:
> >>
> >> var startpoint= new OpenLayers.Feature.Vector(point,null,start_style);
> >> startpoint.id <http://startpoint.id>="hey";
> >> mylayer.addFeatures([startpoint]);
> >> ...
> >> var something=getFeatureById("hey"); //works
> >> mylayer.removeFeatures(mylayer.features[something]);
> >
> > The removeFeatures method takes an array of features as argument:
> >
> > myLayer.removeFeatures([something]);
> >
> > Regards,
> > Andreas.
> >
> >>
> >>
> >>
> >> Maybe  it's in general not possible choosing a feature by an
> >> associative key ?
> >> Then how solving this problem in another, elegant way ? (i have a
> >> solution for my problem, but it's definitely not fine or elegant^^)
> >>
> >>
> >>
> >>
> >> leaving you kind regards
> >> mehmet sirin c.
> >>
> >>
> >>
> >> ------------------------------------------------------------------------
> >>
> >> _______________________________________________
> >> Users mailing list
> >> Users at openlayers.org
> >> http://openlayers.org/mailman/listinfo/users
> >>
> >
> >
> > --
> > Andreas Hocevar
> > OpenGeo - http://opengeo.org/
> > Expert service straight from the developers.
> >
> > _______________________________________________
> > Users mailing list
> > Users at openlayers.org
> > http://openlayers.org/mailman/listinfo/users
> >
>
>
>
> --
> Ivan Grcic
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20091126/21a24f99/attachment.html


More information about the Users mailing list