Regional networks [netID]-mesomap.php software now has a Google map version...

It’s been about 10 years since the first regional weather network (Southwestern) offered a mesonet map with rotating conditions display. Now with 39 active regional networks, it was time for an update to the display software that makes it easier on both member stations and the regional admins to display and maintain the mesonet maps.

I’ve just completed a V3.00 of the Regional Mesonet Map code (formerly [netID]-mesomap.php, now just mesonet-map.php or wxmesonetmap.php with my template ). This could be completed only after I found a markerWithLabels that could work with markerClusterer in the maps… that didn’t exist until recently, and I’d been looking since 2014 for a good one.

This one code base is multilingual with built in mesonet-map-lang-LL.txt files and has settings in mesonet-map-settings.php. All the languages supported by the Regional networks are included. It does produce only ISO-9959-n character codes (sorry… had to do that for template compatibility).

As it’s Google-based, it needs a Google Browser JavaScript Map API key (like the global-map.php code) which can be set in the mesonet-map-settings.php or a global $SITE[‘googleAPI’] key like the global-map.php.

I’ve put together some docs at Saratoga-Weather.org - Scripts - Regional Mesonet Google Map and you can download the package from there.

Hopefully, it will make it easier for the regional network admins to maintain, as it’s driven from the [netID]-stations-cc.txt and [netID]-conditions.txt files on each regional hub. I think each hub-master will have to decide to use the new one in place of the original one for their network, but anybody can use the new mesonet-map.php on their website.

The master regional networks definition file is maintained on northamericanweather.net/mesonet-map-networks.txt and the script fetches it every 6 hours normally. The data and stations files are fetched every 5 minutes from the regional hub for that network for display.

My thanks to Wim (Leuven template), for the idea to use tabber.js to have easy toggling between map, conditions, station features, and regional networks links tabs – it made the presentation much easier and compact.

For regional network member stations, you won’t have to run the mesomap-update-utility.php to keep your map in sync with the regional hub for your network – the software will ensure the display is always up-to-date. Your network hub does not have to switch to the new map for you to use this map instead of the [netID]-mesomap.php on your site.
If your network hub does switch to this software, then you will need to use it too as the old map will no longer display accurately the conditions at station locations on the old graphic map.

For regional network admins, if you implement for your regional network, you can put ‘0,0,0,0’ for the coordinates of new stations in the [netID]-stations-cc.txt file and just make sure the latitude/longitude is set correctly.
And, you won’t need to use Paint.NET to edit the graphic any more… just the one [netID]-stations-cc.txt file would need to be maintained in the same manner as before. Please let me know if you decide to implement on your network to replace the original [netID]-mesomap.php, and also let your member stations know if you elect to switch the network to using the V3 software for maps.

Best regards,
Ken


Very nice Ken =D>

Looks good. But I have trouble mapstart
Erroare get the message:

Oops! Something Went Wrong.
This page did not load Google Maps CORRECTLY. See the JavaScript console for technical details.

http://www.celin-web.com/wdisplay/wxmesonetmap.php
#-o
Thanks for help
Marian


mesonet-map.js.txt (94.5 KB)

Hi Marian,
The Web Console message is

“Google Maps API error: InvalidKeyMapError 오류 메시지  |  Maps JavaScript API  |  Google for Developers

You need to acquire (or put the setting in for an existing) Google Browser JavaScript MAP API key.
If you don’t have one already (like for the global-map.php or quake-json.php), then visit here to start the process.
If you have a key already, then put it in your Settings.php as

$SITE['googleAPI'] = '-replace-this-with-your-API-key-here-';

Also, you can configure the map quickly using one entry in Settings.php for the map

$SITE['rmNETID'] = 'COWN';

The map will automatically use your selected default language for your site.

Hope this helps…
Best regards,
Ken

Thanks, I got a new Google API, and added in setting.php.
The script runs well. :smiley: :slight_smile:
The problem remains that the paper focuses on details that you have given and no zoom can not change the initial mesonet-map-settings.php.
See here:
$ RmMapCenter = '43 .6569, -79.4649 '; // Latitude, longitude center for initial map display (decimal degrees)
$ RmMapZoom = 7; // Initial map zoom level 1 = world, 10 = city;

:roll:

Thanks,
Marian
http://www.celin-web.com/wdisplay/wxmesonetmap.php

T’is true… #-o I’ll have to add the code so the override can be used for your default network and the provided settings for the other networks (via ?net=[netID] on URL).

Glad the map is otherwise working for you :slight_smile:

Ok, Marian try these two quick fixes:

To mesonet-map-settings.php change

if (isset($SITE['rmNETID']))      { $rmNETID = $SITE['rmNETID']; }
if (isset($SITE['rmMapType']))    { $rmMapType = $SITE['rmMapType']; }

// end of overrides from Settings.php

if(isset($_REQUEST['net']) and preg_match('|[A-Z0-9]+|',$_REQUEST['net'])) {
	$useRMNET = $_REQUEST['net'];
}


to

if (isset($SITE['rmNETID']))      { $rmNETID = $SITE['rmNETID']; }
if (isset($SITE['rmMapType']))    { $rmMapType = $SITE['rmMapType']; }
if (isset($SITE['rmMapUseDefaults'])) {$rmMapUseDefaults = $SITE['rmMapUseDefaults']; }
if (isset($SITE['rmMapZoom']))    { $rmMapZoom = $SITE['rmMapZoom']; }
if (isset($SITE['rmMapCenter']))  { $rmMapCenter = $SITE['rmMapCenter']; }
if (isset($SITE['rmMapUseUnits'])) {$rmMapUseUnits = $SITE['rmMapUseUnits']; }
if (isset($SITE['rmTempUOM']))    { $rmTempUOM = $SITE['rmTempUOM']; }
if (isset($SITE['rmWindUOM']))    { $rmWindUOM = $SITE['rmWindUOM']; }
if (isset($SITE['rmBaroUOM']))    { $rmBaroUOM = $SITE['rmBaroUOM']; }
if (isset($SITE['rmRainUOM']))    { $rmMapZoom = $SITE['rmRainUOM']; }

// end of overrides from Settings.php

if(isset($_REQUEST['net']) and 
   preg_match('|[A-Z0-9]+|',$_REQUEST['net']) and 
   $_REQUEST['net'] !== $rmNETID) {
	   
	$useRMNET = $_REQUEST['net'];
	if (!$rmMapUseDefaults and isset($rmNETID) and $rmNETID !== $useRMNET) {
	  #special case: user selects zoom/center ($rmMapUseDefaults) for $rmNETID network
	  # and the request is for another network via ?net=NETID
	  # then reverse the $rmMapUseDefaults for this access
	  $rmMapUseDefaults = true;
	}
}


Then in mesonet-map-inc.php change

print "<!-- NetLookup[".M_NETID."] \n".print_r($NetLookup[M_NETID],true)." -->\n";

// First, generate the embedded JavaScript for the map+pins
include_once("mesonet-map-genjs-inc.php");

to

print "<!-- NetLookup[".M_NETID."] \n".print_r($NetLookup[M_NETID],true)." -->\n";

// First, generate the embedded JavaScript for the map+pins
if(!$rmMapUseDefaults) {
	print "<!-- using custom ".M_NETID." zoom=$rmMapZoom center=$rmMapCenter -->\n";
} else {
	print "<!-- using default ".M_NETID." zoom=$rmMapZoom center=$rmMapCenter -->\n";
}
include_once("mesonet-map-genjs-inc.php");

What this should allow is for you to set $rmMapUseDefaults=false and for the network specified by $rmNETID, your zoom and center will be used.
If someone uses the Regional Networks TAB on the page to view a different network, the $rmMapUseDefaults will be set to true so the default zoom and center will be used.

That should allow cake and eating of cake too :slight_smile:

Let me know how that works for you…

Sorry, I did not notice any changes and modifications.
View modified files in attachments. #-o #-o
Regards,
Marian


mesonet-map-inc.php.txt (12.1 KB)

mesonet-map-settings.php.txt (6.23 KB)

mesonet-map-common.php.txt (32.7 KB)

The mods appear correct. To enable the override, in mesonet-map-settings.php change

  $rmMapUseDefaults = true; // =true, use built-in mapcenter, mapzoom settings for network.

to

  $rmMapUseDefaults = false; // =true, use built-in mapcenter, mapzoom settings for network.

Now it works very well.
Many thanks.
Marian

:smiley: :smiley: :smiley:

http://www.celin-web.com/wdisplay/wxmesonetmap.php?net=COWN

Good presentation :slight_smile:

Great! I’ve updated the distribution with V3.01 of mesonet-map-settings.php and mesonet-map-inc.php with those changes.

Thanks Niko! Thank Wim (Leuven template) for the idea to use Tabs to present the data… the tabber.js script (included in mesonet-map.js) works quite well, and if JavaScript is turned off in the browser, it just makes one long page with headings – that means that search engines can index it well :slight_smile:

Ken

Working Great here - thanks for another great script!

Cheers

:smiley:

MikeyM

works like weather map live now :wink:

I always kinda has, Brian… just no Flash required (ever). The old [netID]-mesomap.php used a static graphic and HTML to place markers over the graphic image. If JavaScript was enabled, then the conditions display would cycle to display various weather station conditions values. Never as spiffy as the WeatherMapLive, but with Flash on the ‘out’ list now, the JavaScript alternative using Google maps is a mildly fair display functionality.

I tried a larger map. I want to use the French language, we created a French-specific files to have done the following settings:

in mesonet-map-fr.php in line 10
require_once (“mesonet-map-settings-fr.php”);

in line 55-56
if (file_exists (“mesonet-map-inc-fr.php”)) {
include_once (“mesonet-map-inc-fr.php”);

in mesonet-map-genhtml-inc-fr.php in line 43-44
$ Lang = ‘fr’; // Default language
require_once (“mesonet-map-settings-fr.php”);

in mesonet-map-settings-fr.php
in line 14-15
$rmNETID = ‘FRWN’; // default Regional Network ID – must be one of the defined networks
$lang = ‘fr’; // default language

This is the link:
http://www.celin-web.com/wdisplay/mesonet-map-fr.php?net=FRWN

If it is possible to get help.
#-o #-o #-o

Thank you,
Marian

Hi Marian,

I’m not sure why you though you had needed to create copies of the files with different names (-fr).

I see that http://www.celin-web.com/wdisplay/mesonet-map-fr.php?net=FRWN&lang=fr works in French (as expected).

Is there a Settings.php from the Saratoga template in the same directory? if so, the value for $SITE[‘lang’] in that overrides the value in mesonet-map-settings-fr.php

Other than the map not showing (without the &lang=fr in the URL), is there an issue for which you need assistance?

Best regards,
Ken

I have cleared, runs well.

:smiley: :smiley: :smiley: :smiley: :smiley: :smiley:

http://www.celin-web.com/wdisplay/wxmesonetmap.php?lang=fr
Thank you for the help,
Marian

I’ve updated the docs at http://saratoga-weather.org/scripts-mesonet-map.php to explain the settings a bit better.

Briefly, any settings in mesonet-map-settings.php that have corresponding entries in a Saratoga template Settings.php (like $lang v.s. $SITE[‘lang’], the Settings.php entry wins and overrides the $lang value. That makes it easy to add the wxmesonetmap.php to the template and configure everything in Settings.php with no mesonet-map-settings.php changes required.

Also, I’ve issued a 3.02 version of the package today, and it includes a new mesonet-map-check-versions.php that will allow you to quickly show if you need any updates to the mesonet-map script package on your site.