开发者

Google Maps v3 - Adding makers results in duplicate markers

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 t开发者_JAVA百科hese markers stay unique?

Thanks!!

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