[OpenLayers-Users] How does remove markers/popups from a layer?
Stephen Woodbridge
woodbri at swoodbridge.com
Mon May 26 00:32:02 EDT 2008
Stephen Woodbridge wrote:
> 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
As a follow up to myself, I think I figured it out using an array popups
to collect the markers into as I make them and then removing them from
the layer, destroying the events and finally the markers. If this is not
correct/complete, or leaks (How do I check if this leaks?), please let
me know so this thread is complete and might help others.
Best regards,
-Steve W
More information about the Users
mailing list