Skip to content


Subversion checkout URL

You can clone with
Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

130 lines (106 sloc) 6.322 kB
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4+01//EN" "http://www+w3+org/TR/html4/strict+dtd">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>YQL Geo Library - get all your geo needs in JavaScript - geolocation, reverse geocoding, content analysis</title>
<link rel="stylesheet" type="text/css" href="">
<style type="text/css" media="screen">
#doc{background:#fff;border:1em solid #fff;}
pre{border:1px solid #999;background:#eee;padding:.5em;clear:both;margin:1em 0;}
h1{margin:0 0 .5em 0;}
#ft p{color:#ccc;margin:2em 0;text-align:right;font-size:80%;}
#ft p a{color:#999;}
<body class="yui-skin-sam">
<div id="doc" class="yui-t7">
<div id="hd" role="banner">
<h1>YQL Geo Library - get all your geo needs in JavaScript - geolocation, reverse geocoding, content analysis</h1>
<div id="bd" role="main">
<p>As an aid for the Georgia Tech Hack 2010 and as a follow-up <a href="">to my talk about geolocation</a> here is a simple JavaScript library that answers most of your geo questions. It wraps the following services in a simple interface:</p>
<li><a href="">Yahoo Placemaker</a></li>
<li><a href="">Yahoo GeoPlanet</a></li>
<li><a href=""></a></li>
<li><a href="">IP location tools</a></li>
<li><a href="">W3C Geo location</a></li>
<li><a href="">Flickr.places.findByLatLon</a></li>
<p>To use the geo library, simply include it in your document. There is one simple method to use which is:</p>
<dd>is the thing you want to analyse - this could be the URL to a web document, a text, an IP, a pair of latitude and longitude information or "visitor" to detect the geographic location of the current visitor.</dd>
<dd>is the callback method that will be called when there was a succesful retrieval of information. The data comes back as an object - if there was an error retrieving the information the data will be wrapped in an <code>error</code> property.</dd>
<p>Check out the different use cases of the library below:</p>
<h2>Getting the geographical location from a text</h2>
<p>You can send an arbitrary text to the <code>get()</code> method to find the geographical information in it:</p>
alert(' ('+','+
<button onclick="yqlgeo.get('paris,fr',function(o){alert(' ('','')');})">Try this out</button>
<h2>Getting the location information from lat/lon</h2>
<p>You can get all kind of data from a latitude and longitude pair. You can either send them in as two parameters or as an array:</p>
alert( + ',' +;
<button onclick="yqlgeo.get(33.748,-84.393,function(o){alert( + ',' +;})">Try this out</button>
alert( + ',' +;
<button onclick="yqlgeo.get([33.748,-84.393],function(o){alert( + ',' +;})">Try this out</button>
<h2>Get all the geo locations from a certain URL</h2>
<p>You can scrape a certain document at a URL for geographical locations:</p>
var out = '';
var all =;
for(var i=0;i&lt;all;i++){[i].name+'\n';
<button onclick="yqlgeo.get('',function(o){var out='';var all;for(var i=0;i<all;i++){[i].name+'\n'};alert(out)}); ">Try this out</button>
<h2>Get the place from an IP number</h2>
alert( + ',' + +
' (' + + ',' + + ')'
<button onclick="yqlgeo.get('',function(o){alert( + ',' + ' ('','')')});">Try this out</button>
<h2>Find the user (using the W3C geolocation API and IP as a fallback)</h2>
alert('No location found for user :('); // some IPs are not in the DB :(
} else {
alert( + ',' + +
' (' + + ',' + + ')'
<button onclick="yqlgeo.get('visitor',function(o){if(o.error){alert('No location found for user :(');} else {alert( + ',' + + ' (' + + ',' + ')');}});">Try this out</button>
<h2>Download the library</h2>
<p>You can get the library directly <a href="yqlgeo.js">from here by saving this link</a> or by <a href="">getting the source code from GitHub</a>.</p>
<div id="ft" role="contentinfo">
<p>Written by <a href="">Chris Heilmann</a> using <a href="">YQL</a>.</p>
<script src="yqlgeo.js"></script>
Jump to Line
Something went wrong with that request. Please try again.