Skip to content
Geo Hashing Chat by Proximity to connect two or more users to a group chat.
JavaScript
Branch: gh-pages
Clone or download
Latest commit 0ac21c0 Apr 5, 2014
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
README.md Update README.md Apr 4, 2014
chat.mp3
chat.ogg added initial geo hash chatting UI. Apr 3, 2014
chat.wav added initial geo hash chatting UI. Apr 3, 2014
index.html typo. Apr 4, 2014
sound.js added initial geo hash chatting UI. Apr 3, 2014

README.md

Geohashing Chat by Proximity

Try it now: Geohash Chat by Proximity

To connect groups of two or more people by location, you will take lat/long values and reduce the resolution of accuracy, and by doing this you can expand the coverage of proximity. You can use multiple resolutions at once or a fixed resolution.

Get Source Code: GitHub Repository for Geo Chat by Proximity

Geohashing Chat Conversations based on Proximity Zoom Level

Basics of Geo Hashing

Next we'll cover some source code snippet for geo hashing lat/long coords. It is fairly simple to increase the radius of lat/long position by reducing the accuracy of the float values. Using this you can expand the circle and collect a Lat/Long.

// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// Geo Hash
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
function geohash( coord, resolution ) {
    var rez = Math.pow( 10, resolution || 0 );
    return Math.floor(coord * rez) / rez;
}

Acquire Lat Long Chat Proximity Location

Geo Hashing Resolution "Zoom"

"Zoom" levels, basically several different cartesian grids with larger and smaller granularity. Once a Geofencing event fires, you will publish to a set of channels corresponding with each zoom level. Zoom levels are important as that is how we actually construct the link between Geofencing and PubNub. Zoom level is the resolution/de-resolution of the Cartesian coordinates Lat/Long (think X,Y coord). By reducing the resolution of the lat/long coord we can construct a channel name that hits 1 box of the grid. Less resolution means larger the boxes and is required to determine a PubNub Channel that is associated.

// Create Proximity Channel
channel = geohash( pos.latitude, 0 ) + '' + geohash( pos.longitude, 0 );

This will create a very wide circle and generate a channel name used to connect. Next connect to PubNub with this channel name.

// Connect to Proximity Channel
pubnub.subscribe({
     channel : channel,
     message : receive,
     connect : ready,
    presence : presence
});

Acquired Latitude Longitude Chat Proximity Group

Multiplexing 9 Boxes

You will calculate the surrounding squares to extend the taper and radius in a way that provides more accuracy. This will remove the "fencing" effect.

Geo Hashing with PubNub Conclusion

That's it! You simply reduce the resolution of a geo coordinate and use that as a channel name on PubNub. Also check out the browser's navigator.geolocation.getCurrentPosition(...) method to acquire lat/long in a chrome/firefox/ie/opera/mobile/safari browser.

Also checkout the PubNub Connected Car Solution Kit

Geohashing Chat Conversations based on Proximity Nearby

You can’t perform that action at this time.