[OpenLayers-Users] Destroy/Delete a vector feature

David Fawcett david.fawcett at gmail.com
Wed Dec 17 10:39:52 EST 2008


Eric,

Thank you very much for your help.

I was thinking about this last night as I was stuck in traffic for a
long time on my commute home due to black ice and new snow.

In a flash of mediocrity, I realized that I could just delete the item
from the geoJson featurecollection before creating my vector layer.
Since the item that I want to remove is always the last feature in the
collection, I decided to just slice it out.

Something like this works great:

aqiStations.features =
aqiStations.features.slice(0,aqiStations.features.length - 1);

David.

PS.  The reason for this hack is to get around an issue with building
geoJson from a MapServer query using the old (<5.2) query templates.
Using the header, template, footer model, I couldn't figure out a way
to not put a comma after the last feature in the collection.  So, I
create a dummy feature in the footer and then nuke it out on the
client side.  Kludgy, but it seems to be working...

FYI, the new MapServer templating makes geoJson creation clean and easy.

On Tue, Dec 16, 2008 at 3:03 PM, Eric Lemoine <eric.c2c at gmail.com> wrote:
> On Tue, Dec 16, 2008 at 9:36 PM, David Fawcett <david.fawcett at gmail.com> wrote:
>> Thank you Eric!
>>
>> I am curious, if a feature is not displayed, can it still be selected?
>>
>> My hope (and guess) is that it can't.  Essentially, is it just not
>> symbolized, or is it really 'not there'?
>
> From my understanding of the code, it isn't rendered at all.
>
> --
> Eric
>



More information about the Users mailing list