Author Topic: earthquake Script Map error  (Read 2496 times)

0 Members and 1 Guest are viewing this topic.

Offline SoMDWx

  • Forecaster
  • *****
  • Posts: 1014
    • Southern Maryland Weather
earthquake Script Map error
« on: December 01, 2017, 08:04:28 AM »
We had an earthquake in Dover, DE, not too far from me. I tried to use the quake-json.php on my site and i get the map to pop up very briefly but then i get the attached image.

I did register for an API key from google and it is installed.

Jim

Offline wvdkuil

  • Wim van der kuil
  • Forecaster
  • *****
  • Posts: 1984
    • My PWS at Leuven Belgium Europe
Re: earthquake Script Map error
« Reply #1 on: December 01, 2017, 08:55:02 AM »
You can find the error by using Chrome,
Right click => Inspect
At the tab Console the error message is shown, often just a typo.

I could not find the link to the earth quake page in your menu.
If you also give the URL to the page with a problem, one can help you better / further.

Wim

Offline Jáchym

  • Meteotemplate Developer
  • Forecaster
  • *****
  • Posts: 8605
    • Meteotemplate
Re: earthquake Script Map error
« Reply #2 on: December 01, 2017, 09:01:31 AM »
Google Maps API error: InvalidKeyMapError https://developers.google.com/maps/documentation/javascript/error-messages#invalid-key-map-error

The API key included in the script element that loads the API is not found. Please make sure you are using a correct API key. You can generate a new API key on the Google API Console.

http://somdweather.com/quake-json/quake-json.php

Offline SoMDWx

  • Forecaster
  • *****
  • Posts: 1014
    • Southern Maryland Weather
Re: earthquake Script Map error
« Reply #3 on: December 01, 2017, 09:30:39 AM »
"I did register for an API key from google and it is installed."  - from post above

Offline SoMDWx

  • Forecaster
  • *****
  • Posts: 1014
    • Southern Maryland Weather
Re: earthquake Script Map error
« Reply #4 on: December 01, 2017, 09:36:46 AM »
You can find the error by using Chrome,
Right click => Inspect
At the tab Console the error message is shown, often just a typo.

I could not find the link to the earth quake page in your menu.
If you also give the URL to the page with a problem, one can help you better / further.

Wim

http://somdweather.com/quake-json/quake-json.php

Offline wvdkuil

  • Wim van der kuil
  • Forecaster
  • *****
  • Posts: 1984
    • My PWS at Leuven Belgium Europe
Re: earthquake Script Map error
« Reply #5 on: December 01, 2017, 09:40:22 AM »
"I did register for an API key from google and it is installed."  - from post above
These are the example lines in the script about setting the API key:
Code: [Select]
// settings: --------------------------------------------------------------------
// As of 22-Jun-2016, you need a Google Browser JavaScript API KEY to run this script
//
//  Get the key from the Google console:
//  https://developers.google.com/maps/documentation/javascript/get-api-key
//  put this in the CALLING page for quake-json.php script:
/*
  $googleAPI = 'AIzaSyC3JloP-y9XqY4v-iWSAkFGavNW_YVWXNs';
*/
// Note: if using the Saratoga template set, put a new entry in Settings.php
/*

$SITE['googleAPI'] = 'AIzaSyC3JloP-y9XqY4v-iWSAkFGavNW_YVWXNs';

*/
Those example googleAPI  settings in the script are considered a comment by the use of /*  and */
There are NO other lines with your or any other  key found in the script.
So at line 202 the message text '-undefined-API-key-' is used for the API key
Code: [Select]
if (!isset($googleAPI))      { $googleAPI = '-undefined-API-key-'; }And that text is used and rejected with the message  "Google Maps API error: InvalidKeyMapError" in the inspect=> console tab.

Wim
« Last Edit: December 01, 2017, 09:42:27 AM by wvdkuil »

Offline wvdkuil

  • Wim van der kuil
  • Forecaster
  • *****
  • Posts: 1984
    • My PWS at Leuven Belgium Europe
Re: earthquake Script Map error
« Reply #6 on: December 01, 2017, 09:47:41 AM »
It seems you changed the example line texts  '-replace-this-with-your-API-key-here-'  with your key
Code: [Select]
/*
  $googleAPI = '-replace-this-with-your-API-key-here-';
*/
But these are examples and commented, as they are surrounded with    /*        */
So remove the /*  and the */  on line 80 and 82 and all will work correctly.

Wim

 

Offline SoMDWx

  • Forecaster
  • *****
  • Posts: 1014
    • Southern Maryland Weather
Re: earthquake Script Map error
« Reply #7 on: December 01, 2017, 09:54:26 AM »
Awesome! Thanks for the help...I still had the comments around the API key...

Jim