Working dynamically with Google Latitude

YoWindow related topics that do not fit in the above forums
Post Reply
klous-1

Working dynamically with Google Latitude

Post by klous-1 »

In case anyone is interested I have managed to get this to work, a PHP script that reads your current GPS location from google latitude, finds the nearest weather station and outputs it to the yowindow widget.

You must make sure that these two setting in your PHP.INI file are set as follows:
allow_url_include = On
allow_url_fopen = On

You must also create a User account on geonames.org to be able to use the system to retrieve the weather station data (you might have noticed that yowindow uses geonameIds)

Then just replace the variables at the top:

google latitude User ID.
geoname ID
the flash vars as is seen in your current HTML for the size and whatever.

Call this PHP instead of writing the whole <param name="flashvars"........>

You'll still need all the other stuff in your oringal HTML, the DIVs and other PARAMs,

You can see it working on my site,http://www.talesfromthesaddle.com but the beauty is dragging your location on google latitude to all over the world and seeing the weather and locations change!

The time shown in Yowindow, on my computer at least, is not quite up to speed....maybe someone can point out my numerous errors.

Code: Select all

<?PHP
header('Content-Type: text/plain');

// VARIABLES, SET THESE AS NEEDED
$googleuserId = 'INSERT YOUR GOOGLE LATITUDE ID NUMBER';
$geonamesid= 'INSERT YOUR GEONAMES.ORG ID';
$flashvars= '&landscape=airport&time_format=24&us=uk&background=#666666&mini_momentBar=false&copyright_bar=false"><a href="http://yowindow.com/weatherwidget.php" style="width: 180px; height: 140px; display: block; text-indent: -50000px; font-size: 0px; background: #DDF url("http://yowindow.com/img/logo") no-repeat scroll 50% 50%">';

if ( $_GET['user'] ) {
if ( is_numeric( $_GET['user'] ) )
$googleuserId = $_GET['user'];
else
exit('This isn\'t a valid user id.');
}

$url = 'http://www.google.com/latitude/apps/badge/api?user='.$googleuserId.'&type=json';

// We get the content
$content = file_get_contents( $url );

// We convert the JSON to an object
$json = json_decode( $content );

$coord = $json->features[0]->geometry->coordinates;
$timeStamp = $json->features[0]->properties->timeStamp;

if ( ! $coord )
exit('This user doesn\'t exist.');

$date = date( 'Y-m-d H:i', $timeStamp );
$lat = $coord[1];
$lon = $coord[0];
 // loop through our records to find weather station
$sXML = new SimpleXMLElement('http://api.geonames.org/findNearByWeather?lat='.$lat.'&lng='.$lon.'&username='.$geonamesid.'&style=short&maxRows=1', NULL, TRUE);


foreach($sXML as $geo) 
{
         
$ICAO=$geo->ICAO;
$placename= $geo->stationName;

        }
echo '<param name="flashvars" value="current_weather_icao='.$ICAO.'&location_name='.$placename.'&moment=';

//To Find Timezone
$sXML2 = new SimpleXMLElement('http://api.geonames.org/timezone?lat='.$lat.'&lng='.$lon.'&username='.$geonamesid.'&style=short&maxRows=1', NULL, TRUE);

foreach($sXML2 as $loop) // loop through our records
{
$timestamp=$loop->time;
   $time=substr($timestamp, -5);
   $date= substr(trim($timestamp), 0,10);
   $offset = $loop->gmtOffset;
  
   }
  echo $date.'T'.$time.':00Z'.$offset.$flashvars;

?>
User avatar
par
Posts: 8623
Joined: Mon Sep 21, 2009 11:56 am
Name: Pasha
Location: Saint-Petersburg, Russia
Contact:

Re: Working dynamically with Google Latitude

Post by par »

Wow!
That is impressive!
I was dreaming of making the same kind of service - Google Maps + YoWindow for a long time.
You've made it first :)

Unfortunately, I was not able to play with your service.
Can you point me to a page where I can drag the location and see how it reflects in the widget?

We are lucky to have you on the forum, please stay with us! :)
Get YoWindow weather app for your phone or tablet.

Image Image Image
klous-1

Re: Working dynamically with Google Latitude

Post by klous-1 »

Hi,

Can you set up a google latitude ID?

Give me your google latitude ID number (not the name).....to get this, set up the account, go to Apps and find "Developers" at the bottom, you'll find a number there.

I'll input this into my website's PHP for you temporarily, then you can just move your google location around andview it on my website as above. So far it seems to be working ok, I've tried a few locations. The only prob is the time stamp...and perhaps some of the names are a bit long....
klous-1

Re: Working dynamically with Google Latitude

Post by klous-1 »

OK, I set something up,

Go to the Google LAtitude site, https://www.google.com/latitude/b/0

log into as user "talesfromthesaddle@hotmail.com", with password "yowindow"

Open another tab or window with http://talesfromthesaddle.com/yowindow/yowindow.shtml

Move the marker on google latitude to any location in the world, refresh the talesfromthesadle window and see the location and weather update automatically.

I have found quite a few places where this doesn't work, siberia, africa, inner mongolia....I'll keep testing, but it should work where there are nearby weather stations registered with Geonanes....not ideal....
Last edited by klous-1 on Thu Jul 28, 2011 11:02 pm, edited 2 times in total.
klous-1

Re: Working dynamically with Google Latitude

Post by klous-1 »

Fixed, works anywhere now!

So just the slight issue with the time Par....maybe this is just my computer though, can someone check the time shown?
User avatar
par
Posts: 8623
Joined: Mon Sep 21, 2009 11:56 am
Name: Pasha
Location: Saint-Petersburg, Russia
Contact:

Re: Working dynamically with Google Latitude

Post by par »

Works like a charm :)
I like the idea and the implementation, good job!
Get YoWindow weather app for your phone or tablet.

Image Image Image
User avatar
portaleazzurro
Posts: 618
Joined: Thu Mar 18, 2010 10:29 pm
Name: Franco
Location: Puglia (Apulia) -Italy-
Contact:

Re: Working dynamically with Google Latitude

Post by portaleazzurro »

My first post March 20, 2010:
http://yowindow.com/forum/viewtopic.php?f=5&t=645
portaleazzurro wrote:Hi,
I congratulate the authors of this fantastic way of Representing the situation and the weather. Certainly it is something totally innovative. Somehow I Placed on my site using Wordpress.com (WordPress only wants to HTML).
As they are also fond of astronomy would like to propose the following:
1) At night when you scroll with the mouse on the starry sky, it would be wonderful to identify the major constellations (Ursa Major, Ursa Minor, Orion, Cassiopeia, Auriga, the Pleiades, Gemini, Scorpio, Taurus, etc. ... .) The most important stars (pole star, Deneb, Aldebaran, Capella, Sirius, Vega, Antares, Spica, etc. ..) and planets (Venus, Jupiter, Mars, Mercury, Saturn, etc. ..)?
2nd) The screen could not insert a kind of compass to orient at will (south, east, north, west) to see your screen so you can observe the sky (especially at night) at 360 degrees? (day also turning their backs to the sun would be created on the ground a sundial (sun dial) with the equinox and solstitial ...).
3) Assuming you can combine a small globe (or a small map) terrestrial, could not we, as you move your mouse over the globe or on the map, see YoWindow on the situation of the time of the place touched by the cursor?
I wish you all a happy spring equinox (tonight at around 18, now more and sometimes less)
. Franco.

Fantastic !!! :Yahoo!:
it's true: everything you can think of, you can achieve !
Congratulations Nick.
Keep us informed.
Franco. :)
"If you look at the sky forever, we would be having wings." (G. Flaubert)
Sincerely from my home and my country. Franco.
klous-1

Re: Working dynamically with Google Latitude

Post by klous-1 »

Hi Franco,

You probably can...I'm no PHP wizard really...I think you could use it with the google maps API...if I get some time I'll look into it a bit and post back here, but can't really promise anything. LEt's see!

Nick
airunreal

Re: Working dynamically with Google Latitude

Post by airunreal »

klous-1 wrote:Hi Franco,

You probably can...I'm no PHP wizard really...I think you could use it with the google maps API...if I get some time I'll look into it a bit and post back here, but can't really promise anything. LEt's see!

Nick
can you find some free time and post as promised? i'm waiting for that. thanx in advance
LishaZey
Posts: 3
Joined: Sat Oct 25, 2014 6:17 am
Name: Lisha

Re: Working dynamically with Google Latitude

Post by LishaZey »

The integration of YoWindow with Google Maps is a success. I hope more advancement will be announced soon. :good:
Lisha
Post Reply