Skip to content

Instantly share code, notes, and snippets.

@Evil2000
Last active April 5, 2022 06:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Evil2000/d2096f24f4cda107f0d347d2b04b55da to your computer and use it in GitHub Desktop.
Save Evil2000/d2096f24f4cda107f0d347d2b04b55da to your computer and use it in GitHub Desktop.
[OSM Maximyzer] Displays the MAP on openstreetmap.de in full page size and hides the annoying layer selector.
// ==UserScript==
// @name OSM Maximyzer
// @namespace osmmaximyzer
// @description Displays the MAP on openstreetmap.de in full page size and hides the annoying layer selector.
// @icon https://www.google.com/s2/favicons?domain=openstreetmap.de
// @include https://www.openstreetmap.de/karte*
// @include https://openstreetmap.de/karte*
// @author Evil.2000
// @version 0.91
// @updateURL https://gist.githubusercontent.com/Evil2000/d2096f24f4cda107f0d347d2b04b55da/raw/osmmaximyzer.user.js?cachebuster=1234
// @downloadURL https://gist.githubusercontent.com/Evil2000/d2096f24f4cda107f0d347d2b04b55da/raw/osmmaximyzer.user.js
// @run-at document-idle
// @grant unsafeWindow
// ==/UserScript==
/**
* This little Tampermonkey script resizes the map on openstreetmap.de to full page size and
* hides the annoying layer selector. It gives the possibility to inital set the coordinates
* and zoom level by specifying it in the loction hash:
* https://www.openstreetmap.de/karte.html#<Zoom>/<Latitute>/<Longitute>
* Example for the center of Germany:
* https://www.openstreetmap.de/karte.html#12/51.164305/10.4541205
*/
var $ = unsafeWindow.jQuery;
var s = `
div.olControlLayerSwitcher {
}
div.olControlPanZoomBar {
margin-top: 20px;
}
#karte_nav {
display: none;
}
#osm_logo_link {
display: none;
}
#Route {
display: none;
}
#editMap {
display: none;
}
#errorMap {
display: none;
}
#slider {
width: 320px;
position: fixed;
top: 40px;
height: 90% !important;
}
#search {
position: fixed;
top: 6px;
z-index: 1;
left: 6px;
/*height: 90%;*/
}
#resultBox {
position: relative;
height: 100%;
margin-left: auto;
}
#map {
bottom: 0;
left: 0;
position: fixed;
right: 0;
top: 0;
}
#copyright {
bottom: 0;
right: 0;
z-index: 1;
position: absolute;
margin-right: 90px;
}`;
$("head link[rel='stylesheet']").last().after('<style type="text/css">'+s+'</style>');
// Set the center of the map to coordinates and zoom level given by the location hash.
var initMoveMap = function() {
var map = unsafeWindow.map
var initZoomLatLong = unsafeWindow.location.hash.substring(1).split('/');
var lon = parseFloat(initZoomLatLong[2]);
var lat = parseFloat(initZoomLatLong[1]);
var zom = parseFloat(initZoomLatLong[0]);
map.setCenter(new unsafeWindow.OpenLayers.LonLat(lon,lat).transform(unsafeWindow.proj4326,unsafeWindow.projmerc),zom);
map.events.register('move', null, function() {
var lonlat = map.getCenter().clone().transform(unsafeWindow.projmerc, unsafeWindow.proj4326);
unsafeWindow.location.hash = '#' + map.getZoom() + '/' + lonlat.lat.toFixed(5) + '/' + lonlat.lon.toFixed(5);
});
}
// Wait until the map is loaded. Then do magic :-).
var t = setInterval(function(){
try {
var ctrls = unsafeWindow.map.controls;
if (ctrls.length == 0) return;
for (let ctrl of ctrls) {
if(ctrl.displayClass == "olControlLayerSwitcher") {
ctrl.minimizeControl();
clearTimeout(t);
unsafeWindow.map.removeLayer(unsafeWindow.groups);
}
}
initMoveMap();
} catch (e) {
return;
}
}, 100);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment