Skip to content

Instantly share code, notes, and snippets.

@varunpant
Created September 21, 2015 12:46
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 varunpant/aad7e87ea1c8af8a673a to your computer and use it in GitHub Desktop.
Save varunpant/aad7e87ea1c8af8a673a to your computer and use it in GitHub Desktop.
Google Maps ,custom raster overlay example with Tilestache
<!DOCTYPE html>
<html>
<head>
<title>Overlay map types</title>
<style>
html, body, #map-canvas {
height: 100%;
margin: 0px;
padding: 0px
}
</style>
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp"></script>
<script>
function CustomOverlay(tileSize) {
this.tileSize = tileSize;
}
CustomOverlay.prototype.getTile = function(coord, zoom, ownerDocument) {
var img = ownerDocument.createElement('img');
img.src = "http://localhost:8080/NE/" + zoom + "/" + coord.x + "/" + coord.y + ".png";
img.style.width = this.tileSize.width + 'px';
img.style.height = this.tileSize.height + 'px';
return img;
};
var map;
function initialize() {
map = new google.maps.Map(
document.getElementById("map-canvas"), {
center: new google.maps.LatLng(42.660851192127, -96.5624457296875),
zoom: 4
});
map.overlayMapTypes.insertAt(0, new CustomOverlay(new google.maps.Size(256, 256)));
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body>
<div id="map-canvas"></div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment