diff options
author | Andreas Jakum <aj-gh@users.noreply.github.com> | 2017-09-13 11:51:23 +0200 |
---|---|---|
committer | Andreas Jakum <aj-gh@users.noreply.github.com> | 2017-09-13 11:51:23 +0200 |
commit | 062c056eef6acee3e33967efc0095ceeb8b07624 (patch) | |
tree | 865f061bbf89c69db3bec505005d1355247bc413 /map.js | |
parent | e91ac818f38cdfa63febcb904d5417295b4091bc (diff) |
Add basic OSM support and set as default.
Diffstat (limited to 'map.js')
-rw-r--r-- | map.js | 26 |
1 files changed, 24 insertions, 2 deletions
@@ -21,19 +21,41 @@ debug = function (log_txt) { function initialize(lat, lng, res) { debug("Initializing Funkfeuer Graz Map"); + var OSM_Mapnik = 'OSM_Mapnik'; + var copyrightNode = document.createElement('div'); + copyrightNode.id = 'copyright-control'; + copyrightNode.style.fontSize = '11px'; + copyrightNode.style.fontFamily = 'Arial, sans-serif'; + copyrightNode.style.margin = '0 2px 2px 0'; + copyrightNode.style.whitespace = 'nowrap'; + copyrightNode.innerHTML = 'Map data © <a href=\"http://www.openstreetmap.org/\">OpenStreetMap</a> / Google'; + copyrightNode.index = 0; + google.maps.visualRefresh=true; var mapOptions = { center: new google.maps.LatLng(lat, lng), zoom: res, streetViewControl: false, disableDoubleClickZoom: true, - mapTypeId: google.maps.MapTypeId.ROADMAP, + mapTypeId: OSM_Mapnik, mapTypeControlOptions: { mapTypeIds: [google.maps.MapTypeId.ROADMAP, google.maps.MapTypeId.HYBRID, - google.maps.MapTypeId.SATELLITE , google.maps.MapTypeId.TERRAIN ], + google.maps.MapTypeId.SATELLITE , google.maps.MapTypeId.TERRAIN, + OSM_Mapnik ], style: google.maps.MapTypeControlStyle.HORIZONTAL_BAR, } }; map = new google.maps.Map(document.getElementById("map"), mapOptions); + map.mapTypes.set("OSM_Mapnik", new google.maps.ImageMapType({ + getTileUrl: function(coord, zoom) { + return "//tile.openstreetmap.org/" + zoom + "/" + coord.x + "/" + coord.y + ".png"; + }, + tileSize: new google.maps.Size(256, 256), + name: "OpenStreetMap", + maxZoom: 18 + })); + + map.controls[google.maps.ControlPosition.BOTTOM_RIGHT].push(copyrightNode); + //##// map.addControl(new RulerControl()); var reloadconDiv = document.createElement('div'); |