[OpenLayers-Users] How does remove markers/popups from a layer?

Stephen Woodbridge woodbri at swoodbridge.com
Sun May 25 23:54:41 EDT 2008


Hi all,

I'm fetching markers via an Ajax call and rendering them based on code 
very similar to the popup matrix example. You can see the code here:

http://imaptools.com/maps2/tiger.html

Just enter an address or zipcode and it will zoom you to that location 
and adds a marker to the map. So this part works well!

But I need to clean up and remove the old markers when a new request is 
made. What is the best way to do this? It is also possible to get an 
array of results, not just one, in some cases.

Is there a way to tell the layer to tell the markers to delete 
themselves? Or do I need to create an array and push all the markers 
onto the array, and then unregister all the click events and somehow 
destroy all the markers, popups and icons? Do we have an example of how 
what it the best way to do this? What is the best way to do this?

Thanks for any advice offered,
   -Steve W



More information about the Users mailing list