Author Topic: Google now requires API key for map display in browser- quake-json.php  (Read 5649 times)

0 Members and 1 Guest are viewing this topic.

Online saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9279
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Looks like Google is (sometimes slowly) changing the API for the Google Maps.. previously, they didn't require an API key for the maps used in scripts like quake-json, global-map and details with nws-alerts.  As of June 22, 2016, they've begun denying Maps with a message "Check the JavaScript Console" and you'll see 'Missing API Key' for all new sites.. preexisting sites have 90 days to get a key, otherwise they'll stop working too.  Sigh...

So now you need first get an API key for your site(s)

https://developers.google.com/maps/documentation/javascript/get-api-key

Standalone users update quake-json.php from the scripts page then change quake-json.php to have your API key

Code: [Select]
$googleAPI = '-replace-this-with-your-API-key-here-';
The quakes.php sample page is also changed a bit so follow it's example for your standalone page.

Saratoga template users should use the updates page to get what you need, and add an entry to your Settings.php file with
Code: [Select]
$SITE['googleAPI'] = '-replace-this-with-your-API-key-here-';
  You'll also need to replace the wxquake.php (USA, World) or wxquakew.php (Canada) as both have slightly changed to accommodate the new API key requirement.

Best regards,
Ken
« Last Edit: July 04, 2016, 10:59:34 AM by saratogaWX »
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline W3DRM

  • Forecaster
  • *****
  • Posts: 3360
    • Emmett Weather
Hi Ken,

I get a message saying I don't have permission to create an API Key. It appears I have to have an account in order to do that. Is Google now charging us to create API keys?
Don - W3DRM - Emmett, Idaho --- Blitzortung ID: 808 --- FlightRadar24 ID: F-KBOI7
Davis Wireless VP2, WD 10.37s150,
StartWatch, VirtualVP, VPLive, Win10 Pro
--- Logitech HD Pro C920 webcam (off-line)
--- RIPE Atlas Probe - 32849

Online saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9279
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
I think you can register for a free API key..I did.  You need to have an account (user/pass) on google.  I have two different accounts (both free) - one for Google+ and stuff, and one for the weather website stuff. 
You need the 'Standard Plan' for which allows for Google Maps JavaScript API, Google Static Maps API, Google Street View Image API as free up to 25,000 map loads per day.
https://developers.google.com/maps/pricing-and-plans/#details

Their info about the changes to the API access are at
https://developers.google.com/maps/pricing-and-plans/standard-plan-2016-update

Hope this helps...
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline PaulMy

  • Forecaster
  • *****
  • Posts: 5519
    • KomokaWeather
I was able to get an API key and have updated the earthquakes script and seems to be working http://www.komokaweather.com/komokaweather-ca/wxquakew.php.  I think I had previously set up a Google account for Meteotemplate Google Analytics 

Thanks Ken,
Paul

Offline W3DRM

  • Forecaster
  • *****
  • Posts: 3360
    • Emmett Weather
Okay, tried requesting a new API key and this time it worked. Not sure why I received the denied message originally. All is well now.

Thanks for the quick reply!

Happy 4th to all!!!
Don - W3DRM - Emmett, Idaho --- Blitzortung ID: 808 --- FlightRadar24 ID: F-KBOI7
Davis Wireless VP2, WD 10.37s150,
StartWatch, VirtualVP, VPLive, Win10 Pro
--- Logitech HD Pro C920 webcam (off-line)
--- RIPE Atlas Probe - 32849

Offline Jáchym

  • Meteotemplate Developer
  • Forecaster
  • *****
  • Posts: 8605
    • Meteotemplate
