"മീഡിയവിക്കി:Common.js" എന്ന താളിന്റെ പതിപ്പുകൾ തമ്മിലുള്ള വ്യത്യാസം

(ചെ.)No edit summary
(ചെ.)No edit summary
വരി 3: വരി 3:


document.addEventListener("DOMContentLoaded", function () {
document.addEventListener("DOMContentLoaded", function () {
     // Create a MutationObserver to watch for changes in the DOM
     // Check if L (Leaflet) is loaded
    const observer = new MutationObserver(function (mutations) {
    if (typeof L !== "undefined" && L.Marker) {
        mutations.forEach(function (mutation) {
        // Define a custom icon
            // Check if new nodes are added
        const customIcon = L.icon({
            mutation.addedNodes.forEach(function (node) {
            iconUrl: "https://schoolwiki.in/extensions/Kartographer/lib/external/mapbox/images/marker-icon-2x.png",
                // Ensure the node is an element and has the target class
            iconSize: [30, 70], // Size of the icon
                if (node.nodeType === 1 && node.matches('.leaflet-marker-pane img')) {
             iconAnchor: [15, 35] // Point of the icon which will correspond to the marker's location
                    const img = node;
                    if (img.src === "https://tile.openstreetmap.org/v4/marker/pin-m+7e7e7e@2x.png") {
                        // Replace the src attribute with the new URL
                        img.src = "https://schoolwiki.in/extensions/Kartographer/lib/external/mapbox/images/marker-icon-2x.png";
                    }
                }
             });
         });
         });
    });


    // Start observing the body for added child elements
        // Override the default marker icon
    observer.observe(document.body, {
        L.Marker.prototype.options.icon = customIcon;
         childList: true,
    } else {
        subtree: true
         console.error("Leaflet is not loaded. Make sure the map is initialized properly.");
     });
     }
});
});


"https://schoolwiki.in/മീഡിയവിക്കി:Common.js" എന്ന താളിൽനിന്ന് ശേഖരിച്ചത്