【问题标题】:How to ascertain location (co-ords) of a tweet如何确定推文的位置(坐标)
【发布时间】:2011-03-28 11:27:46
【问题描述】:

我正在使用 jQuery 以 json 格式检索和显示关于 2 个足球队的推文。 我目前正在输出文本和用户 ID,但我计划在谷歌地图上绘制这些推文。但首先我需要获取推文的位置。关于如何实现这一点的任何想法。

到目前为止的基本代码如下;

<script type="text/javascript"> 
$(document).ready(function(){
var team1, team2; 
team1 = '<?php echo $_GET["team1"]; ?>'; 
team2 = '<?php echo $_GET["team2"]; ?>'; 

var url1="http://search.twitter.com/search.json?q=%23"+team1+"&callback=?";
var url2="http://search.twitter.com/search.json?q=%23"+team2+"&callback=?";

$.getJSON(
    url1,function(results){ // get the tweets
    var res1 = results.results[0].text;
    var userID1 = results.results[0].from_user_id;
    $("#last-tweet1").html(res1 + "<p>user id: " + userID1); // get the first tweet in the response and place it inside the div
    });


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

【问题讨论】:

    标签: jquery json twitter geolocation


    【解决方案1】:

    每个结果对象都有一个geo 元素。不幸的是,大多数推文都没有附加位置信息,所以你不会找到很多。

    【讨论】:

    • 嗨亚伯拉罕 - 我可以从 json 文件中获取用户 ID - 是否有可能以某种方式从中获取位置? (所以不一定从发送推文的地方)
    • 实际上,如果我对 twitter 使用地理编码调用,我只能返回已填写“位置”的结果(例如,曼彻斯特)。现在我需要做的就是以某种方式将其链接到 Google 地图。
    猜你喜欢
    • 2016-02-18
    • 2019-02-07
    • 2011-12-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-01-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多