105 lines
3.1 KiB
HTML
105 lines
3.1 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
|
|
<style type="text/css">
|
|
html { height: 100% }
|
|
body { height: 100%; margin: 0px; padding: 0px ; background-color: #000; }
|
|
#mcmap { height: 100% }
|
|
</style>
|
|
<script type="text/javascript"
|
|
src="http://maps.google.com/maps/api/js?sensor=false">
|
|
</script>
|
|
<script type="text/javascript">
|
|
var config = {
|
|
path: 'tiles',
|
|
fileExt: 'png',
|
|
tileSize: 384,
|
|
defaultZoom: 1,
|
|
maxZoom: {maxzoom},
|
|
cacheMinutes: 0, // Change this to have browsers automatically requiest new images every x minutes
|
|
debug: false
|
|
};
|
|
|
|
var MCMapOptions = {
|
|
getTileUrl: function(tile, zoom) {
|
|
var url = config.path;
|
|
if(tile.x < 0 || tile.x >= Math.pow(2, zoom) || tile.y < 0 || tile.y >= Math.pow(2, zoom)) {
|
|
url += '/blank';
|
|
} else if(zoom == 0) {
|
|
url += '/base';
|
|
} else {
|
|
for(var z = zoom - 1; z >= 0; --z) {
|
|
var x = Math.floor(tile.x / Math.pow(2, z)) % 2;
|
|
var y = Math.floor(tile.y / Math.pow(2, z)) % 2;
|
|
url += '/' + (x + 2 * y);
|
|
}
|
|
}
|
|
url = url + '.' + config.fileExt;
|
|
if(config.cacheMinutes > 0) {
|
|
var d = new Date();
|
|
url += '?c=' + Math.floor(d.getTime() / (1000 * 60 * config.cacheMinutes));
|
|
}
|
|
return(url);
|
|
},
|
|
tileSize: new google.maps.Size(config.tileSize, config.tileSize),
|
|
maxZoom: config.maxZoom,
|
|
minZoom: 0,
|
|
isPng: !(config.fileExt.match(/^png$/i) == null)
|
|
};
|
|
|
|
var MCMapType = new google.maps.ImageMapType(MCMapOptions);
|
|
MCMapType.name = "MC Map";
|
|
MCMapType.alt = "Minecraft Map";
|
|
|
|
function CoordMapType() {
|
|
}
|
|
|
|
function CoordMapType(tileSize) {
|
|
this.tileSize = tileSize;
|
|
}
|
|
|
|
CoordMapType.prototype.getTile = function(coord, zoom, ownerDocument) {
|
|
var div = ownerDocument.createElement('DIV');
|
|
div.innerHTML = "(" + coord.x + ", " + coord.y + ", " + zoom + ")";
|
|
div.innerHTML += "<br />";
|
|
div.innerHTML += MCMapOptions.getTileUrl(coord, zoom);
|
|
div.style.width = this.tileSize.width + 'px';
|
|
div.style.height = this.tileSize.height + 'px';
|
|
div.style.fontSize = '10';
|
|
div.style.borderStyle = 'solid';
|
|
div.style.borderWidth = '1px';
|
|
div.style.borderColor = '#AAAAAA';
|
|
return div;
|
|
};
|
|
|
|
var map;
|
|
|
|
function initialize() {
|
|
var mapOptions = {
|
|
zoom: config.defaultZoom,
|
|
center: new google.maps.LatLng(-45, 90),
|
|
navigationControl: true,
|
|
scaleControl: false,
|
|
mapTypeControl: false,
|
|
mapTypeId: 'mcmap'
|
|
};
|
|
map = new google.maps.Map(document.getElementById("mcmap"), mapOptions);
|
|
|
|
if(config.debug) {
|
|
map.overlayMapTypes.insertAt(0, new CoordMapType(new google.maps.Size(config.tileSize, config.tileSize)));
|
|
}
|
|
|
|
// Now attach the coordinate map type to the map's registry
|
|
map.mapTypes.set('mcmap', MCMapType);
|
|
|
|
// We can now set the map to use the 'coordinate' map type
|
|
map.setMapTypeId('mcmap');
|
|
}
|
|
</script>
|
|
</head>
|
|
<body onload="initialize()">
|
|
<div id="mcmap" style="width:100%; height:100%"></div>
|
|
</body>
|
|
</html>
|