0

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

谷歌地图有一个 javascript api。

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

我的结果之一如下所示。

查询更新:派对

地点:空

简介地点:法国巴黎

用户名 1:SusanClay20

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

我想在地图上实际显示个人资料图片,但我想知道这怎么可能。

我是否需要将它们存储在拳头上,然后显示在谷歌地图上?我对此真的很空白,任何评论都将不胜感激。

谢谢

4

1 回答 1

0

在 Google 地图中,您可以利用信息窗口在某些标记处显示。谷歌开发者页面的一些示例代码:

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 调用以及要填充的数据。

于 2013-03-03T14:31:57.290 回答