Configuration Options

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:

links Defines the URL formatting to use for various types of links used throughout the views and layouts
links.loc Defines how to format locations when used in a URL via the {{loc}} variable
links.local.main URL to the main local weather layout
links.local.history URL to the local daily and monthly observation layouts
links.local.advisory URL to the local advisory layout
links.maps URL to the main maps layout
icons.path Base URL path to load weather icons from. The icon names provided by the Aeris Weather API will be appended to the end of this URL path along with the value defined by icons.ext.
icons.ext The file extension to use for the weather icons from the source specified by icon.path
icons.mapping An object that maps a single weather icon name to a regular expression to use against the weather icon names provided by the Aeris 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.
unitsType The default unit type to display, either Units.Type.Imperial or Units.Type.Metric
units The 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. Note that only the links options are currently overridable using the API method:

	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'

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 Aeris 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 Aeris 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'

Last modified: October 03, 2018