1
Peekay
Google Maps API Keys are back
  • 2016/9/12 14:51

  • Peekay

  • XOOPS is my life!

  • Posts: 2335

  • Since: 2004/11/20


Google Maps API Keys are back

To embed Google Maps in a website, webmasters had to register for a free 'API Key' on the Google developers website. Then, Google changed the rules and for a while you could embed maps without a key. Now, from June 2016, API keys are back.

To get keys for your domains that use a Google maps module (you need one for each domain AFAIK) go to:

https://console.developers.google.com

Log in with your Google account credentials. In the API Manager screen - to the right of the Google API logo - you will see a drop-down menu of API projects. If you had registered a key sometime in the distant past, you may find that you already have a project called 'API Project' which is the name given to legacy keys.

Getting a new key

Getting a new key is a two step process. First, you need to create a new project/key combination. To do this, select the aforementioned drop-down menu, choose 'Create Project' then follow the prompts. At some point a window will appear with the key which you can copy. You will need to paste it into a module preference field, or hard-code it into the URL that calls Google Maps.

Step two is to register your site domain with Google. To do this:

* Ensure the correct project is selected in the drop-down menu.
* Select the 'Credentials' option in the left sidebar.
* Click once on the key (the default name is 'Browser key').
* Under the section 'Accept requests from these HTTP referers' do the following:

1) In the empty field, enter the word

Quote:
'localhost'

and press 'Save' (this enables localhost map development)

2) In the new empty field that then appears, enter the actual site URL including the wildcards, e.g.

Quote:
*.mywebsite.co.uk/*

It can take a few minutes for the changes to take effect.

Code changes

There have also been some changes to the way Google maps is accessed. Most importantly, you will need to change the primary script source URL from:

Quote:
to:
Quote:
//maps.googleapis.com/maps/api/js?key=.....

Some of the syntax has also changed, e.g.

Quote:
GMap2 changes to google.maps.Map

Quote:
GLatLng changes to google.maps.LatLng

There are more replacement pairs listed on the Google developers website, but these seem to be the significant ones. You may also need to remove some references to deprecated classes to prevent Javascript console errors. Running Firebug in Firefox will display errors from Google if their map API is unhappy about something.

For example, the addControl() method is deprecated, so in the module that I use I had to comment out:

Quote:
map.addControl(new GSmallMapControl());
map.addControl(new GMapTypeControl());
map.addControl(new GScaleControl());

The default map controls are now enabled by default, so map navigation wasn't affected.

There's a good guide to implementing the update at:

https://developers.google.com/maps/articles/v2tov3

HTH */

2
Peekay
Re: Google Maps API Keys are back
  • 2016/9/12 17:44

  • Peekay

  • XOOPS is my life!

  • Posts: 2335

  • Since: 2004/11/20


**EDIT

Sorry, missed out a step in the above.

You will during the process of getting a new key be asked to choose an API. The one you want is 'Google Maps JavaScript API'.

You can access all the APIs from the 'Library' menu option in the left sidebar.

Peekay

3
Mamba
Re: Google Maps API Keys are back
  • 2016/9/13 15:18

  • Mamba

  • Moderator

  • Posts: 11409

  • Since: 2004/4/23


Thank you for the update on this! That's very useful!
Support XOOPS => DONATE
Use 2.5.11 | Docs | Modules | Bugs

4
ilsanto
Re: Google Maps API Keys are back
  • 2017/1/9 14:16

  • ilsanto

  • Just popping in

  • Posts: 6

  • Since: 2002/3/2 1


Xoops 2.5.8.1
googlemaps 0.91 beta1
Theme based on xbootstrap

This not working.

In the admin interface the lat e lng are "undefinited".

How to solve this?

Stefano

5
abpf83
Re: Google Maps API Keys are back
  • 2018/4/28 16:11

  • abpf83

  • Just popping in

  • Posts: 3

  • Since: 2010/12/19


Hello to you, I have the same problem, except that I am Xoops 2.5.9
Googlemaps 0.91 beta1
Theme based on xbootstrap

It does not work.

In the administration interface of the lat e lng are "undefinited".

How to solve this problem?

6
Mamba
Re: Google Maps API Keys are back
  • 2018/4/30 17:41

  • Mamba

  • Moderator

  • Posts: 11409

  • Since: 2004/4/23


Don't have an answer right now, I'll have to look into it...
Hopefully in the next week or two.

Unless somebody else could help in the meantime?
Support XOOPS => DONATE
Use 2.5.11 | Docs | Modules | Bugs

7
iHackCode
Re: Google Maps API Keys are back

I have some fixes in my branch, but there might be a few features missing.

https://github.com/ihackcode/googlemaps/tree/fixes

8
abpf83
Re: Google Maps API Keys are back
  • 2018/5/1 11:37

  • abpf83

  • Just popping in

  • Posts: 3

  • Since: 2010/12/19


Merci pour le module. coté utilisateur sa marche pas sur Internet explorer et ok sur firefox

http://www.service-construction.fr/modules/googlemaps/

9
iHackCode
Re: Google Maps API Keys are back

Thanks. I had a typo in the call for setcenter. I've fixed it and pushed it to GitHub (https://github.com/ihackcode/googlemaps/tree/fixes)

10
Mamba
Re: Google Maps API Keys are back
  • 2018/5/5 2:10

  • Mamba

  • Moderator

  • Posts: 11409

  • Since: 2004/4/23


Thank you!

I've committed your changes to GitHub:

https://github.com/XoopsModules25x/googlemaps/pull/5

You might update your own master now
Support XOOPS => DONATE
Use 2.5.11 | Docs | Modules | Bugs

Login

Who's Online

333 user(s) are online (203 user(s) are browsing Support Forums)


Members: 0


Guests: 333


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits