Skip to content

Instantly share code, notes, and snippets.

@codepo8
Created August 1, 2010 09:37
Show Gist options
  • Save codepo8/503172 to your computer and use it in GitHub Desktop.
Save codepo8/503172 to your computer and use it in GitHub Desktop.
default xml namespace = "http://where.yahooapis.com/v1/schema.rng";
var res = y.query("select * from geo.places(1) where text='"+
place + "'").results;
var lat = res.place.centroid.latitude;
var lon = res.place.centroid.longitude;
lat = Math.round(parseInt(lat)/5)*5;
lon = Math.round(parseInt(lon)/5)*5;
if(lat === +lat){
var src='http://earthquake.usgs.gov/images/globes/'+
lat+'_'+lon+'.jpg';
var loc = '';
if(location === 'true'){
var loc = <ul class="location">
<li>Name: {res..name.text()}</li>
<li>Placetype: {res..placeTypeName.text()}</li>
<li>Country: {res..country.text()}</li>
<li>Latitude: {res..centroid.latitude.text()}</li>
<li>Longitude: {res..centroid.longitude.text()}</li>
<li>WOEID: {res..woeid.text()}</li>
</ul>;
}
default xml namespace = "";
if(type === 'data'){
var data = y.query('select * from data.uri where url="'+
src+'"').results;
var datauri = data..url;
var dataimg = <img/>;
dataimg.@src = data..url;
dataimg.@alt = place;
}
var img = <img/>;
img.@src = src;
img.@alt = place;
var out = (type === 'data') ? dataimg : img;
response.object = <div class="globe">{out}{loc}</div>;
} else {
response.object = <error>
No location found for {place}, sorry.
</error>;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment