anvc / scalar

Born-digital, open source, media-rich scholarly publishing that’s as easy as blogging.
Other
231 stars 73 forks source link

Where/how to input Google Maps API Key? #158

Closed hesperidium closed 3 years ago

hesperidium commented 3 years ago

This feels like such a basic question, with an answer that's probably staring me in the face, but here we are...

I am looking to use the Maps Layout and have set up a Google Cloud Platform account and gotten a Maps API Key (set with restriction to the two URLs we're I'll be using the feature), but I am not certain where to actually input the API key on Scalar. I've tried adding to the page body HTML the that Google instructs and I've searched for a few Javascript solutions but none have worked so far.

Thanks for any guidance!

craigdietrich commented 3 years ago

Hi!

The Google Maps API key, along with other keys, goes in the file:

system/application/config/local_settings.php

There's a lot of different settings in there that can adjust the behavior of a Scalar install. Here is more info: https://scalar.usc.edu/works/guide2/local-settings?path=advanced-topics

hesperidium commented 3 years ago

Thanks for the rescue!! Will run with this...

hesperidium commented 3 years ago

Hi Craig,

I downloaded my local_settings.php, updated the Google Maps API Key, and uploaded the edited .php, but the Maps Widget still showed "development only." When I looked closer at the local_settings.php I saw the line about overwriting with a local_settings_custom.php version, so I tried uploading that instead (all via Cyberduck to cPanel File Manager). The _custom.php upload showed up in the FTP Account folder on cPanel but the Maps Widget still did not load, so I tried moving the _custom.php file into the original system/applications/config location and received this error when I reloaded my Scalar page:

Fatal error: Allowed memory size of 205520896 bytes exhausted (tried to allocate 32768 bytes) in /home/ohmaexhi/public_html/system/application/config/local_settings_custom.php on line 103

Am I skipping or misunderstanding a step? Thanks for your help!

craigdietrich commented 3 years ago

If you put the key in local_settings.php, you should be all set. (I wouldn't mess with local_settings_custom.php, that's a special case.)

If it's still not working it means that the key may not be fully set up. Unfortunately, the Google Console is so confusing these days, it takes some trial and error.

What does the Console say when you try to load a map? You can get to this in Menu > More Tools > Developer Tools > Console tab... if you reload the page while it's open it may explain the problem in a red alert.

hesperidium commented 3 years ago

Thanks, Craig! Yeah, Google Console is a cluster... I'm still getting the same "No API Key" error message on the Scalar side, and on the Google side it's showing no API requests yet, so something is definitely up. I'll keep tinkering.

craigdietrich commented 3 years ago

Shoot me an email (craigdietrich at gmail) and let's see if we can figure out what's going on?