We have 74 guests and no members online
jsWeather offers a solution for preparing generally available weather data and displaying it in a user-friendly way. For this, the easy and safe to use weather application interface (API) from "OpenWeatherMap" is used.
OpenWeatherMap is a commercial online service that provides an interface for retrieving weather data, weather forecasts, and historical weather data for web application and mobile device developers. Some of the available data can be accessed after a registration for free.
With the use of OpenWeatherMap three program developments have been realized:
Weather in New York28th March, 2024 - 9:49
Moderate Rain
Humidity: 90 %
Wind: 4.6 mph North
Pressure: 1,017 hPa
Visibility: 32,808 ft
|
jsWeather is a lightweight and versatile Joomla module that displays weather information for any location, including information such as, humidity, barometric pressure, wind, visibility. It was developed using the latest current version of openWeatherMap as weather data source. Key features of jsWeather include:
|
This application shows weather informations on any location - please choose your location to be displayed. The forecast shows weather developments in any location at midday for 5 days. In addition, a diagram shows how the daily temperature will develop.
The data for this application is provided via a web service by "OpenWeathermap". This data is processed with the help of web application class "js_weather" and displayed in the above format.
The jsweather.ini file contains messages for the languages "German, French and English. If necessary, you can adapt the entries or add new languages.
Now check whether with the url ""installation directoryjsweather/index.php, whether your installation was successful.
With Joomla, it is best to use the application with the options of the jphpx component or the jphpx Plugins as also implemented here in this documentation with the jphpx plugin-tag.
Independent web application solutions can only be integrated into a Joomla environment to a limited extent (e.g. with Joomla's Iframe Warapper environment). Also Joomla does not allow that php code may be used in its content. With my joomla extension, jjphpx System Package, it is possible despite this limitation to run your own web solutions under the Joomla umbrella and also to use all the capabilities of Joomla. I will show here how this is also made possible for my web application jsWeather.
A solution is created in three quick and easy steps:
Select the option "jphpx Application" or "jphpx Code Entry" via the "Components" menu item in the administrator backend. This calls the component and you can now define a new jphpx application with the "New" button. For this, a title of the application, the source (the path and the file name), the access and the activation must be entered. With the "Save" button, the new code entry becomes available after successful saving.
In this way create the entries for the following php application scripts
In the configuration file "settngs.php" in the directory: "your-directory/jsweather/jphpx" update the id numbers of the jphpx code entries.
Note: Please check that jphpx plugin version 1.3.3.4 or higher has been installed.
In the last step you make the applications available for your Joomla site. Create a new Joomla article with e.g. explanatory or introductory text to your weather application. The respective jsWeather web application is defined with a jphpx plugin tag:
{jphpx [your-directory/jsweather/jphpx/get_current_weather.php]}or
{jphpx [your-directory/jsweather/jphpx/current.php]}
{jphpx [your-directory/jsweather/jphpx/get_weather.php]}or
{jphpx [your-directory/jsweather/jphpx/forecast.php]}
{jphpx [your-directory/jsweather/jphpx/weather_info.php]}
How to use jsWeather with jphpx component or module please read jphpx reference about jphpx component and module.
Via the constructor "js_weather" __construct ($api_key, $forecast = false)
a js_weather object is created. A required parameter is the API key of openWeatherMap, the second parameter defines whether data for the weather forecast or about the current weather should be delivered. Example:
my_weather = new js_weather ($api_key, true);
The method "setLocation" setLocation ($location, $use_ip = false)
specifies the location for the weather data. The format is either a place name or an indication of geographic coordinates. If the second parameter ($use_ip) is set to "true", an attempt is made to deliver the location via a geolocation server. The return value is "true" if the execution was successful. Example:
$rc = my_weather->setLocation("52.3472,14.5506");
The weather data is returned using the get_weather_data ($dir = null)
method. If the $dir parameter specifies a valid directory, the weather data will be saved in the file "save_weatherdata.$id" within directory "$dir". Saving will only be done if the request was successful. The $id suffix can be set using the setID($id) method. set (default is "1"). This function is used e.g. in the jsWeather joomla module for caching the weather data. Example:
$weather_info = $myweather->get_weather_data());The output format is always a JSON object. The structure of this object is documented in openWeatherMap, e.g. for weather forecast.
In addition, "getter" and "setter" methods are available for use:
With version 1.1.5 you may use owfont, which is a symbol font for Open Weather Map API. owfont is designed to match to weather condition codes returned by OpenWeatherMap API. It uses the response code as class name (prefixed with owf) and displays the related weather icon.
When using geolocation servers, an attempt is made to deliver the geographic coordinates via the website visitor's Internet address. However, this location allocation can only be as accurate as the respective data provided by the internet providers. IP-based geolocation services can be expected to provide 55 to 80 percent accuracy for a user's region or state.
Weather data are never "precise" they always relate to a more or less large region. It is therefore quite possible that e.g. rain is displayed although there is no rain in sight at the selected location.
If you get a "400" error when entering a valid location, you should enter the place name in lower case and then try the request again. If this also leads to the same error, enter the geographic coordinates of the location.
jsWeather is free software (like Joomla!) - however you must follow the GPL license terms to use it. More about GPL and free software can be found at GNU Org.
To download jsWeather click the "download" image:
jsWeather module version 1.1 for Joomla!
jsWeather Web-Application and js_weather class
Any questions? Visit the Support Forum or send an email to the developer, our webmaster.
The data for this application is provided via a web service provided by "OpenWeathermap". With my web application "jsWeather" this data is processed and displayed in the above format.
OpenWeatherMap is a commercial online service that provides an interface for retrieving weather data, weather forecasts, and historical weather data for web application and mobile device developers. Some of the available data can be accessed for free after successful registration .