The global configuration for your WeatherBlox setup manages things like link formatting, icon locations and mappings, and the units to display. The library provides all of the defaults necessary to get started without worrying about any of these settings, but you can override these defaults to provide additional customization.

Refer to the configuration documentation for more information on how to override these defaults for both the JavaScript and API methods.


Below are the available configuration options:

linksDefines the URL formatting to use for various types of links used throughout the views and layouts
links.locDefines how to format locations when used in a URL via the {{loc}} variable
links.local.mainURL to the main local weather layout
links.local.historyURL to the local daily and monthly observation layouts
links.local.advisoryURL to the local advisory layout
icons.pathBase URL path to load weather icons from. The icon names (opens in a new tab) provided by the Xweather Weather API will be appended to the end of this URL path along with the value defined by icons.ext.
icons.extThe file extension to use for the weather icons from the source specified by icon.path
icons.mappingAn object that maps a single weather icon name to a regular expression to use against the weather icon names provided by the Xweather Weather API. Using this mapping will allow you to provide a single icon name that can be used for multiple API-specific icon names, such as using "sunny" for "sunny", "clear" and "fair". This reduces the total number of icons you need to customize and also allows you to define your own icon naming convention. Refer to the Icon Mapping section for more details.
unitsTypeThe default unit type to display, either Units.Type.Imperial or Units.Type.Metric
unitsThe unit strings to display next to values for both imperial and metric values. These are specified per data type they represent.

The following is the default configuration object for WeatherBlox:

	links: {
		loc: '{{place.state}}/{{}}',
		local: {
			main: '/local/{{loc}}.html',
			history: {
				day: '/local/{{loc}}/history/{{year}}/{{month}}/{{date}}.html',
				month: '/local/{{loc}}/history/{{year}}/{{month}}.html'
			advisory: '/local/{{loc}}/advisories.html'
		maps: {
			main: '/maps/{{regionSlug}}/{{layers}}.html'
	icons: {
		path: '//',
		ext: 'png',
		mapping: {}
	unitsType: Units.Type.Imperial,
	units: {
		imperial: {
			temp: '°F',
			speed: ' mph',
			distance: ' mi',
			height: ' ft',
			pressure: ' in',
			percent: '%',
			precip: '"',
			rain: '"',
			snow: '"',
			phrase: ''
		metric: {
			temp: '°C',
			speed: ' kmh',
			distance: ' km',
			height: ' m',
			pressure: ' mb',
			percent: '%',
			precip: ' mm',
			rain: ' mm',
			snow: ' cm',
			phrase: 'met'

Overriding defaults

To override these default configuration values using WeatherBlox, you just need to use the aeris.wxblox.config.set() method to set your desired value for the configuration's key path.

For example, the following would change the icon path to a custom icon set used across various WeatherBlox views:

aeris.wxblox.config.set('icons.path', '');

Handling links

Some WeatherBlox views and layouts contain links that can be used to direct a user to a different weather-related page, such as viewing full weather advisory information or viewing a different day for an hourly forecast. Review our documentation on handling links for more information on customizing links within your WeatherBlox implementation.

Icon mapping

Using the icons.mapping configuration option, you can provide your own method for mapping your custom icon set to the icon names provided by the Xweather Weather API. The object should be key-value pairs where the value is a regular expression string used for matching against the API icon names. For instance, the Xweather Weather API will append an "n" to the end of all icon names for their night counterparts, but not all weather icons need a nighttime representation if there isn't a sun or moon displayed. Using this icon mapping option can eliminate the need to duplicate an icon for both day and night representations.

Below is the default mapping used by WeatherBlox views:

	sunny: '(sunny|clear|fair)',
	clearn: '(sunny|clear|fair)n',
	hazy: '(hazy|smoke|dust)',
	hazyn: '(hazy|smoke|dust)n',
	drizzle: 'drizzlef?',
	tstorms: 'tstorms?w?',
	fog: 'fogn?',
	wind: '(wind|pcloudywn?|mcloudywn?)',
	snowflurries: '(snow)?flurries',
	sleet: '(sleet|freezingrain)',
	rainandsnow: '(rain(and)?snow|rainsnow)',
	showers: 'showersw?n?',
	blizzard: 'snoww'