Closed GoogleCodeExporter closed 9 years ago
Your code fragment has some issues.
-- There is no var for the idle variable
-- cluster.center_ should not be used, use cluster.getCenter() instead
-- there is no var for infoWindow.
-- You pass "clusters" to the addMarkers function but addMarkers takes an array
of markers (I'm not sure what "clusters" contains because it is not defined
anywhere.)
A live example illustrating the problem would be useful.
I just checked the events example provided with MarkerClustererPlus and it
reports that only one event is fired after a cluster is clicked.
Original comment by garylitt...@gmail.com
on 27 Sep 2011 at 4:01
Thanks for getting back to me.
The idle, infoWindow, and clusters array are all global variables, which is why
they're not defined here.
The infoWindow is appearing appropriately, but the onClick for the clusters
does something funny. The first time it runs, it appears to fire twice, after
that, it appears to go up in numbers. If you click it again, it fires 3 times,
then 4 and so on.
I'm not sure if that helps, I don't really have a live version I can easily
link to.
Original comment by nmccrac...@gmail.com
on 27 Sep 2011 at 6:55
Since you are providing your own click handler, you should turn off the default
click handler. Do this by setting the zoomOnClick property to false in the
MarkerClustererOptions object you pass when creating the MarkerClusterer.
Original comment by garylitt...@gmail.com
on 27 Sep 2011 at 8:51
Thanks, I've done that. Is there anything I need to adjust in the javascript
file that could be the culprit?
Original comment by nmccrac...@gmail.com
on 28 Sep 2011 at 12:26
Until you post a complete demo, I can't tell what's causing the problem.
Original comment by garylitt...@gmail.com
on 28 Sep 2011 at 5:13
Thanks for getting back to me.
I've written up a short demo which can be found here:
http://exents.com/marker-simple.html
I have isolated that the problem starts when the bounds are changed in any way.
So if you hit the cluster before changing the bounds, you'll get the
CLUSTERFIRE alert, which simply tells you the cluster was fired, then a few
seconds later, you'll get the Idle Has Been Readded alert, which lets you know
that the idle listener that usually exists has come back.
If you change your bounds, you'll get all this twice. Change it again, you get
it 4 times, change it again, you get 6 and so on.
Maybe this has something to do with my idle listeners being in place?
I'm honestly not sure.
Original comment by nmccrac...@gmail.com
on 28 Sep 2011 at 3:53
The problem is that your idle handler calls "clusterer" which keeps pushing the
same markers to the end of the clusters array... and then it installs another
click handler. So every time you pan the map, another click handler is
installed. In other words, your code is buggy.
Original comment by garylitt...@gmail.com
on 28 Sep 2011 at 4:16
Would something like:
mc.clearMarkers(); and setting the idle listener to addListenerOnce take care
of that problem.
In my original code, I have a recurring clearMarkers() program that is supposed
to clear the markers from the Clusterer everytime it's run. It additionally
splices the cluster array until everything is removed from it.
Will the listener be added again in this case if its set to addListenerOnce?
Original comment by nmccrac...@gmail.com
on 28 Sep 2011 at 4:31
The way your code is written now, the first idle event after you click a marker
causes another click handler to be installed. That's not what you want.
Original comment by garylitt...@gmail.com
on 28 Sep 2011 at 4:45
You're right, I found my solution. The key was taking it out of the function it
was in. Putting the listener somewhere that the idle didn't call it took care
of the problem.
Thanks for your help and patience!
Original comment by nmccrac...@gmail.com
on 28 Sep 2011 at 5:02
Original issue reported on code.google.com by
nmccrac...@gmail.com
on 27 Sep 2011 at 1:04