views:

136

answers:

1

Hi guys,

I'm having some problems with Google Maps v3. I have an event listener on "bounds_change" that adds all accommodations(markers) within the active bounds. When i move the map slightly, the same markers are added again because they are located in the bounds. So every time I move the map, duplicate markers are added.

How can I make sure these markers stay unique?

Thanks!!

Richard

+1  A: 

Hi Richard,

You need to keep track of your markers which are currently drawn, there are few "markermanagers" out there:

http://gmaps-utility-library-dev.googlecode.com/svn/trunk/markermanager/docs/examples.html

But basically you need to maintain a list of markers currently displayed, and then when you get the "bounds_change" event check the markers you want to add against the list of markers you have and only draw ones not currently displayed, you'll also need to remove any markers not currently within the bounds as well.

Peter Farmer