From 062c056eef6acee3e33967efc0095ceeb8b07624 Mon Sep 17 00:00:00 2001 From: Andreas Jakum Date: Wed, 13 Sep 2017 11:51:23 +0200 Subject: Add basic OSM support and set as default. --- map.js | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/map.js b/map.js index 7db6e43..5b36da7 100644 --- a/map.js +++ b/map.js @@ -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 © OpenStreetMap / 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'); -- cgit v1.2.1