Android Question Weather forecast?

Colin Evans

Active Member
Licensed User
Longtime User
Hi

I've tried looking at some of the weather examples but never managed to get any working. so I've looked the Met Office Widget and wondered if its possible to display the results of that in my B4A app, as shown in the example

The script generated by the met office widget is

<code>
<script type="text/javascript"> moWWidgetParams="moAllowUserLocation:true~moBackgroundColour:black~moColourScheme:grey~moDays:7~moDomain:www.metoffice.gov.uk~moFSSI:310012~moListStyle:vertical~moMapDisplay:none~moShowFeelsLike:true~moShowUV:true~moShowWind:true~moSpeedUnits:M~moStartupLanguage:en~moTemperatureUnits:C~moTextColour:white~moGridParams:weather,temperature,wind,feelslike,warnings~"; </script><script type="text/javascript" src="http://www.metoffice.gov.uk/public/pws/components/yoursite/loader.js"> </script><p>This <a href='http://www.metoffice.gov.uk/public/weather/forecast/?tab=map' target='_blank' >weather forecast</a> is generated by the <a href='http://www.metoffice.gov.uk/public/weather/components'>Met Office Weather Widget</a></p>
</code>
 

Attachments

  • widget_example.png
    widget_example.png
    35.2 KB · Views: 313

Colin Evans

Active Member
Licensed User
Longtime User
Tried it with the following code but the results are the image attached

<code>
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim webview1 As WebView
End Sub

Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Activity.LoadLayout("webview")
webview1.LoadHtml($"<script type="text/javascript"> moWWidgetParams="moAllowUserLocation:false~moBackgroundColour:black~moColourScheme:grey~moDays:7~moDomain:www.metoffice.gov.uk~moFSSI:310012~moListStyle:vertical~moMapDisplay:none~moShowFeelsLike:true~moShowUV:true~moShowWind:true~moSpeedUnits:M~moStartupLanguage:en~moTemperatureUnits:C~moTextColour:white~moGridParams:weather,temperature,wind,feelslike,warnings~"; </script><script type="text/javascript" src="http://www.metoffice.gov.uk/public/pws/components/yoursite/loader.js"> </script><p>This <a href='http://www.metoffice.gov.uk/public/weather/forecast/?tab=map?locId=310012' target='_blank' ><span id='moWWSiteName' >Liverpool</span> weather forecast</a> is generated by the <a href='http://www.metoffice.gov.uk/public/weather/components'>Met Office Weather Widget</a></p>"$)

End Sub
</code>
 

Attachments

  • weview1.png
    weview1.png
    23.7 KB · Views: 298
Upvote 0

Colin Evans

Active Member
Licensed User
Longtime User
That code doesn't seem to work, if you save it and try to open it on a browser you will get the same results.
Thanks for the reply, the code was generated by the met office web site, so I've asked them the question, I'll keep it updated
 
Upvote 0

Colin Evans

Active Member
Licensed User
Longtime User
Thanks for the reply, the code was generated by the met office web site, so I've asked them the question, I'll keep it updated
Met Office replied but only to say they weren't aware of any problems, so I now use this one from acuweather, which seems to work okay,

<a href="http://www.accuweather.com/en/gb/new-brighton/ch45-0/weather-forecast/325626" class="aw-widget-legal"></a>
<div id="awtd1467067750896" class="aw-widget-36hour" data-locationkey="325626" data-unit="f" data-language="en-us" data-useip="false" data-uid="awtd1467067750896" data-editlocation="true" data-lifestyle="fishing"></div><script type="text/javascript" src="http://oap.accuweather.com/launch.js"></script>
 
Upvote 0
Top