Created
June 22, 2012 23:13
-
-
Save YenTheFirst/2975721 to your computer and use it in GitHub Desktop.
map tile number overlay
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//this is a very very minor modification of http://www.maptiler.org/google-maps-coordinates-tile-bounds-projection/ , to use google maps api v3. | |
//if you run this javascript on a page, or include it, you'll get nice tile number overlays. | |
function TileToQuadKey ( x, y, zoom){ | |
var quad = ""; | |
for (var i = zoom; i > 0; i--){ | |
var mask = 1 << (i - 1); | |
var cell = 0; | |
if ((x & mask) != 0) | |
cell++; | |
if ((y & mask) != 0) | |
cell += 2; | |
quad += cell; | |
} | |
return quad; | |
} | |
var tilelayer= new google.maps.ImageMapType({ | |
getTileUrl: function(tile, zoom) { | |
var imageurl3 = "http://chart.apis.google.com/chart?chst=d_text_outline&chs=256x256&chf=bg,s,00000055&chld=FFFFFF|16|h|000000|b|"; | |
var imageurl4 = "http://chart.apis.google.com/chart?chst=d_text_outline&chs=256x256&chf=bg,s,ffffff00&chld=FFFFFF|16|h|000000|b|"; | |
var tilegoogle = " (" + tile.x + "," + tile.y +")"; | |
var tiletms = " (" + tile.x + "," + ((1 << zoom) - tile.y - 1) + ")"; | |
var tilequadtree = " " +TileToQuadKey( tile.x, tile.y, zoom); | |
if ((tile.x % 2 && !(tile.y % 2)) || (!(tile.x % 2) && tile.y % 2)) { | |
imageurl = imageurl3; | |
} else { | |
imageurl = imageurl4; | |
} | |
return imageurl + "|||Google: "+tilegoogle+"|TMS: "+tiletms+"|QuadTree: "+tilequadtree + "|Zoom "+zoom+"||||||____________________________"; | |
}, | |
tileSize: new google.maps.Size(256, 256) | |
}); | |
//YOU HAVE TO EDIT THIS PART. | |
//your_reference_to_the_map.overlayMapTypes.insertAt(0,tilelayer); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment