Sign in to follow this  
Followers 0
Marko Cifer

api
Map not working? - How to use the module to accept Google API keys

3 posts in this topic

Hey, I had to do this for one of our domains so I thought I'd share since this will become a bigger problem due to new domains NEEDING a key now.

 

Why do I need an API key for Google Maps? It worked perfectly before!

If your domain did not use the Google Maps API before June 22nd, 2016, it wasn't grandfathered into the new system and thus needs to use an API key for verification.

I read up on it here - it's where you can see how to get an API key.

 

UPDATE: You can use the official update now.

Just make sure you're entering the referrers correctly in the API page - keep in mind that you need to authorize www and non-www URLs/domains!

 

To keep it short, instead of adding script tags elsewhere I just patched the module to allow entering an API key in the administrative section. It's actually rather easy to do, you need to modify two files:

  • mod_bt_googlemaps.xml
  • helper.php

They're both in: /modules/mod_bt_googlemaps

 

In mod_bt_googlemaps.xml, look for the line with <fieldset name="basic"> in it, then after that add:

<field
	name="apikey"
	type="text"
	label="API Key"
	description="Google API key">
</field>

This will add a new field in the admin where you can add your Google API key.

 

In helper.php, change the 28th line from:

$mapApi= '//maps.google.com/maps/api/js?language='.$language->getTag();

to:

$mapApi= '//maps.google.com/maps/api/js?language='.$language->getTag().'&key='.$params->get('apikey');

And that's it.

Share this post


Link to post
Share on other sites

Specifically, you can't use the Google Maps API without a key at all unless you had already been using it on a domain before the cutoff date.

Doesn't matter if it's this module, another component or manually adding it to your HTML.

Also, this thread is now redundant as there is an official update that adds API key support - and has actually been around for a while. Whoops.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  
Followers 0