Geolocate my friends
From OpenSocial Directory
|
|
| ||||||||||||||||
Image:Example.jpg==Reviews==
Add a Review
Template:Geolocate my friends Reviews
[edit] Comments
| Leave a comment |
|---|
Is it works?
I tried, but it seems getting null values to lat and long. So each friend are at the same place on map.
comment posted by: Jaime (Thu Nov 08 2007 17:05:29 GMT-0200 (BRST))
nether i and my friends can be seen on the map
comment posted by: Erik (Sun Nov 25 2007 23:49:49 GMT-0200 (Hora oficial do Brasil))
I tried, but it seems getting null values to lat and long. So each friend are at the same place on map.
comment posted by: Jaime (Thu Nov 08 2007 17:05:29 GMT-0200 (BRST))
Does it work?
Only two tags, one on the east coast, one on the west coast... Clearly not all my friends.
comment posted by: blahBlah (Sat Nov 10 2007 14:55:19 GMT-0500 (EST))
Hey guy, can u change this code to get the city, too ? i dont use my CEP , and would like to my frinds know where city i live
comment posted by: Erik (Tue Nov 13 2007 11:53:35 GMT-0200 (BRST))
"at the same place on map" i think we must change the mod how google maps see the icon. do u have seen how google earth se the same place to youtube ? he separe into a star to i can see better
comment posted by: Erik (Tue Nov 13 2007 11:57:31 GMT-0200 (BRST))
nether i and my friends can be seen on the map
comment posted by: Erik (Sun Nov 25 2007 23:49:49 GMT-0200 (Hora oficial do Brasil))
[edit] Code
<?xml version="1.0" encoding="UTF-8" ?>
<Module>
<ModulePrefs title="Geolocate my friends" height="500" width="700" author="Balachandar Muruganantham" author_email="mbchandar@gmail.com">
<Require feature="opensocial-0.5" />
<Require feature="dynamic-height" />
</ModulePrefs>
<Content type="html">
<![CDATA[
<script type="text/javascript" src="http://www.google.com/jsapi?key=ABQIAAAASXmVvbqMX11TuormEoTYQhRSk02GZpXEMAkEqFagruxbBFc2zRQvvXnyqc-2fivXs0hB8dLDi4zgNg"></script>
<script type="text/javascript">
google.load("maps", "2.x");
var map = null;
// Call this function when the page has been loaded
function initialize() {
map = new google.maps.Map2(document.getElementById("map"));
map.setCenter(new google.maps.LatLng(34,0), 2);
map.addControl(new google.maps.LargeMapControl());
map.addControl(new google.maps.MapTypeControl());
map.setMapType(G_NORMAL_MAP);
getData();
}
function getData() {
var myparam = {"profileDetail": 'contact'};
//document.getElementById('message').innerHTML = 'Requesting friends...';
var req = opensocial.newDataRequest();
req.add(req.newFetchPersonRequest('VIEWER',myparam),"viewer");
req.add(req.newFetchPeopleRequest ('OWNER_FRIENDS'), 'viewer_friends');
req.send(onLoadFriends);
};
function onLoadFriends(data) {
var viewer = data.get("viewer").getData();
var name = viewer.getDisplayName();
var thumb = viewer.getField(opensocial.Person.Field.THUMBNAIL_URL);
var profile = viewer.getField(opensocial.Person.Field.PROFILE_URL);
var geo_approx_lat = viewer.obj_.Keywords[1].Value;
var geo_approx_long = viewer.obj_.Keywords[2].Value;
profile = 'http://sandbox.orkut.com' + profile;
var html = '<img src="' + thumb + '"/>';
html += '<a href="' + profile + '" target="_top">' + name + '</a>' + " lat " + geo_approx_lat + "long " + geo_approx_long;
onefriend = name + '<br><img src="' + thumb + '" alt="'+name+'" title="'+name+'"/>';
var blueIcon = new google.maps.Icon(G_DEFAULT_ICON);
blueIcon.image = "http://gmaps-samples.googlecode.com/svn/trunk/markers/blue/blank.png";
markerOptions = { icon:blueIcon };
var point = new google.maps.LatLng(geo_approx_lat,geo_approx_long);
var marker = new google.maps.Marker(point,markerOptions);
map.addOverlay(createMarker(point,onefriend));
var viewer_friends = data.get("viewer_friends").getData();
viewer_friends.each(function(person) {
var name = person.getDisplayName();
var thumb = person.getField(opensocial.Person.Field.THUMBNAIL_URL);
var profile = person.getField(opensocial.Person.Field.PROFILE_URL);
var geo_approx_lat = person.obj_.Keywords[1].Value;
var geo_approx_long = person.obj_.Keywords[2].Value;
var point = new google.maps.LatLng(geo_approx_lat,geo_approx_long);
var marker = new google.maps.Marker(point);
profile = 'http://sandbox.orkut.com' + profile;
html += '<a href="' + profile + '" target="_top" style="float:left">';
html += '<img src="' + thumb + '"/>';
html += '</a>';
onefriend = name + '<br><img src="' + thumb + '" alt="'+name+'" title="'+name+'"/>';
map.addOverlay(createMarker(point,onefriend));
});
//document.getElementById('message').innerHTML = html;
}
function createMarker(point, msg) {
var marker = new google.maps.Marker(point);
google.maps.Event.addListener(marker,"click", function() {
msg ="<p style='font-size:11px;font-family:Verdana, Sans, Helvetica;'>"+msg+"</p>";
map.openInfoWindowHtml(point, msg);
});
return marker;
}
google.setOnLoadCallback(initialize);
</script>
<div id="map" style="height: 98%; width: 98%;border: solid 1px #000000"></div>
<div id="message"> </div>
]]>
</Content>
</Module>
BlogMarks
del.icio.us
digg
Furl
Newsvine
reddit
Simpy
Slashdot