Ken, this is since Jun 22nd, existing users have 90 more days (i.e. users who used G Maps before 22nd June. Others have to get an API key immediately.

Did you get my email? I emailed you and Wim about it as soon as I got to know about it (about 10 days ago).

See:
http://www.wxforum.net/index.php?topic=26825.msg292407#msg292407
http://www.wxforum.net/index.php?topic=26825.msg292496#msg292496

Offline Jáchym

  • Meteotemplate Developer
  • Forecaster
  • *****
  • Posts: 8605
    • Meteotemplate
Have a look in the code where exactly this is specified.

If inside the PHP part, then server key, if in the HTML/Javascript part, then browser key. I would assume the latter one.

Offline rrrick8

  • Senior Contributor
  • ****
  • Posts: 225
    • Vermilion weather
Thanks. While going through the process I found I already had a key from 2012. Had forgotten.
Severe Weather Manager-Vermilion County EMA
CWOP-CW9931 KILDANVI5

Online saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9279
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Ken, this is since Jun 22nd, existing users have 90 more days (i.e. users who used G Maps before 22nd June. Others have to get an API key immediately.

Did you get my email? I emailed you and Wim about it as soon as I got to know about it (about 10 days ago).

See:
http://www.wxforum.net/index.php?topic=26825.msg292407#msg292407
http://www.wxforum.net/index.php?topic=26825.msg292496#msg292496
Thanks Jachym, yes.. I did get the email about the June 22nd.  With all the prep for the termite tenting and reloading the house, I've not been able to keep up to speed :(
I found that my saratoga-weather.org site worked without API key (since it was running well before June 22).  I had an alias for the site (stgawx.org) that showed the problem right away, so I used that to develop the fix for quake-json as both standalone and Saratoga template-aware.

Thanks again for the heads-up. 
Best regards,
Ken
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline Jáchym

  • Meteotemplate Developer
  • Forecaster
  • *****
  • Posts: 8605
    • Meteotemplate
Sure, no problem :-) I just wanted to make sure my emails dont end up in your spam folder :D

Online saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9279
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Sure, no problem :-) I just wanted to make sure my emails dont end up in your spam folder :D
Never!  You even have a '_Jachym' folder in my Thunderbird email where I save your messages :)
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline Jáchym

  • Meteotemplate Developer
  • Forecaster
  • *****
  • Posts: 8605
    • Meteotemplate
Nice :-)

Otherwise, with regards to the API key, I hope it won´t be an issue, because obviously, the problem in this case is that it is impossible to cache, hopefully the daily quota is enough even for bots. Im not sure if "no-follow" in the header would help. That would most likely just prevent the bot from indexing the links, but would still load the script.

Offline lrosenman

  • Contributor
  • ***
  • Posts: 148
    • Siena Weather
Nice :-)

Otherwise, with regards to the API key, I hope it won´t be an issue, because obviously, the problem in this case is that it is impossible to cache, hopefully the daily quota is enough even for bots. Im not sure if "no-follow" in the header would help. That would most likely just prevent the bot from indexing the links, but would still load the script.

you probably want to protect those pages from the robots with a robots.txt file in the root of the website....
http://www.robotstxt.org/robotstxt.html

Offline Jáchym

  • Meteotemplate Developer
  • Forecaster
  • *****
  • Posts: 8605
    • Meteotemplate
Yes, well the problem is that these text files tell the search engine - "do not index this", but thats it - in other words - it is only up to that bot if i will really do that. And obviously, the most aggressive bots are usually the ones that ignore this completely, there is nothing preventing them from doing it.

Yes there are some scripts that try to detect them, but I dont have very good experience with these, they either dont work, or they block even normal users.

Offline mkutche

  • Forecaster
  • *****
  • Posts: 1043
    • GosportWx.com
I have no idea how to create this??

Mike
Mike K.
Davis Vantage Vue 6250 - CumulusMX (3.21.1-b3205)
Gosport, Indiana
Gosportwx.com twitter.com/GosportINWX
-----------------------------------------------------------

Online saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9279
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Start with this link:

https://developers.google.com/maps/documentation/javascript/get-api-key

You just need a valid Google userid:password (like for a GMail account) to use their site to create an API key to use with the maps.
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline mkutche

  • Forecaster
  • *****
  • Posts: 1043
    • GosportWx.com
Start with this link:

https://developers.google.com/maps/documentation/javascript/get-api-key

You just need a valid Google userid:password (like for a GMail account) to use their site to create an API key to use with the maps.

ok i think i did it right.. although my router loves to block my website ip so i will have to look via my cell phone..
Mike K.
Davis Vantage Vue 6250 - CumulusMX (3.21.1-b3205)
Gosport, Indiana
Gosportwx.com twitter.com/GosportINWX
-----------------------------------------------------------

Offline Jáchym

  • Meteotemplate Developer
  • Forecaster
  • *****
  • Posts: 8605
    • Meteotemplate
Just make sure you specify the referrer to your domain, otherwise anyone can use your code and exhaust your daily quota, the code is normally visible in the HTML so you must do this.

Online saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9279
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Good advice, Jachym.

The proper format of that for your site (mkutche) is
Code: [Select]
*gosportwx.com/* which will allow www.gosportwx.com and gosportwx.com pages to use your Google API key.
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline mkutche

  • Forecaster
  • *****
  • Posts: 1043
    • GosportWx.com
Good advice, Jachym.

The proper format of that for your site (mkutche) is
Code: [Select]
*gosportwx.com/* which will allow www.gosportwx.com and gosportwx.com pages to use your Google API key.

Thanks. Now if I can get a host that isn't going to block my domain or load slow that'd be nice lol I just cant afford one right now. :(
Mike K.
Davis Vantage Vue 6250 - CumulusMX (3.21.1-b3205)
Gosport, Indiana
Gosportwx.com twitter.com/GosportINWX
-----------------------------------------------------------

Offline Jáchym

  • Meteotemplate Developer
  • Forecaster
  • *****
  • Posts: 8605
    • Meteotemplate
1and1 has packages starting from 99c/month

Offline tshattuck

  • Forecaster
  • *****
  • Posts: 337
    • Your Local Weather - Clay, NY
Ken:
I downloaded the new scripts and tried to setup Google API but my web page no longer displays the maps. The old script was working before I switched to the new script. I did place the API in the script per your instructions I am using your USA template set. I also referred to the links you provided for Google assistance on APIs, but it was over my head.  :-(

What type of key do I have to setup and how do I activate?

Your assistance is appreciated

yourlocalweather-clay-ny.com/wxquake.php/

Online saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9279
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
You need a "Google Maps JavaScript API" key from Google.

Then add
Code: [Select]
$SITE['googleAPI'] = '-replace-this-with-your-API-key-here-';
to your Settings.php (pretty much anywhere in the file.  Just before $SITE['noaaradar'] entry is a nice place.)
Change -replace-this-with-your-API-key-here- string with the Google API Key you get.

The process for getting a key starts at https://developers.google.com/maps/documentation/javascript/get-api-key
« Last Edit: July 13, 2016, 04:40:21 PM by saratogaWX »
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline Jáchym

  • Meteotemplate Developer
  • Forecaster
  • *****
  • Posts: 8605
    • Meteotemplate
I guess this will be a common question and the Google Developer Console is not really intuitive for someone who has never used it.

I have therefore prepared a little guide that I included in Meteotemplate wiki, but it can be used by anyone who needs the key.

It is available here as a PDF file right at the top in the Setup section:

http://www.meteotemplate.com/web/wiki/wiki3GB.php
« Last Edit: July 15, 2016, 11:51:46 AM by Jáchym »

Offline jay_hoehn

  • WxElement panel
  • Forecaster
  • *****
  • Posts: 656
    • Jay's Woodcrafts
Jachym,

Great guide.  Very simple to follow.  This should help many people in a couple of months when the maps quit working.

Jay
Davis Vantage Pro2 Plus
VVP
Weather Display


 

anything