Hi,

I am currently working on an application that periodically (every 30
secs) grabs two tweets within the UK from two specified football teams
using the json format.  Within the json file I can access the location
of each tweet which is currently textual (manchester, bristol etc).

What I need to do is somehow geocode the locations and use the lat,lng
co-ords to plot the tweet data onto multiple (2) infowindows.  I've
had a crack at using the geocode API but have had no luck yet.
Currently I'm trying to just output the co-ords into a test div to see
if it works, but it isn't.

My general code is below if that helps, any advice or help regarding
this would be grrreat!
(currently I am also just outputting the twitter data into placeholder
divs for the meantime)




//create urls for grabbing both teams tweets in the UK area
  var url1="http://search.twitter.com/search.json?q=
%23"+team1+"&callback=?&geocode=53.779292%2C-1.579413%2C350mi";
  var url2="http://search.twitter.com/search.json?q=
%23"+team2+"&callback=?&geocode=53.779292%2C-1.579413%2C350mi";

  function team1tweets()
  {
                $.getJSON(
                url1,function(results){ // get the tweets
                var res1 = results.results[0].text;
                var user1name = results.results[0].from_user;
                var user1Location = results.results[0].location;

                // get the first tweet in the response and place it inside the 
div
                $("#last-tweet1").html(res1 + "<p>from: " + user1name + " (" +
user1Location + ")</p><p>");
                }
                );

                //convert location into longitude and latitude
                var convertLocUrl1 = 
"http://maps.googleapis.com/maps/api/geocode/
json?address=" + userLocation1 + "&sensor=false&region=uk";
                convertLocUrl1,function(locResult){
                var lat1 = locResult.results[0].geometry.location.lat();
                var lng1 = locResult.results[0].geometry.location.lng();
                $("#testDiv").html("latitude:" + lat1 + "<p>longitude:" + lng1 
+ "</
p>");
                }

  }

   function team2tweets()
   {
                $.getJSON(
                url2,function(results){ // get the tweets
                var res2 = results.results[0].text;
                var user2name = results.results[0].from_user;
                var user2Location = results.results[0].location;
                $("#last-tweet2").html(res2 + "<p>from: " + user2name + " (" +
user2Location + ")</p>"); // get the first tweet in the response and
place it inside the div
                });

//convert location into longitude and latitude
                var convertLocUrl2 = 
"http://maps.googleapis.com/maps/api/geocode/
json?address=" + userLocation2 + "&sensor=false&region=uk";
                convertLocUrl2,function(locResult){
                var lat2 = locResult.results[0].geometry.location.lat();
                var lng2 = locResult.results[0].geometry.location.lng();
                $("#testDiv2").html("latitude:" + lat2 + "<p>longitude:" + lng2 
+ "</
p>");
                }
   }

   team1tweets();
   team2tweets();

  setInterval(checkStream1,20000);
  setInterval(checkStream2,20000);


  function checkStream1()
  {
                team1tweets();
  }

  function checkStream2()
  {
                team2tweets();
  }
});
</script>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Maps JavaScript API v3" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-maps-js-api-v3?hl=en.

Reply via email to