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

Heroku & PhantomJS: ReferenceError: Can't find variable: google #554

Open nickkellet opened 6 years ago

nickkellet commented 6 years ago

I'm using GMaps successfully and have been for a while.

My app is deployed on Heroku and I've been using phantomJS and rasterize to create png files based on content generated in the app.

I've now combined these to create images of the maps page.

It works in dev, but not on heroku.

It runs this code

system( "vendor/phantomjs/bin/phantomjs --output-encoding=utf8 bin/rasterize.js 'https://www.dmy.fyi/smap/kelowna/golf/1/?mode=make' tmp/images/imap_1_120171213-4-15jkab0.png 1080*1080px" )

And reports ...

ReferenceError: Can't find variable: google undefined:1 in eval code :0 in eval ReferenceError: Can't find variable: google https://www.dmy.fyi/assets/gmaps/google/primitives.self-5b8a3a670839d76c06f9877827daa0d739b27f8d6ebd346d7fc6006819755e65.js?body=1:5 in Primitives https://www.dmy.fyi/assets/gmaps/objects/handler.self-2f220cab5c91a054a6ee7f5b4c1eaab6edd160062ee3709c81714c18a6fbefa3.js?body=1:122 in setPrimitives https://www.dmy.fyi/assets/gmaps/objects/handler.self-2f220cab5c91a054a6ee7f5b4c1eaab6edd160062ee3709c81714c18a6fbefa3.js?body=1:8 in Handler https://www.dmy.fyi/assets/gmaps/base.self-8dd1d1a22a7ff3bf4faa70885ea5f452367e7249102c52508c66d85ca396ee8b.js?body=1:9 in build

Not sure where to go now. It works in development, so it's setup correctly.

I can run this in dev on the heroku URL and it works.

z= system( "/usr/local/bin/phantomjs --output-encoding=utf8 bin/rasterize.js 'https://www.dmy.fyi/smap/kelowna/golf/1/?mode=make#' tmp/images/imap_1_120171213-4-w3q9rb.png 1080*1080px" )

Any suggestions? What's missing on Heroku?

apneadiving commented 6 years ago

Most of the time these issues are linked to turbolinks and the short answer is to always load google maps, so add it to your layout.

-- Benjamin

On 13 December 2017 at 18:19:11, Nick Kellet (notifications@github.com) wrote:

I'm using GMaps successfully and have been for a while.

My app is deployed on Heroku and I've been using phantomJS and rasterize to create png files based on content generated in the app.

I've now combined these to create images of the maps page.

It works in dev, but not on heroku.

It runs this code

system( "vendor/phantomjs/bin/phantomjs --output-encoding=utf8 bin/rasterize.js 'https://www.dmy.fyi/smap/kelowna/golf/1/?mode=make' tmp/images/imap_1_120171213-4-15jkab0.png 1080*1080px" )

And reports ...

ReferenceError: Can't find variable: google undefined:1 in eval code :0 in eval ReferenceError: Can't find variable: google https://www.dmy.fyi/assets/gmaps/google/primitives.self-5b8a3a670839d76c06f9877827daa0d739b27f8d6ebd346d7fc6006819755e65.js?body=1:5 in Primitives https://www.dmy.fyi/assets/gmaps/objects/handler.self-2f220cab5c91a054a6ee7f5b4c1eaab6edd160062ee3709c81714c18a6fbefa3.js?body=1:122 in setPrimitives https://www.dmy.fyi/assets/gmaps/objects/handler.self-2f220cab5c91a054a6ee7f5b4c1eaab6edd160062ee3709c81714c18a6fbefa3.js?body=1:8 in Handler https://www.dmy.fyi/assets/gmaps/base.self-8dd1d1a22a7ff3bf4faa70885ea5f452367e7249102c52508c66d85ca396ee8b.js?body=1:9 in build

Not sure where to go now. It works in development, so it's setup correctly.

I can run this in dev on the heroku URL and it works.

z= system( "/usr/local/bin/phantomjs --output-encoding=utf8 bin/rasterize.js 'https://www.dmy.fyi/smap/kelowna/golf/1/?mode=make#' tmp/images/imap_1_120171213-4-w3q9rb.png 1080*1080px" )

Any suggestions? What's missing on Heroku?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/apneadiving/Google-Maps-for-Rails/issues/554, or mute the thread https://github.com/notifications/unsubscribe-auth/AAPHHzc6Kg1ANa_YjtERv3idDav4J-2iks5tAAcMgaJpZM4RA5Pb .