[OpenLayers-Users] thoughts on a design pattern for a common vector layer task

Puneet Kishor punk.kish at gmail.com
Sun Feb 19 13:08:54 EST 2012

I tend to do something like so a lot

1. listen to a map event
2. on event, get data from server
3. create vector layer "foo" unless vector layer "foo" already exists
4. add the data from #2 to vector layer "foo"

What is the most efficient way to achieve the above? Where I get lost is #3 above. 
How do I determine if a particular layer exists?
If it does, should I delete it, and recreate it, or should I delete all the features on it and add new features to it?

Puneet Kishor

More information about the Users mailing list