Search code examples
ruby-on-railsrubyruby-on-rails-3google-mapsgmaps4rails

gmaps4rails add image to infowindow


I have enjoyed using you gmaps_4_rails gem and am impressed with the ease of configuring it. The only problem that I have had and I have spent a great deal of time trying to get it working is how to add an image to an infowindow. I cant get the example:

def gmaps4rails_infowindow
  "<img src=\"#{self.picture}\"> #{self.name}"
end

to work. I want to be able to do something like this in the infowindow /public/images/#{name}.jpg width= 25 height = 32.

I eventually want to store the images on amazon s3 but have been working on my local macbook to get the process working.

Any assistance would be greatly appreciated


Solution

  • Simply do this:

    def gmaps4rails_infowindow
      "<img src='/images/#{name}.jpg' width='25' height='32'> #{name}"
    end
    

    Have a look here to be sure of what you do: https://github.com/apneadiving/Google-Maps-for-Rails/wiki/Security-Warning