Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Google maps for launchpad group users
<!DOCTYPE html>
copyright (c) 2011 Google inc.
You are free to copy and use this sample.
License can be found here:
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<title>Ubuntu Members in the World</title>
<!-- Style -->
<style type="text/css">
body { height: 100%; margin: 0px; padding: 10px; }
#map_canvas { height: 600px; width: 800px; margin:0 auto; }
<!-- Google Maps API javascript -->
<script type="text/javascript" src=""></script>
<!-- Import the visualization javascript -->
<script type="text/javascript" src=""></script>
<!-- Initialize visualization -->
<script type="text/javascript">
google.load('visualization', '1', {});
<script type="text/javascript">
var map;
var geocoder;
var lastWindow;
/* INITIALIZE - initialize the map and geocoder */
function initialize() {
geocoder = new google.maps.Geocoder();
map = new google.maps.Map(document.getElementById('map_canvas'), {
center: new google.maps.LatLng(25, 15), //the center lat and long
zoom: 2, //zoom
disableDefaultUI: true, // remove the default items
mapTypeId: google.maps.MapTypeId.ROADMAP //the map style
//make gviz request
/* GVIZ - get data from Fusion Tables */
function setData() {
//create a viz query to send to Fusion Tables
var query = new google.visualization.Query('' + encodeURIComponent("SELECT Member, Latitude, Longitude FROM 1zq9pJyRjZB1FqOcqDhd8lKgCFov6VEDdag4tigQ"));
//set the callback function that will be called when the query returns
//define callback function, this is called when the results are returned
function getData(response) {
//for more information on the response object, see the documentation
numRows = response.getDataTable().getNumberOfRows();
numCols = response.getDataTable().getNumberOfColumns();
//create an array of row values
for (i = 0; i < numRows; i++) {
var row = [];
for (j = 0; j < numCols; j++) {
row.push(response.getDataTable().getValue(i, j));
/* GEOCODING - geocode data in Fusion Tables, if the data is a String Address */
//geocode the address, and create a new marker and InfoWindow at the geocoded location
function addMark(row) {
var coordinate = new google.maps.LatLng(row[1], row[2])
//create the marker
var marker = new google.maps.Marker({
map: map,
position: coordinate,
//this is where the magic happens!
icon: new google.maps.MarkerImage("")
//add a click listener to the marker to open an InfoWindow,
setTimeout(function () { google.maps.event.addListener(marker, 'click', function(event) {
if(lastWindow) lastWindow.close(); //close the last window if it exists
lastWindow = new google.maps.InfoWindow( {
position: coordinate,
content: row[0] //this is the row data, you can use HTML here for the content
});}, 150000);
<body onload="initialize()">
<div id="map_canvas"></div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment