0

I Have retrieved 5 tweets with twitter4j(Java api for twitter) and now I want to display them on google map.

Google map has a javascript api.

Any Idea how could I display them on google map. can this data be sent to google maps directly and display them on google map

One of my result looks as below.

UPDATES FOR QUERY: Party

Location: null

Profile Location: Paris, France

UserName1: SusanClay20

Message: Looking to Book your Christmas Party? See how we can help :)

I want to actually display profile picture on map but I was wondering how this would this be possible.

Do I need to store them some where fist and then display on google maps? I am really Blank about this and Any comment would be appreciated.

Thanks

Br

Sara
  • 585
  • 7
  • 12
  • 22

1 Answers1

0

In Google Maps, you can utilize info windows to be displayed at certain markers. Some sample code from the 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);
});

If it's something you're getting through say, AJAX polling then you would turn this into a function that gets called with the location info, and change contentString to be an HTML representation of how you want to display the tweet. The same principle would happen if you're not doing polling and simply want to do it on page load. Instead you would have the function, then utilize the backend system to print out javascript calls of the function with the data to be populated.

cwgem
  • 2,739
  • 19
  • 15
  • Thanks for the reply but My question is still there how would a request be sent to google maps from Eclipse. I am using Twiiter4j which is a Java api for twitter. I am only trying to understand relationship. how request can be sent to google maps, For Android application we hav google maps but not for web applications ! – Sara Mar 03 '13 at 16:21
  • For web applications, Google Maps requests are generally handled by the [javascript API](https://developers.google.com/maps/documentation/javascript/). If you're creating a Java web app, there is usually an abstraction / direct access to javascript generation. What that access is depends on the underlying java web framework. – cwgem Mar 03 '13 at 16:28
  • You could call the information with javascript and then create a json/xml feed that you could call from within your other api much like calling the tweets and perform the calculations there I guess. But yes, the whole idea would be reasonably simple in straight javascript. – Rafe Mar 03 '13 at 17:27