Author Topic: Mapbox Token (API) and Saratoga Mesonet Script - Mapbox Token not set  (Read 917 times)

0 Members and 1 Guest are viewing this topic.

Offline AmateurExtra

  • Member
  • *
  • Posts: 14
  • Amateur Radio Operator Extra Class - N3UVR
    • N3UVR's Backyard Weather Station
Situation:
Browser is Firefox version 79 (64 bit) OS Windows 10
Using Saratoga templates, all scripts are current including the Mesonet scripts.
Created Mapbox account and default public token.
Set $mapboxAPIkey=default public key in mesonet-map-settings.php
Set $rmProvider = 'MapboxSat';
URL is https://k3csg.altervista.org/wxmesonetmap.php
View page source reveals
// skipping Mapbox - Terrain3 since $mapboxAPIkey is not set
// skipping Mapbox - Satellite since $mapboxAPIkey is not set
What am I doing incorrectly? Is the Mapbox API incorrect? Is there a procedure that I am not doing? The page works correctly without the satellite view but I've the bit between my teeth on this. Thanks.
"And therefore never send to know for whom
the bell tolls; it tolls for thee."

"For Whom the Bell Tolls"
by John Donne

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Mapbox Token (API) and Saratoga Mesonet Script - Mapbox Token not set
« Reply #1 on: August 05, 2020, 01:04:01 PM »
The 'native' map https://k3csg.altervista.org/mesonet-map.php shows both Mapbox choices, so I suspect that somewhere in wxmesonetmap.php or Settings.php you have either a $mapboxAPIkey or $SITE['mapboxAPIkey'] that is has a default value.
Your mesonet-map-settings.php does have a valid $mapboxAPIkey set, and that's why the mesonet-map.php page works as expected.

BTW.. I'd responded to your email on this question earlier.. guess you'd not seen the response.
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 AmateurExtra

  • Member
  • *
  • Posts: 14
  • Amateur Radio Operator Extra Class - N3UVR
    • N3UVR's Backyard Weather Station
Re: Mapbox Token (API) and Saratoga Mesonet Script - Mapbox Token not set
« Reply #2 on: August 05, 2020, 02:40:42 PM »
I did see it, followed your instructions and still the thing did not work. Rather than impose on you, I posted on here and I imposed on you. Oh well, thanks Ken.
"And therefore never send to know for whom
the bell tolls; it tolls for thee."

"For Whom the Bell Tolls"
by John Donne

Offline AmateurExtra

  • Member
  • *
  • Posts: 14
  • Amateur Radio Operator Extra Class - N3UVR
    • N3UVR's Backyard Weather Station
Re: Mapbox Token (API) and Saratoga Mesonet Script - Mapbox Token not set
« Reply #3 on: August 05, 2020, 05:19:18 PM »
What I cannot figure is the Mapbox API is set and working in the stand alone version - https://k3csg.altervista.org/mesonet-map.php and not working in the Saratoga template version - https://k3csg.altervista.org/wxmesonetmap.php
"And therefore never send to know for whom
the bell tolls; it tolls for thee."

"For Whom the Bell Tolls"
by John Donne

Offline AmateurExtra

  • Member
  • *
  • Posts: 14
  • Amateur Radio Operator Extra Class - N3UVR
    • N3UVR's Backyard Weather Station
Re: Mapbox Token (API) and Saratoga Mesonet Script - Mapbox Token not set
« Reply #4 on: August 05, 2020, 08:56:10 PM »
Both versions now work for me in Edge, Firefox, and Brave.

I can only get the stand alone version to work. What, please, is the solution?
"And therefore never send to know for whom
the bell tolls; it tolls for thee."

"For Whom the Bell Tolls"
by John Donne

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Mapbox Token (API) and Saratoga Mesonet Script - Mapbox Token not set
« Reply #5 on: August 05, 2020, 11:59:15 PM »
copy your wxmesonetmap.php to wxmesonetmap.txt and post it here.  I'll take a look.
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 AmateurExtra

  • Member
  • *
  • Posts: 14
  • Amateur Radio Operator Extra Class - N3UVR
    • N3UVR's Backyard Weather Station
Re: Mapbox Token (API) and Saratoga Mesonet Script - Mapbox Token not set
« Reply #6 on: August 06, 2020, 07:23:55 AM »
copy your wxmesonetmap.php to wxmesonetmap.txt and post it here.  I'll take a look.
"And therefore never send to know for whom
the bell tolls; it tolls for thee."

"For Whom the Bell Tolls"
by John Donne

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Mapbox Token (API) and Saratoga Mesonet Script - Mapbox Token not set
« Reply #7 on: August 06, 2020, 11:55:11 AM »
Thanks.  I've managed to reproduce the issue locally.. working on a fix.
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 saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Mapbox Token (API) and Saratoga Mesonet Script - Mapbox Token not set
« Reply #8 on: August 06, 2020, 12:47:01 PM »
Dang, that was hard to find.  Turns out to be interference with the nws-alerts-config.php file that wasn't noticed until you use Mapbox.

Change nws-alerts-config.php
Code: [Select]
$mapboxAPIkey = '--mapbox-API-key--';  // use this for the Access Token (API key) to MapBox
to
Code: [Select]
//$mapboxAPIkey = '--mapbox-API-key--';  // use this for the Access Token (API key) to MapBox
and wxmesonetmap.php should work correctly with Mapbox maps.

Whew...
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 AmateurExtra

  • Member
  • *
  • Posts: 14
  • Amateur Radio Operator Extra Class - N3UVR
    • N3UVR's Backyard Weather Station
Re: Mapbox Token (API) and Saratoga Mesonet Script - Mapbox Token not set
« Reply #9 on: August 06, 2020, 01:17:03 PM »
Dang, that was hard to find.  Turns out to be interference with the nws-alerts-config.php file that wasn't noticed until you use Mapbox.

Change nws-alerts-config.php
Code: [Select]
$mapboxAPIkey = '--mapbox-API-key--';  // use this for the Access Token (API key) to MapBox
to
Code: [Select]
//$mapboxAPIkey = '--mapbox-API-key--';  // use this for the Access Token (API key) to MapBox
and wxmesonetmap.php should work correctly with Mapbox maps.

Whew...

Ken - you da man! It works and I can let go the bit. Last time I programmed, I used Fortran 4 and Cobol and that puts me way back in the era of Pterodactyls. This PHP script, no place for old men. How the heck did you figure this out? That's a lot of code!
"And therefore never send to know for whom
the bell tolls; it tolls for thee."

"For Whom the Bell Tolls"
by John Donne

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Mapbox Token (API) and Saratoga Mesonet Script - Mapbox Token not set
« Reply #10 on: August 06, 2020, 01:53:49 PM »
Guess I'm from the Pterodactyl era too.. my first programming was in Fortran too (in '66). Lots of languages since then (maybe 2 dozen in total) with PHP/JavaScript/perl/bash the latest set.  Finding a good reference for a language is a must as all of them share similar control contructs.

I had added a bit of debug code (finally in the wxmesonetmap.php source) to display the $mapboxAPIkey as an HTML comment in key places.  I notice that it changed to the '-mapbox-API-key-' value just after menubar.php was loaded.  Looking at menubar.php, I saw that it happened after the include for nws-alerts-config.php was done, and in that file was the errant setting.

The nws-alerts* script set was originated by Curly who allowed me to incorporate it into the Base-USA template.  I'd forgotten that the Mapbox support I added to his script (when Google map was replaced with Leaflet maps) had it's own standalone setting for the 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

 

anything