apneadiving / Google-Maps-for-Rails

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

Client side infowindows #469

Closed jerefrer closed 9 years ago

jerefrer commented 9 years ago

It seems what's described in the wiki page is a bit outdated, isn't it ?

Gmaps.map.jsTemplate = function(marker_container){
  //whatever you need
  return your_html;
}

Could you provide the current way to achieve this ? So things are crystal clear, could you please indicate a working example with how you would use, say, Handlebars ?

apneadiving commented 9 years ago

You're referring to old wiki pages, yes they still exist but check the wiki main page it doesnt link to it.

Anyway, check https://github.com/apneadiving/Google-Maps-for-Rails/wiki/Change-handler-behavior it describes how to override the create_infowindow method in a builder of yours. This way you can use whatever template engine you desire.

The original version is here: https://github.com/apneadiving/Google-Maps-for-Rails/blob/master/vendor/assets/javascripts/gmaps/google/builders/marker.coffee#L38

jerefrer commented 9 years ago

I'll dive into this, much thanks :)

jerefrer commented 9 years ago

For the record, here's a working implementation of client side classic infowindows rendering : https://gist.github.com/jerefrer/b9d3acb553ead86b3c1d

I didn't use any templating engine (i.e. Handlebars) since I thought it was overkill for such a tiny bit of html.