Hi all,
I found a lot of threads about placing a weather icon in maps (or create a sensor to monitor it) but nothing worked well for me so I did one by myself.
Admin Note:
Requires an secondary web-server capable of processing php scripts.
1. Create a page called weather.php and copy/paste this:
<? $request = 'http://api.openweathermap.org/data/2.5/weather?q='. $_GET["location"] .'&lang=en'; $response = file_get_contents($request); $jsonobj = json_decode($response); ?> <div style="border: 1px solid black; width: 85px; text-align: center;"> <p style="margin: 0px; font-family: Verdana; font-size: 10px"><?echo $jsonobj->{'weather'}[0]->{'description'}?></p> <img src="http://openweathermap.org/img/w/<?echo $jsonobj->{'weather'}[0]->{'icon'}?>.png"> </div>
Save weather.php on your web server.
2. Add in your map a custom HTML object and copy this code in the html-after:
<iframe src="http://yourwebserver/weather.php?location=London,uk" allowtransparency="true" frameborder="0"></iframe>
I hope that this could help you :)
Add comment