-
Notifications
You must be signed in to change notification settings - Fork 0
/
tile.html
76 lines (62 loc) · 2.05 KB
/
tile.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<html>
<head>
<title>Tile Test</title>
<script type="text/javascript">
function draw2()
{
var ctx = document.getElementById('tutorial').getContext('2d');
var img = new Image();
var zoomLevel = 16;
var addr = "http://b.tile.stamen.com/watercolor/" + zoomLevel.toString() + "/";
var origX = 16810;
var origY = 24347;
var x = origX;
var y = origY;
var imgArray = [];
var xTiles = 10;
var yTiles = 10;
//Fill image array with tiles.
for(i = 0; i < xTiles; i++)
{
//fill each row (y).
for(y = origY; y < origY+yTiles; y++)
{
//base url/x/y.jpg
imgArray.push(addr + x.toString() + "/" + y.toString() + ".jpg");
}
x++; //increment to next column (x).
}
ctx.height = 256*yTiles;
ctx.width = 256*xTiles;
//Draw all tiles.
imgArrayIndex = 0;
for (i = 0; i < xTiles; i++)
{
for (j = 0; j < yTiles; j++)
{
img = new Image();
img.src = imgArray[imgArrayIndex++];
img.onload = (function(img, i, j){ //temporary closure to store loop
return function () { //variables reference
ctx.drawImage(img,i*256,j*256,256,256);
}
})(img, i, j);
}
}
}
</script>
<style type="text/css">
canvas { border: 1px solid black; }
</style>
</head>
<form id="search">
<p>
(This shit don't work right now. Chill.)
<input id="search-location" class="span3" type="text" placeholder="Type a location">
<input id="search-submit" class="btn" type="submit" value="Find">
</p>
</form>
<body onload="draw2();">
<canvas id="tutorial" width="2560" height="2560"></canvas>
</body>
</html>