Created
April 19, 2013 04:07
-
-
Save tkrajina/5418085 to your computer and use it in GitHub Desktop.
OpenStreetMap images layer on Google Map
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
map.mapTypes.set("OSM", new google.maps.ImageMapType({ | |
getTileUrl: function(coord, zoom) { | |
var imagesPerUnit = Math.pow(2, zoom); | |
// Stitch horizontaly: | |
var x = coord.x < 0 ? imagesPerUnit + (coord.x % imagesPerUnit) : coord.x; | |
var x = x >= imagesPerUnit ? 0 : x; | |
// Do not stitch verticaly, if overflow -- don't show: | |
if(coord.y < 0 || coord.y >= imagesPerUnit) | |
return null; | |
return "http://tile.openstreetmap.org/" + zoom + "/" + x + "/" + coord.y + ".png"; | |
}, | |
tileSize: new google.maps.Size(256, 256), | |
name: "OSM", | |
maxZoom: 18 | |
})); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment