Zum Inhalt springen

MediaWiki:Kartographer.js: Unterschied zwischen den Versionen

Aus Scuba-Spot.info
Keine Bearbeitungszusammenfassung
Keine Bearbeitungszusammenfassung
Markierung: Zurückgesetzt
Zeile 40: Zeile 40:
         },*/
         },*/
         "contours": {
         "contours": {
             "tilesUrl": "https://tiles.scuba-spot.info/contours/{z}/{x}/{y}",
             "tilesUrl": "http://tiles.scuba-spot.info/contours/{z}/{x}/{y}",
             "options": {
             "options": {
                 "wvIsExternal": true,
                 "wvIsExternal": true,

Version vom 10. Juni 2025, 19:29 Uhr

/* Jedes JavaScript an dieser Stelle wird für alle Benutzer auf Seiten geladen, die Karten enthalten */

(function (mw) {
    var maptiles = {/*
        "mapnik": {
            "tilesUrl": "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
            "options": {
                "wvIsExternal": true,
                "wvName": "Mapnik",
                "subdomains": ["a", "b", "c"],
                "attribs": [
                    {
                        "url": "https://www.openstreetmap.org/copyright",
                        "name": "OpenStreetMap",
                        "label": "Map data"
                    }
                ]
            }
        },*/ /*
        "openseamap": {
            "tilesUrl": "https://tiles.openseamap.org/seamark/{z}/{x}/{y}.png",
            "options": {
                "wvIsExternal": true,
                "wvIsOverlay": true,
                "wvName": "Open Sea Map",
                "defaultActive": true,
                "attribs": [
                    {
                        "url": "https://www.openstreetmap.org/copyright",
                        "name": "OpenStreetMap",
                        "label": "Map data"
                    },
                    {
                        "url": "https://www.openseamap.org/",
                        "name": "Open Sea Map",
                        "label": "Map style"
                    }
                ]
            }
        },*/
        "contours": {
            "tilesUrl": "http://tiles.scuba-spot.info/contours/{z}/{x}/{y}",
            "options": {
                "wvIsExternal": true,
                "wvIsOverlay": true,
                "wvName": "Contours",
                "defaultActive": false,
                "attribs": [
                    {
                        "url": "https://www.swisstopo.admin.ch/de/hoehenmodell-swissbathy3d",
                        "name": "swissBathy3D",
                        "label": "©swisstopo"
                    }
                ]
            }
        }
        // Add more layers as needed
    };

    // Function to add layers to the map
    function addCustomLayers(map) {
        var baseLayers = {};
        var overlayLayers = {};

        for (var key in maptiles) {
            var tile = maptiles[key];
            var layer = L.tileLayer(tile.tilesUrl, tile.options);
            if (tile.options.wvIsOverlay) {
                overlayLayers[tile.options.wvName] = layer;
                if (tile.options.defaultActive) {
                    layer.addTo(map);
                }
            } else {
                baseLayers[tile.options.wvName] = layer;
            }
        }

        L.control.layers(baseLayers, overlayLayers).addTo(map);
    }

    // Hook into Kartographer's map initialization
    mw.hook('wikipage.maps').add(function (maps) {
        maps.forEach(function (map) {
            addCustomLayers(map);
        });
    });
})(mediaWiki);