Skip to content

Instantly share code, notes, and snippets.

@stephenlb
Forked from ToeJamson/1.js
Created May 7, 2014 23:26
Show Gist options
  • Save stephenlb/74772411af575275dbb7 to your computer and use it in GitHub Desktop.
Save stephenlb/74772411af575275dbb7 to your computer and use it in GitHub Desktop.
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// Geo Hash
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
function geohash( coord, resolution ) {
var rez = Math.pow( 10, resolution || 0 );
return Math.floor(coord * rez) / rez;
}
// Create Proximity Channel
channel = geohash( pos.latitude, 0 ) + '' + geohash( pos.longitude, 0 );
// Connect to Proximity Channel
pubnub.subscribe({
channel : channel,
message : receive,
connect : ready,
presence : presence
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment