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 only works with new markers. #233

Closed scottbaggett closed 12 years ago

scottbaggett commented 12 years ago

I'm currently working on a small app that uses replaceMarkers to alternate between a few sets of markers. As visitors click between sections I need to update my map with different sets of markers. The problem is that on the first click the markers are replaced with new data properly, but when I try to replace them again with markers that were previously on the map all the markers are removed from the map and I get no errors. I can see that the markers exist within the markers array.

Am I doing something wrong? Should I not be trying to replace markers on markers that were already in the array? It seems like replacemarkers should accept any array of markers even ones that have been previously shown on the map.

apneadiving commented 12 years ago

Thanks for this report, I'm rewriting the js part of the gem and I corrected that.

scottbaggett commented 12 years ago

Fantastic!

apneadiving commented 12 years ago

Oops, I'm not done yet, I'm working on the objectify_js branch

scottbaggett commented 12 years ago

No problem. I was able to work around it. Looking forward to not having to work around it next time though. Thanks again.

romaind commented 11 years ago

Hello,

I'm currently having this exact same issue with gmaps4rails (1.5.6).

Are you still working on the issue or is it supposed to be fixed ?

romaind commented 11 years ago

scottbaggett > How did you get to work around the issue ?

markedmondson commented 10 years ago

For anyone still on 1.5.6 who gets this problem, I got around it with the rather ugly:

  markers[0].lat = 50;
  Gmaps.map.clearMarkers();
  delete markers[0]["serviceObject"];
  Gmaps.map.addMarkers([markers[0]]);
  Gmaps.map.create_markers();