Where to put API key for Google Maps

Can someone instruct where to put the API key for Google Maps in the Real Homes Wordpress theme. thanks!

That would be a question for the theme author to answer. :slight_smile:

Usually, the theme (or plugin) settings page would provide an input for that. If there currently is none, check if there might be a theme update available. Otherwise, you really need to contact the theme author.

Hi there,

You can try to download the theme to your local machine and then use Notepad++ and go to Main Menu > Search > Find in Files. Search for keyword “maps.google”

Once you’ve found it, edit and place the key as your parameter like below

Cheers,
Joe Iz

I recently reinstalled Wampserver, wordpress, and ultimately my production website data onto my own machine, so that I have a “development” version of my website so that I can test out changes before updating my live site.

This appeared to google as a “new” implementation, and suddenly none of my imbedded maps would work, as google now requires the api key.

After browsing many forums, it was still unclear how exactly to get this working. It was easy enough to get an api key from google, but what to do with it was the big question. I found some examples of what the html code should ultimately look like, but the problem was how to get the various .php files updated so that the generated html code would now include my api key.

But, I did finally get it working! And here is what I did:

I used the tool Notepad++ as follows:

  1. Search->Find in Files and in the Directory field navigate to your …\wp-content directory
  2. In the Find what field enter sensor
  3. Click on Find All
  4. In the bottom part of the window that now shows the search results, right-click and choose open all

At this point, you should now have open all the files that your going to have to change.

In each file use the line numbers displayed in the search results window to navigate to the appropriate spot in each of your open files. Where ever you find code that has the word sensor, it is likely a piece of code relating to the google maps api, where &sensor=false is one of the parameters (at least in my case they were all &sensor=false, I suppose you may find some instances where &sensor=true).

What you need to do insert your api key as one of the parameters. So whenever I found &sensor=false, I changed it to &key=123xxxxx123&sensor=false. (Of course you’ll need to use your specific key value, no quotes required.) So I ended up with a variety of things, depending on what the .php file was doing. Here are some examples:

maps.google.com/maps/api/js?v=3.12&key=123xxxxx123&sensor=false&libraries=places&callback=em_maps
wp_enqueue_script(“Gmap”,“http://maps.google.com/maps/api/js?key=123xxxxx123&sensor=false”,false);
other_params: “key=123xxxxx123&sensor=false”,

For the Churchope theme, the changes needed to be made to the …\wp-content\themes\churchope\js\locationmap.js in two places, both were updating a variable called other_params.

I ended up searching the entire \wp-content directory, because I ultimately discovered that serveral of my plug-ins needed fixes to include the api key, not just the churchope theme.

I hope you find this helpful, and at least gets you pointed in the right direction on how to get your google maps displaying on your pages once again.

Ginny
Waterloo, ON