Last active
December 22, 2020 20:51
-
-
Save dervondenbergen/e34bcd1358fb6e6e7b1891c99fccd1aa to your computer and use it in GitHub Desktop.
OpenRailwayMap extra layer from OpenStreetMap.de
This file contains hidden or 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
// ==UserScript== | |
// @name Add OpenStreetMap.de Layer to OpenRailwayMap | |
// @namespace http://tampermonkey.net/ | |
// @version 0.3 | |
// @description try to take over the world! | |
// @author Felix De Montis | |
// @match https://*.openrailwaymap.org/* | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
window.cfc = setInterval(checkForControls, 50); | |
function checkForControls() { | |
var functionDefined = window.hasOwnProperty('setupControls'); | |
console.log('SC', functionDefined) | |
if (functionDefined) { | |
clearInterval(window.cfc); | |
console.log(setupControls); | |
window.setupControls = newSetupControls; | |
console.log(setupControls); | |
} | |
} | |
function newSetupControls() { | |
// grayscale mapnik background layer | |
var mapnikGray = new L.TileLayer.Grayscale('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', | |
{ | |
attribution: _("Map data © OpenStreetMap contributors"), | |
maxZoom: 19 | |
}).addTo(map); | |
// normal mapnik background layer | |
var mapnik = new L.TileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', | |
{ | |
attribution: _("Map data © OpenStreetMap contributors"), | |
maxZoom: 19 | |
}); | |
// blank background map | |
var blank = new L.TileLayer(window.openrailwaymap.root+'/img/blank.png', | |
{ | |
maxZoom: 20 | |
}); | |
var deLayer = new L.TileLayer("https://{s}.tile.openstreetmap.de/{z}/{x}/{y}.png", { | |
maxZoom: 20 | |
}) | |
var deLayerGray = new L.TileLayer.Grayscale("https://{s}.tile.openstreetmap.de/{z}/{x}/{y}.png", { | |
maxZoom: 20 | |
}) | |
var baseLayers = new Object(); | |
baseLayers[_("Mapnik")] = mapnik; | |
baseLayers[_("Mapnik Grayscale")] = mapnikGray; | |
baseLayers[_("No background map")] = blank; | |
baseLayers[_("OSM DE")] = deLayer; | |
baseLayers[_("OSM DE Grayscake")] = deLayerGray; | |
// hillshading layer | |
var hillshading = new L.TileLayer('http://{s}.tiles.wmflabs.org/hillshading/{z}/{x}/{y}.png', | |
{ | |
attribution: _("Hillshading by <a href='https://www.nasa.gov/'>NASA SRTM</a>"), | |
maxZoom: 17 | |
}); | |
var overlays = new Object(); | |
overlays[_("Hillshading")] = hillshading; | |
overlays[_("OpenRailwayMap")] = railmap; | |
new L.Control.Scale({metric:true, maxWidth:200}).addTo(map); | |
new L.Control.Layers(baseLayers, overlays).addTo(map); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment