Skip to content

Instantly share code, notes, and snippets.

@stefanw
Created May 4, 2011 08:21
Show Gist options
  • Save stefanw/954922 to your computer and use it in GitHub Desktop.
Save stefanw/954922 to your computer and use it in GitHub Desktop.
var getOSMMapType = function(){
return new google.maps.ImageMapType({
getTileUrl: function(coord, zoom) {
return 'http://tile.openstreetmap.org/'+ zoom +'/'+ coord.x +'/' + coord.y +'.png';
},
tileSize: new google.maps.Size(256, 256),
isPng: true,
maxZoom: 18,
name: "OSM"
});
};
var mapTypes = {"OSM": getOSMMapType()};
var mapOptions = {
"zoom": 13
, "center": new google.maps.LatLng(someLat, someLng)
, "mapTypeId": "OSM"
, "mapTypeControlOptions": {
"mapTypeIds": mapTypes
}
};
var map = new google.maps.Map(document.getElementById(someMapID), mapOptions);
map.mapTypes.set("OSM", mapTypes["OSM"]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment