Created
January 5, 2011 15:53
-
-
Save EHER/766486 to your computer and use it in GitHub Desktop.
Exibe no mapa o último checkin feito no Apontador
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
<div id="map_canvas" style="width:710px; height:450px"></div> | |
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script> | |
<script type="text/javascript"> | |
if(location.host == 'eher.com.br') { | |
consumerKey = "ImpfX7kZ3mPaMHnhOKzY-f-QbFyv0zvoOuJA1sSE_I8~"; | |
} else { | |
consumerKey = "ImpfX7kZ3mPaMHnhOKzY-QCkBr08iSRfew61TRDxJeo~"; | |
} | |
$j.getJSON("https://api.apontador.com.br/v1/users/8972911185/visits?callback=?", { | |
jsconsumerkey : consumerKey, | |
type : "jsonp" | |
}, function(data) { | |
if(data.visits.length>0) { | |
var lastVisit = data.visits[0].visit; | |
var centerLatLng = new google.maps.LatLng(lastVisit.place.point.lat, lastVisit.place.point.lng); | |
var myOptions = { | |
zoom: 16, | |
center: centerLatLng, | |
mapTypeId: google.maps.MapTypeId.ROADMAP | |
}; | |
var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); | |
var marker = new google.maps.Marker({ | |
map: map, | |
position: centerLatLng | |
}); | |
var linkChegamos = "http://chegamos.com/places/show/"+lastVisit.place.id; | |
var visitInfo = new google.maps.InfoWindow({ | |
map: map, | |
position: marker.getPosition(), | |
content: '<strong>'+lastVisit.place.name+'</strong><br/>'+ | |
'<a href="'+linkChegamos+'" target="_blank">Ver no Chegamos!</a>' | |
}); | |
visitInfo.open(map, marker); | |
} else { | |
console.log("Apontador não respondeu"); | |
} | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment