apneadiving / Google-Maps-for-Rails

Enables easy Google map + overlays creation in Ruby apps
https://apneadiving.github.io/
MIT License
2.26k stars 382 forks source link

replacemarkers flicker effect #132

Closed aliyakamercan closed 12 years ago

aliyakamercan commented 12 years ago

When user pans the map, I make and ajax request to the server and get all the markers that fall into the new bounds, something almost identical to what is described here: My problem is that when I use replaceMarker all the markers on the map are recreated therefore each of them flickers onces. This really annoys me.

If I use addMarkers, I don't get the flicker effect, but my sidebar gets screwed because; 1) The markers which are left out of the bounds after pan, are not removed from my marker list. 2) Some duplicates are added to my marker list - markers that fall into intersection of old and new bounds.

I think addmarkers function should at least check for duplicates.

apneadiving commented 12 years ago

Adding your own solution provided on stackoverflow as I don't see any better solution without overloading the js:

http://stackoverflow.com/questions/8652951/gmaps4rails-replacemakers-flicker-effect

Sidenote, it's a pity js objects don't have a proper id, this would have solved the case.

I keep this open.

aliyakamercan commented 12 years ago

Maybe instead of id, lang and lat can be used ?

apneadiving commented 12 years ago

The problem here is that many people only submit their city, so they share the same lat/lng.

aliyakamercan commented 12 years ago

Oh I see, I am new to rails and gmaps so I am not sure if the following makes any sense :). We use a model to store markers with lang/lat and this model has ids/keys in the db. Can't these ids be attached to the markers automatically. That's it basically what I do anyway.

On Tue, Jan 3, 2012 at 9:32 AM, Benjamin Roth < reply@reply.github.com

wrote:

The problem here is that many people only submit their city, so they share the same lat/lng.


Reply to this email directly or view it on GitHub:

https://github.com/apneadiving/Google-Maps-for-Rails/issues/132#issuecomment-3340509

apneadiving commented 12 years ago

What you do is simply great and I think I'll add it to the doc.

Yet, I'd like to avoid overloading the json created by gmaps4rails by default.

Currently, I'm using mongodb and the generated ids have many characters. So adding ids to the default json, if not explicitely desired, would be a perf killer.

apneadiving commented 12 years ago

in the new branch, I refresh the clusterer whenever addMarkers is called.

Still don't have proper ids for markers.

And you'll hate me but I've dropped suppor for sidebar: not much used + it's only a few js lines in callback.