Skip to main content

Weather information and season images for your app using this beautiful plugin!

Weather Info! Have you ever wanted the weather info for your app without all of the httpclient stuff? You are in the right place.. I've got an amazing yet beautiful plugin for you! Let's Get Started! Open up a new project or use the project which you are currently working on.. Today I am going to use a console project. As always right click on the solution and click on manage nuget packages. Search for plugin.weather and install the first package.. Add the following namespaces to your file.. using Plugin.Weather; Let's First get the weather of current time using the city. For that use the following code. Weather weather = Api.GetWeatherByCity("City Name"); Now we can access all the weather information using the "weather" object. The below image shows the information which we can access using the weather object. Now I am going to write all the information to the console. You can also get the weather image url and save the image as Png/Jpg/Gif Format..   C

Weather information and season images for your app using this beautiful plugin!

Weather Info!


Have you ever wanted the weather info for your app without all of the httpclient stuff?
You are in the right place..
I've got an amazing yet beautiful plugin for you!


Let's Get Started!


Open up a new project or use the project which you are currently working on..

Today I am going to use a console project.

As always right click on the solution and click on manage nuget packages.


Search for plugin.weather and install the first package..


Add the following namespaces to your file..



Let's First get the weather of current time using the city.

For that use the following code.

Now we can access all the weather information using the "weather" object.

The below image shows the information which we can access using the weather object.


Now I am going to write all the information to the console.

You can also get the weather image url and save the image as Png/Jpg/Gif Format..
 
Code:
 
Let's take a city. Example: Wellington.
 
Output:

 
We have got the following information for Wellington, New Zealand.
 
Temperature: 17,
Humidity: 94, 
Looks like Day? no, 
Latitude: -41.300, 
Longitude: 174.783, State: , 
Country: New Zealand, 
Weather: Partly cloudy, 
Cloud Cover 50, 
Time Zone: Pacific/Auckland, 
Wind Speed 4, 
Wind Degree 320, 
Wind Direction: NW, Pressure: 1018,
 Icon Url: https://assets.weatherstack.com/images/wsymbols01_png_64/wsymbol_0004_black_low_cloud.png 

Let's take a look at a city in the northern hemisphere.. Example: Seoul

Output:

 
We have got the following information for Seoul, South Korea.
 
Temperature: -2,
Humidity: 63,
Looks like Day? no,
Latitude: 37.566,
Longitude: 127.000,
State: null,
Country: South Korea,
Weather: Clear,
Cloud Cover 0,
Time Zone: Asia/Seoul,
Wind Speed 2,
Wind Degree 210,
Wind Direction: SSW,
Pressure: 1029,
Icon Url: https://assets.weatherstack.com/images/wsymbols01_png_64/wsymbol_0008_clear_sky_night.png

Now let's take a look at te other functions of this package.

We can get the current season in the north/south hemisphere.

Code:

Output:

At the time of writing the article its Winter in the north and summer in the south.

We can also get the images of various seasons using the following code..

You will have to pass a random value between 1 to 5.

Code:

 
Let's check the folder.

 
There are a few files created!

And they show the pics of the different seasons of the nature.

You can also get an image based on season in the northern and the southern hemisphere.

Use this code:

Again you will need to specify a random number between 5 to get the image.

 Output:

  

There are two files created.

 

At the time of writing the season in the north is Winter and its summer in the south.

By using just two lines of code we can get a random image based on the current season and the value given. 

It's easy right.

Summary

In this article, we have learnt how to get the weather info and how to get not only the current season but also how to get the image of a season or get the image using the current season using C#.
 
This works on all the .net core projects such as ASP.NET, Xamarin.Forms, WinForms, WPF, .NET MAUI.
Please download the nuget package used in this article.
 
Link:  https://www.nuget.org/packages/Plugin.Weather/
 
(OR)
 
Execute the following command in the package console.

 

Please leave your questions and feedback in the comments.
I would love to hear from you.
 
Please check out my Tech Youtube channel.. I have a lot of  entertaining Tech content in it..
 
Link: https://www.youtube.com/channel/UCOmqF3cD0ajQ91EVOyI1U7w
 
Thank You! 

Comments

Popular posts from this blog

How to Create VCards using this amazing plugin!

How to Create VCards? Introduction What type of file does your phone saves when u create a contact? Well, the answer is: It stores it in a file format called vcard. Where vcard stands for "Virtual Contact Card". At the time of writing this article., there are not whole lot of nuget packages that can do this. I have Created a nuget package that helps you to achieve it.. So, in this tutorial, we are going to create a vcard using C#. Create a vcard using C# Let's get started by creating a new project in visual studio for Mac. Please Note that this package also work for visual studio for windows too.. Click on "new project" and select"Console Project" and click on next. Give it a name and click on "Create" Now right click on the solution and click on manage nuget packages. Search for "VCards" and click on the third result. Click on "Add Package" to install it in your project. Then add the following namespaces to your project.