在谷歌地图上显示推文

时间:2013-03-03 14:17:22

标签: google-maps google-maps-api-3 twitter twitter4j

我已经使用twitter4j(推特的Java api)检索了5条推文,现在我想在谷歌地图上显示它们。

Google地图有一个javascript api。

任何想法如何在谷歌地图上显示它们。可以将这些数据直接发送到谷歌地图并在谷歌地图上显示

我的一个结果如下所示。

查询更新:派对

位置:null

简介位置:法国巴黎

UserName1:SusanClay20

消息:想要预订圣诞派对?看看我们如何提供帮助:)

我想在地图上显示个人资料图片,但我想知道这是如何实现的。

我需要将它们存储在拳头中,然后在谷歌地图上显示吗? 我对此非常感到满意,任何评论都将不胜感激。

由于

1 个答案:

答案 0 :(得分:0)

在Google地图中,您可以利用信息窗口显示某些标记。来自Google developer's page的一些示例代码:

var myLatlng = new google.maps.LatLng(-25.363882,131.044922);
var mapOptions = {
  zoom: 4,
  center: myLatlng,
  mapTypeId: google.maps.MapTypeId.ROADMAP
}

var map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);

var contentString = '<div id="content">'+
    '<div id="siteNotice">'+
    '</div>'+
    '<h2 id="firstHeading" class="firstHeading">Uluru</h2>'+
    '<div id="bodyContent">'+
    '<p><b>Uluru</b>, also referred to as <b>Ayers Rock</b>, is a large ' +
    'sandstone rock formation in the southern part of the '+
    'Northern Territory, central Australia. It lies 335 km (208 mi) '+
    'south west of the nearest large town, Alice Springs; 450 km '+
    '(280 mi) by road. Kata Tjuta and Uluru are the two major '+
    'features of the Uluru - Kata Tjuta National Park. Uluru is '+
    'sacred to the Pitjantjatjara and Yankunytjatjara, the '+
    'Aboriginal people of the area. It has many springs, waterholes, '+
    'rock caves and ancient paintings. Uluru is listed as a World '+
    'Heritage Site.</p>'+
    '<p>Attribution: Uluru, <a href="http://en.wikipedia.org/w/index.php?title=Uluru&oldid=297882194">'+
    'http://en.wikipedia.org/w/index.php?title=Uluru</a> (last visited June 22, 2009).</p>'+
    '</div>'+
    '</div>';

var infowindow = new google.maps.InfoWindow({
    content: contentString
});

var marker = new google.maps.Marker({
    position: myLatlng,
    map: map,
    title:"Uluru (Ayers Rock)"
});

google.maps.event.addListener(marker, 'click', function() {
  infowindow.open(map,marker);
});

如果这是你要通过说的话,AJAX轮询然后你会把它变成一个用位置信息调用的函数,并将contentString改为你想要显示的方式的HTML表示鸣叫。如果您不进行轮询并且只是想在页面加载时执行此操作,则会发生相同的原则。相反,您将拥有该功能,然后利用后端系统打印出要填充的数据的函数的javascript调用。

相关问题