Monday, March 8, 2010

Meetups Coming To Town - A Mashup of Meetup, Google Gears, & Google Map APIs is one of the social network site that facilitates offline group meetings in various locations around the world. I have been attending some of the groups' meetups since 2009 and found they were very helpful, most important of all - all the meetups I went to were FREE!

The API is very easy to use and everybody received one API key when registering with the site. I decided to utilize the API by integrating it with Google Gears and Map APIs to come out a mashup for people can easy to find out what meetups happening in his(her) own town.

To automatically find out the locations that users are in, the Google Gears API is used to retrieve Geolocation. Users will need to install Google Gears to use the feature, otherwise, they have to manually keyin the location information.

The very first time you run the mashup it will ask your authorization -


A PHP file is running at back-end to communicate with Meetup API and the main program - mymu.html, I need to modifiy the header of the json output from Meetup in order for Dojo to accept it as a datastore to feed the spreadsheet displayed on top.

$state = urlencode($_GET["state"]);
$city = urlencode($_GET["city"]);

if (isset($_GET["page"]))
$page = $_GET["page"];
$page = "50";

if (isset($_GET["topic"]))
$topic = $_GET["topic"];

if (! isset($_GET["type"]))

switch($type) {
 case "0":
 case "1":
  $curl = curl_init();
  $req = "" . $state .  "&city=" . $city . "&key=YourMeetupApiKey";
  if ($topic != "") {
  $req .= "&topic=" . $topic;
  if ($page != "") {
  $req .= "&page=" . $page;
  curl_setopt($curl, CURLOPT_URL, $req );
  curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
  $result = curl_exec($curl);

  $result=str_replace("\"results\":", "identifier:\"id\", items:", $result);
  echo $result;
You can test the program by going to and see the detail javaScript and HTML codes from there. Beside the "State" and "City" filters, a optional "Topic" field is also available for you the limit the results. A Dojo speradsheet on upper page will show all the future meetups coming to your city, and a Google Map on the lower page will display where they will be held. Click at the row of the spreadsheet or the Google map marker, a more detail window will pop-out.
The main JavaScript function - init() will try to find the user geolocation first, then retrieve data from Meetup API and populate the information on Dojo spreadsheet and a Google Map.(init2)
function init() {
  if (! || !google.gears) {
    alert('Gears is not installed, please get it at ');
  function successCallback(p) {
 if ( == "United States") {
  function errorCallback(err) {
    var msg = 'Error retrieving your location: ' + err.message;
  try {
    var geolocation = google.gears.factory.create('beta.geolocation');
                                   { enableHighAccuracy: true,
                                     gearsRequestAddress: true });
  } catch (e) {
    alert('Error using Geolocation API: ' + e.message);

function init2() {
  gridView();  //create spreadsheet
 loadMap(dijit.byId('city').value + ", " + dijit.byId('state').value); // load the city map
 drawMap(store); // draw the markers

No comments:

Post a Comment