PageSourceSearch

https://www.dithmarschen.de/typo3conf/ext/nws_template/Resources/Public/Javascripts/override.leaflet.js

js dithmarschen.de collected 2026-10-02 14:33:58 UTC 1,663 bytes, 60 lines download raw bytes

1/**
2 * +++++++++++++++++++++++++++++++++++++++++++
3 * ++ !! VERY HACKY, USE WITH CAUTION!!
4 * ++
5 * ++ Prevents all leaflet maps from using tile.openstreetmap.org
6 * ++ Switch to own tiles.nwsnet.eu instead.
7 * +++++++++++++++++++++++++++++++++++++++++++
8 */
9var initOverrideOsmTilesWithOwn = function () {
10	'use strict';
11	function overrideLayer(layer) {
12		if (layer._url.includes('tile.openstreetmap.org')) {
13			layer.setUrl('https://{s}.tiles.nwsnet.eu/{z}/{x}/{y}.png');
14		}
15	}
16
17	function overrideLeafletLoading(){
18		var userAcceptedLeafletUsage = localStorage.getItem('userAcceptedLeafletUsage');
19		if ('true' === userAcceptedLeafletUsage) {
20			return;
21		}
22
23		// Rapidly wait for Leaflet JS to be loaded
24		if (typeof L === 'undefined' || typeof L.map === 'undefined') {
25			setTimeout(() => overrideLeafletLoading(), 0);
26			return;
27		}
28
29		// Change layers added after map initialization
30		L.Layer.prototype.addTo = function (a) {
31			if(typeof this.setUrl !== 'undefined') {
32				overrideLayer(this);
33			} else if (typeof this.getLayers !== 'undefined') {
34				var layers = this.getLayers();
35				for(var layer of layers) {
36					overrideLayer(layer);
37				}
38			}
39			// original addTo functions content:
40			return a.addLayer(this), this;
41		};
42
43		// Change all layers before initializing a map
44		var originalMap = L.map;
45		L.map = function (a,b) {
46			if (b.layers) {
47				for(var layer of b.layers) {
48					overrideLayer(layer);
49				}
50			}
51			return originalMap(a,b);
52		};
53	}
54	overrideLeafletLoading();
55	window.userAcceptedLeafletUsage = function() {
56		localStorage.setItem('userAcceptedLeafletUsage', 'true');
57		location.reload();
58	};
59};
60initOverrideOsmTilesWithOwn();

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.