Place Search

Place Search

Object
aeris.wxblox.views.PlaceSearch
Data Usage
/places (1 per query)

The PlaceSearch view can integrated into your application so your users have the ability to select which location they would like to see weather data for.

Place Search

Examples

Displays the primary place search field:

const view = new aeris.wxblox.views.PlaceSearch('#wxblox');
view.load();

Displays the place search field with a custom selection handler to redirect to a location's page:

const search = new aeris.wxblox.views.PlaceSearch('#wxblox');
search.on('select', function(e) {
    var p = e.data.place;
    var stateOrCountry = (p.place.state) ? p.place.state : p.place.country;
    var url = locationPageUrl;
    url = url.replace(/{{loc}}/, encodeURIComponent(p.place.name.toLowerCase() + ',' + stateOrCountry.toLowerCase());
    window.location.href = url;
});

Configuration

The following configuration options are supported by this view:

OptionDescriptionDefault
searchOnChangeType: boolean (undefined)When set to false, user will need to hit enter or the search icon after typing to retrieve list of applicable places. Default value will display results as the user types.true
enabledType: boolean (undefined)Whether or not the view is enabled. If false then the view will not be rendered and data required for the view will not be requested. This option is typically only applicable for views contained within a parent layout.true
metricType: boolean (undefined)Whether or not to display units in metric. The method setUnits() can be used at runtime once a view has rendered to change the units currently displayed.false
renderNoDataType: boolean (undefined)Whether or not the view should be rendered if data was not returned or not available.true
requestType: object (undefined)An object containing the default Weather API request options to use for the views's data request where applicable. These parameters can also be overriden in the load(:params) method when rendering the view using the JavaScript method.``

Methods

The following methods are supported by instances of this view:

Events

The following events are triggered by instances of this view: