ruby-on-railsruby-on-rails-4wkhtmltoimageimgkit

Using Google Maps in wkhtmltoimage / imgkit


Is it posible to create an image with IMGKit with google maps on it?

The problem is that i need to 'include' some javascript, but with IMGKit you can't include javascript from a remote server.

Is there a way to include:

= javascript_include_tag "//maps.google.com/maps/api/js?v=3.13&sensor=false&libraries=geometry"
= javascript_include_tag "//google-maps-utility-library-v3.googlecode.com/svn/tags/markerclustererplus/2.0.14/src/markerclusterer_packed.js"

to the IMGKit?

kit = IMGKit.new(html, :quality => 100, :width => 500, :height => 500)
kit.stylesheets << 'app/assets/stylesheets/some_style.scss'
kit.stylesheets << '//maps.google.com/maps/api/js?v=3.13&sensor=false&libraries=geometry'
kit.stylesheets << '//google-maps-utility-library-v3.googlecode.com/svn/tags/markerclustererplus/2.0.14/src/markerclusterer_packed.js'

Thanks for your help.


Solution

  • If anyone needs to create an image from an google map with IMGKit you can use the Static Google Map API.

    To generate such an image in rails have a look at this link.