Created
February 8, 2012 16:02
-
-
Save bialikover/1770724 to your computer and use it in GitHub Desktop.
con mapa
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>Siempre es jueves</title> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> | |
<script type="text/javascript" | |
src="http://maps.googleapis.com/maps/api/js?key=AIzaSyB6Ci719_dZPKFs8mAHCQSwUyUfLWuQItI&sensor=true"> | |
</script> | |
<style> #map_canvas{ margin-top: 5%; height:70%; width:100%; }</style> | |
</head> | |
<body onload="initialize()"> | |
<div id="fb-root"></div> | |
<script> | |
var time = new Date(); | |
window.fbAsyncInit = function() { | |
FB.init({ | |
appId : '107677519315273', | |
status : true, | |
cookie : true, | |
xfbml : true, | |
oauth : true, | |
}); | |
FB.login(function(response) { | |
if (response.authResponse) { | |
console.log('Welcome! Fetching your information.... '); | |
FB.api('/me', function(user) { | |
if (user) { | |
var image = document.getElementById('image'); | |
image.src = 'http://graph.facebook.com/' + user.id + '/picture'; | |
var name = document.getElementById('name'); | |
name.innerHTML = user.name | |
} | |
}); | |
//este snippet trae los eventos de mis amigos benchmark: LIMIT 150 =>5.46s AND rsvp_status="attending" q1 | |
FB.api("/fql",{q: | |
{'query0':'SELECT uid2 from friend WHERE uid1 = me() LIMIT 50', | |
'query1':'SELECT eid from event_member WHERE uid IN (SELECT uid2 FROM #query0)', | |
'query2':'SELECT eid, name, description, location, venue, start_time, end_time FROM event WHERE eid IN (SELECT eid FROM #query1)' | |
}}, | |
function(response){ | |
var events= response.data[2].fql_result_set; | |
for (var i = 0; events.length > i ; i++){ | |
tstart = new Date(events[i].start_time * 1000); | |
tend = new Date(events[i].end_time * 1000); | |
if(time.toDateString() == tstart.toDateString()){ | |
if(events[i].venue.latitude != null){ | |
$("div#events").append("<p> id: "+events[i].eid+ | |
" evento: "+events[i].name+ | |
" latitud: "+events[i].venue.latitude+ | |
" longitud: "+events[i].venue.longitude+ | |
" empieza: "+tstart.toDateString()+ | |
" termina: "+tend.toDateString()+"</p>"); | |
} | |
} | |
else {console.log("no se encontraron eventos para hoy");} | |
} | |
} | |
); | |
} else { | |
console.log('User cancelled login or did not fully authorize.'); | |
} | |
}, {scope: 'email'} | |
); | |
}; | |
(function(d){ | |
var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;} | |
js = d.createElement('script'); js.id = id; js.async = true; | |
js.src = "//connect.facebook.net/en_US/all.js"; | |
d.getElementsByTagName('head')[0].appendChild(js); | |
}(document)); | |
position = navigator.geolocation.getCurrentPosition(success, error); | |
var lat; | |
var lon; | |
function success(position){ | |
lat = position.coords.latitude; | |
lon = position.coords.longitude; | |
} | |
function error(){ | |
alert("no pudimos encontrar tu posicion :( intentalo intentalo!"); | |
} | |
function initialize() { | |
var myLatlng; | |
if(lat!=null && lon!=null){ | |
myLatlng = new google.maps.LatLng(lat,lon); | |
} | |
else{ | |
myLatlng = new google.maps.LatLng(19.318919320531563,-99.12139892578125); | |
} | |
var myOptions = { | |
zoom: 13, | |
center: myLatlng, | |
mapTypeId: google.maps.MapTypeId.ROADMAP | |
} | |
var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); | |
var marker = new google.maps.Marker({ | |
position: myLatlng, | |
title:"Tu estas aqui!" | |
}); | |
marker.setMap(map); | |
} | |
</script> | |
<div align="center"> | |
<img id="image"/> | |
<div id="name"></div> | |
<div id="events"></div> | |
<div id= "map_canvas"></div> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment