Skip to content

Instantly share code, notes, and snippets.

@tzmartin
Created July 18, 2012 22:51
Show Gist options
  • Save tzmartin/3139501 to your computer and use it in GitHub Desktop.
Save tzmartin/3139501 to your computer and use it in GitHub Desktop.
Roll your own reverse/forward geolocator in Titanium
/* Roll your own reverse/forward geolocator
*
* YQL
*/
Titanium.Yahoo.yql('select * from yahoo.maps.findLocation where q="'+latitude+','+longitude+'" and gflags="R"',function(e) {
var woeid = e.data.ResultSet.Results.woeid;
Titanium.API.info(woeid);
});
/*
* Google Maps API
*/
function geocode(lat,lng){
var urlLatLng="http://maps.google.com/maps/api/geocode/json?latlng="+lat+","+lng+"&sensor=true";
//var urlAddress = "http://maps.google.com/maps/api/geocode/json?address=90210&sensor=true";
xhr = Titanium.Network.createHTTPClient();
xhr.open('GET',urlLatLng);
xhr.onload = function(){
var json = this.responseText;
var items = eval('(' + json + ')');
Ti.API.info('>ADDR found:'+ items.results[0].formatted_address);
adrlabel.text=items.results[0].formatted_address;
}
xhr.send();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment