Skip to content

Instantly share code, notes, and snippets.

@teemow
Created August 21, 2012 10:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save teemow/3414259 to your computer and use it in GitHub Desktop.
Save teemow/3414259 to your computer and use it in GitHub Desktop.
Google Maps Fusion Tables
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<style>
html, body, #map_canvas {
margin: 0;
padding: 0;
height: 100%;
}
</style>
<script src="https://maps.googleapis.com/maps/api/js?sensor=false"></script>
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script>
var map;
function initialize() {
var geocoder = new google.maps.Geocoder();
geocoder.geocode( {'address' : "germany"}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
var mapOptions = {
zoom: 7,
center: results[0].geometry.location,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById('map_canvas'), mapOptions);
selectProvince();
google.maps.event.addListener(map, 'click', function(event) {
selectProvince();
});
}
});
}
var layer = new google.maps.FusionTablesLayer({
styles: [{
polygonOptions: {
strokeWeight: "5",
strokeColor: "#FF0000",
fillOpacity: "0.0",
fillColor: "#000000"
}
}]
});
var provinces = [ 1623, 1624, 1625, 1626, 1627, 1628, 1629, 1630, 1631, 1632, 1642, 1650, 1651, 1652, 3540, 3541 ];
function selectProvince() {
var tableid=576292;
var rand = Math.floor(Math.random() * (provinces.length - 1));
layer.setMap(null);
layer.setQuery({select: "kml_4326",
from: tableid,
where: "objectid = '" + provinces[rand] + "'",
});
// queryTable();
layer.setMap(map);
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body>
<div id="map_canvas"></div>
<script>
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment