web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Show weather based on ...
Power Apps
Answered

Show weather based on user location

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi guys!

 

I'm trying to build an app to put on my SharePoint intranet site that provides some personalization. Right now I'm trying to show the weather based on the user's location. Ideally, the app would show the city of the user's current location + the weather for that city.

 

I have managed to show the precise address of the user by setting the OnVisible property of the screen to 

 

Set(myLocation, BingMaps.GetLocationByPoint(Location.Latitude, Location.Longitude))

 

Then adding a text box with myLocation.name

 

What I would now like to do is:

  • From this exact address, show JUST the City name (incl. perhaps the Country name), and
  • Using this city, show the weather for that city.

 

Everything I've tried so far has not worked. Anyone any ideas...?

 

Thanks!

 

Merel

Categories:
I have the same question (0)
  • Max44 Profile Picture
    223 on at

    Well... First of all there is no need to use WebServices, but you can't do it without any API. As I can see you use openweathermap API . As far as I know this API returns both longitude and latitude, so you can use these values as input to another request to a photo API (like flickr) to get the image you want. Moreover openweathermap API returns city name which can make your photo request even more accurate.

     
  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi @Max44 ,

     

    Thanks for your swift reply! I'm not sure I totally understand, though.

     

    I'm not trying to get a photo, just city name (and maybe country) but more importantly the weather for the current user.

     

    I have used the Bing Maps API to pinpoint the user's location but after that I'm stuck. Is it not possible to do this using Bing Maps API & the built in MSN Weather connection?

     

    Thanks again!

    Merel

  • Verified answer
    v-bofeng-msft Profile Picture
    Microsoft Employee on at

    Hi @Anonymous :

    Do you want to get the users current location and the current weather for that city?

    Firstly, I want to explain why you encounter this problem.

    The key is to use a connector with "weather" functionality.(BingMap does not has the feather about whether)

    I suggest you use MSN Weather connection here.

    In addition, Location.Latitude&","&Location.Longitude is enough. For convenience, we do not need to use BingMaps here.

    Secondly, Ive made a test for your reference:

    Case1:use BingMap

    1/add a button and set its OnSelect property to:

    Set(myLocation, BingMaps.GetLocationByPoint(Location.Latitude, Location.Longitude));
    Set(myweather,MSNWeather.CurrentWeather(myLocation.address.addressLine,"Metric"))

    2/add three label controls(Label1/ Label2/ Label3) and set their Text property to:

    Label1:

    "Area:"& myweather.responses.source.location

    Label2:

    "CAP:"& myweather.responses.weather.current.cap

    Label3:

    "Temp:"& myweather.responses.weather.current.temp&myLocation.units.temperature

    Case2:do not use BingMap

    1/add a button and set its OnSelect property to:

    Set(myweather,MSNWeather.CurrentWeather(Location.Latitude&","&Location.Longitude,"Metric"))
     

    Best Regards,

    Bof

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi @v-bofeng-msft !

     

    Thanks for your reply! I used a combination of the things mentioned by you and got the results I wanted. Here I'll share what I did for whoever is interested:

     

    1. I set the OnStart property of the app to:

    // LOCATION //
    
    //Set some variables to retrieve current User's location
    
    Set(myLocation, BingMaps.GetLocationByPoint(Location.Latitude, Location.Longitude));
    
    //WEATHER
    
    //Set variables to collect weather information
    Set(myWeather,MSNWeather.CurrentWeather(Location.Latitude&","&Location.Longitude,"Metric"));
    Set(myForecast,MSNWeather.TomorrowsForecast(Location.Latitude&","&Location.Longitude,"Metric"))

     

    2. Created a Label for Location:

    myLocation.address.formattedAddress

    Note: I would like to only show the City here, but have not managed to do that yet

     

    3. Created a label for Today's weather for my specific location:

    myWeather.responses.weather.current.temp & " "& myWeather.units.temperature

     And one for tomorrow:

    myForecast.responses.daily.tempLo & " "& myWeather.units.temperature & " - " & myForecast.responses.daily.tempHi & " "& myWeather.units.temperature

     

    The result:
    Annotation 2020-04-14 114638.png

     

    Cheers,

    Merel

  • JaguarMonkey Profile Picture
    71 on at

    Interestingly, If i use solution one, I am place in the wrong city.  If I use solution 2 it place mes in the right location

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 505

#2
WarrenBelz Profile Picture

WarrenBelz 502 Most Valuable Professional

#3
Haque Profile Picture

Haque 324

Last 30 days Overall leaderboard