Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <head>
- <meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no" />
- </head>
- <!--[if IE]>
- This page does not support Internet Explorer. Please download <a href="http://google.com/chrome">Chrome</a> or<a href="http://mozilla.org"> Firefox</a> for your system.
- <![endif]-->
- <script src="http://maps.googleapis.com/maps/api/js?sensor=true"></script>
- <script src=geo.js></script>
- <script>
- function onPositionUpdate(position)
- {
- var lat = position.coords.latitude;
- var lng = position.coords.longitude;
- // alert("Current position: " + lat + " " + lng);
- document.getElementById("coord").value = ("" + lat + "," + lng);
- }
- if(navigator.geolocation)
- navigator.geolocation.getCurrentPosition(onPositionUpdate);
- else
- alert("navigator.geolocation is not available");
- </script>
- <form method="GET" action="test.php">
- <input id="coord" name="coord" value="">
- <input type="submit" value="Enter Location">
- </form>
- <?php
- $weather_loc = $_GET["coord"];
- echo $coord;
- $json_string2 = file_get_contents("http://api.wunderground.com/api/YOURAPI/geolookup/conditions/forecast/q/$weather_loc.json");
- $json_string = file_get_contents("http://api.wunderground.com/api/YOURAPI/geolookup/conditions/forecast/q/$weather_loc.json");
- $current_parse = json_decode($json_string2);
- $parsed_json = json_decode($json_string, true);
- $current = $current_parse->{'current_observation'}->{'temp_f'};
- $parsed = $parsed_json['forecast']['txt_forecast']['forecastday'];
- $loc = $parsed_json['location']['city'];
- $state = $parsed_json['location']['state'];
- //pr($parsed_json);
- if (empty($weather_loc)) {
- echo 'No location has been set. Please hit the button above';
- }
- else {
- echo 'Weather forecast for: ',$loc , ',' ,$state;
- echo '<center>Currently: <b><font color="red">' . $current . 'F</center>';
- foreach($parsed as $key => $value)
- {
- echo '<table border="1" width="100%">';
- echo '<tr>';
- echo '<th><b>' . $value['title'] . '</th></font>';
- echo '</tr>';
- echo '<tr>';
- echo '<td width="50%">' .$value['fcttext'] . '</td></font>';
- echo '<td width="10%"><center><img src=' . $value['icon_url'] . '></td>';
- echo '</tr></table>';
- }
- echo '<div id="radar">';
- echo '<td>';
- //echo include ('./dom/yt.php');
- echo '</td>';
- echo '</div>';
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment