WXforum.net
Web Weather => Weather Website PHP/AJAX scripting => Topic started by: saratogaWX on May 14, 2019, 11:54:39 AM
-
I've updated Curly's nws-alerts V1.42 package to use Leaflet/OpenStreetMaps instead of Google maps, so no API key is needed anymore. Support for optional Mapbox.com API key is provided.
The Saratoga Base-USA template was updated, so use the update tool (https://saratoga-weather.org/wxtemplates/updates.php) with a query of Base-USA, Plugin-*, 14-May-2019.
The standalone script set was also updated on the legacy scripts page (https://saratoga-weather.org/scripts-legacy.php) and I've attached a small zip with the changed files. (note that nws-alerts.php V1.43 is only a version rev from V1.42).
Also the full script set is available on my GitHub distribution (https://github.com/ktrue/NWS-alerts)
-
As always, thanks [tup]
Wim
-
Great job, as usual! Thanks, Ken. [tup] =D>
-
A little glitch here with xhtml validation (https://validator.w3.org/check?uri=https%3A%2F%2Fwww.gwwilkins.org%2Fwxnws-details.php%3Fa%3DNEZ067;accept=text%2Fhtml%2Capplication%2Fxhtml%2Bxml%2Capplication%2Fxml%3Bq%3D0.9%2Cimage%2Fwebp%2Cimage%2Fapng%2C%2A%2F%2A%3Bq%3D0.8%2Capplication%2Fsigned-exchange%3Bv%3Db3;accept-language=en-US%2Cen%3Bq%3D0.9).
There's probably a simple fix, but it's beyond my ken, Ken. :-)
-
Ahh.. the validator was parsing the HTML inside the <script>...</script>
I've added <script>
// <![CDATA[
...
// ]]>
</script>
to have the parser stop trying to do that and become annoyed :)
Try the attached replacement.
-
I've pushed that change to the Base-USA template, the Legacy-scripts and the GitHub distributions. Thanks for spotting that omission.
-
Thanks Ken!
-
I had already corrected another little glitch with this addition of 'type' to the javascript call:
$leafletScript = '<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.3/leaflet.js" type="text/javascript"></script>'."\n";
Again the validator for xhtml complained about this omission which is useless these days, really.
Thanks, Ken! I had no idea what to do, but the CDATA exclusion is perfect.
-
Again the validator for xhtml complained about this omission which is useless these days, really.
Yup. And it is no longer necessary in HTML5.
-
Ahh... for XHTML, it's needed. HTML5 not needed. Since the templates use XHTML 1.0 Transitional, I've added that to the script.. thanks again.
BTW, it was an interesting challenge to modify Curly's original Google map script to do Leaflet instead .. a bit of somewhat convoluted PHP to generate the inline script only if the alert had geo-coordinates present, and quite a change in the generated JavaScript to control Leaflet due to differently named/accessed Leaflet functions v.s. Google maps functions.
Posted in the usual places...
-
Quick question Ken, doe the latest version still support "Filtered Events" or was that feature removed? I ask because I did not see the necessary files in your GitHub distribution package.
-
All the filtering features from Curly's 1.42 version are still there .. I only replaced the Google map with the Leaflet map generation.
What was missing in the GitHub package?? I may have skipped something when packaging it for GitHub.
-
If you need these file I will forward them to you but these are needed in order to configure the filters:
nws-alerts-events.php
nws-alerts-filter-config.php
nws-alerts-filtering.php
Thank you for keeping these old scripts alive!
-
Hey Ken,
The new version is working fine on my PC.
The 'check-fetch-times.php' has an 'unknown' for 'nws-alerts.css':
-
If you need these file I will forward them to you but these are needed in order to configure the filters:
nws-alerts-events.php
nws-alerts-filter-config.php
nws-alerts-filtering.php
Thank you for keeping these old scripts alive!
Yes, please .zip and send me those files... I see the .zip and GitHub only have ./cache/nws-alerts-filters.php in it.. the other files you cited are not there.
-
Hey Ken,
The new version is working fine on my PC.
The 'check-fetch-times.php' has an 'unknown' for 'nws-alerts.css':
I'll check.. I think maybe the versioning info is not in the CSS file. Thanks...
-
Hey Ken,
The new version is working fine on my PC.
The 'check-fetch-times.php' has an 'unknown' for 'nws-alerts.css':
Ahh... I discovered there was some missing code to have the .css files version info included in the version-list. I've updated that (and check-fetch-times.php V1.27 also) so the versioning on .css scripts needed are now included in the display.
Pushed Version 3.292 - 21-May-2019 (Base-*) updated check-fetch-times.php V1.27 for .css file version checking
-
Works great, Ken. Thanks for the quick update!
-
Thanks Ken
Worked Great last night with the "Special Weather Statement", "Severe Thunderstorm Warning" and "Tornado Warning" all showing correctly. [tup]
Cheers
:-)
MikeyM
-
Ken:
I noticed in your posts here you mention MapBox is optional. I don't have an API Key for MapBox what happens if I don't have API key?
Thanks
-
I believe it just eliminates the mapbox map display options like satellite. I don't think it will effect the performance of the script.
-
Ken:
I noticed in your posts here you mention MapBox is optional. I don't have an API Key for MapBox what happens if I don't have API key?
Thanks
The default behavior is to use the Esri_WorldTopoMap, tiles which needs no key. You only need the Mapbox key if you want to use Mapbox tiles.
-
I will go without the API Key based on your comments. I want to keep it simple.
Thanks for the feedback.
-
Just to be clear, I never said not to get the API Key, just that you don't need one for the script.
I do have one, the key.
-
I added my (unused) mapbox api key. Everything still looks the same. Anybody want to share a link to their page that uses mapbox? Thanks.
-
I added my (unused) mapbox api key. Everything still looks the same. Anybody want to share a link to their page that uses mapbox? Thanks.
It will only show the map if the alert includes location code. IE: It shows the map for an alert in Houston but not in Galveston and that's because the location code only came with the Houston alert.
-
Anyone can check out other map options... you do need a key for the Mapbox tiles.
Edit nws-alerts-config.php, around line 100 or so:
$mapProvider = 'Esri_WorldTopoMap'; // ESRI topo map - no key needed
//$mapProvider = 'OSM'; // OpenStreetMap - no key needed
//$mapProvider = 'Terrain'; // Terrain map by stamen.com - no key needed
//$mapProvider = 'OpenTopo'; // OpenTopoMap.com - no key needed
//$mapProvider = 'Wikimedia'; // Wikimedia map - no key needed
//
//$mapProvider = 'MapboxSat'; // Maps by Mapbox.com - API KEY needed in $mapboxAPIkey
//$mapProvider = 'MapboxTer'; // Maps by Mapbox.com - API KEY needed in $mapboxAPIkey
### END OF SETTINGS ###
Just un-comment (get rid of the leading "//") the line you want to try and upload the file. If you decide you don't like that, put the "//" back.
-
Ken:
I noticed in your posts here you mention MapBox is optional. I don't have an API Key for MapBox what happens if I don't have API key?
Thanks
A MapBox key just enables two additional maps, another Terrain and a Satellite map for display. Totally optional, and if you don’t have a key, the options for those additional map tiles will not be shown in the map type selection box.
-
Ken:
Thanks for the clarification. It helps a lot.
-
Hi Ken,
Just to be clear, the map will only show up when a warning is issued and the map does not show when a watch is issued. Or did I miss a setting?
yamiacaveman
pennlake.us
-
It's working. No map with Watch. We're now under a Warning and the MapBox map shows up in the Warning.
-
In my experience with testing the scripts, the County Zone is the one that carries the geo info to outline on the map for Watch and Warning (not all Watches, though). The Forecast Zone rarely caries geo info in my experience. If an alert contains geo info, then the map will appear.. no geo info in the collection of alerts results in no map display with the detail page.
-
Some alerts that I've seen with geo info and the type of NWS code included:
- Tornado Warning / county codes
- Severe Thunderstorm Warning / county codes
- Flash Flood Warning / county codes
- Flood Warning / county and zone codes
- Flood Advisory / county and zone codes
- Special Weather Statement (not always) / zone codes
-
Gotcha, thanks all.