"ഘടകം:Slippymap/sandbox" എന്ന താളിന്റെ പതിപ്പുകൾ തമ്മിലുള്ള വ്യത്യാസം

Schoolwiki സംരംഭത്തിൽ നിന്ന്
No edit summary
No edit summary
 
(ഒരേ ഉപയോക്താവ് ചെയ്ത ഇടയ്ക്കുള്ള 12 നാൾപ്പതിപ്പുകൾ പ്രദർശിപ്പിക്കുന്നില്ല)
വരി 1: വരി 1:
local DEFAULT_FRAME_WIDTH = "270"
local DEFAULT_FRAME_HEIGHT = "200"
local DEFAULT_ZOOM = 10
-- Trim whitespace from arguments
function trimArgs(argsTable)
    local cleanArgs = {}
    for key, val in pairs(argsTable) do
        if type(val) == 'string' then
            val = val:match('^%s*(.-)%s*$')
            if val ~= '' then
                cleanArgs[key] = val
            end
        else
            cleanArgs[key] = val
        end
    end
    return cleanArgs
end
-- Main function to generate map
local p = {}
local p = {}


-- Function to clean input values by trimming spaces and handling nil values
-- This will display the map based on provided coordinates
local function clean(input)
p.main = function(frame)
return input and mw.text.trim(input) or nil
    local parent = frame.getParent(frame)
end
    local parentArgs = parent.args
    local config = trimArgs(parentArgs)


function p.slippymap(frame)
    -- Extract coordinates (if provided)
local args = (frame:getParent() or frame).args
    local coords = config.coordinates or config.coord


-- Extract and process map options from arguments
    if not coords then
local options = {
        return ''  -- Return an empty string if no coordinates are provided
latitude = tonumber(clean(args.lat)) or 51.3432699,
    end
longitude = tonumber(clean(args.lon)) or 0.52700328,
height = tonumber(clean(args.height)) or 400,
width = clean(args.width) == "full" and "full" or tonumber(clean(args.width)) or 400,
zoom = tonumber(clean(args.zoom)) or 12,
align = clean(args.alignment) or "center",
text = clean(args.text), -- Use provided text, no default value here
marker = clean(args.marker) ~= "no",
}


-- Generate GeoJSON content if the marker is enabled
    -- Configure mapframe arguments
local content = nil
    local args = {}
if options.marker then
    args.display = "inline"
content = mw.text.jsonEncode({
    args.frame = "yes"
type = "FeatureCollection",
    args.plain = "yes"
features = {
    args["frame-width"] = config["frame-width"] or DEFAULT_FRAME_WIDTH
{
    args["frame-height"] = config["frame-height"] or DEFAULT_FRAME_HEIGHT
type = "Feature",
    args.zoom = config.zoom or DEFAULT_ZOOM
geometry = {
    args["frame-coord"] = coords
type = "Point",
coordinates = { options.longitude, options.latitude },
},
properties = {
title = options.text or "Marker", -- Popup text set to `args.text`, fallback is "Marker"
icon = {
iconUrl = "//schoolwiki.in/images/5/5f/63rd_state_kalolsavam_logo.png", -- Custom marker image
iconSize = { 50, 50 }, -- Width and height of the icon
iconAnchor = { 25, 50 }, -- Anchor point (center bottom of the icon)
popupAnchor = { 0, -50 }, -- Popup anchor position
},
},
},
},
})
end


-- Return the mapframe tag with content and options
    -- Return the mapframe code as a string
return frame:extensionTag {
    return frame:preprocess('{{#mapframe:' .. mw.uri.encodeArgs(args) .. '}}')
name = "mapframe",
content = content,
args = {
latitude = options.latitude,
longitude = options.longitude,
height = options.height,
width = options.width,
zoom = options.zoom,
align = options.align,
},
}
end
end


return p
return p

18:34, 6 ജനുവരി 2025-നു നിലവിലുള്ള രൂപം

ഈ ഘടകത്തിന്റെ വിവരണം ഘടകം:Slippymap/sandbox/വിവരണം എന്ന താളിൽ നിർമ്മിക്കാവുന്നതാണ്

local DEFAULT_FRAME_WIDTH = "270"
local DEFAULT_FRAME_HEIGHT = "200"
local DEFAULT_ZOOM = 10

-- Trim whitespace from arguments
function trimArgs(argsTable)
    local cleanArgs = {}
    for key, val in pairs(argsTable) do
        if type(val) == 'string' then
            val = val:match('^%s*(.-)%s*$')
            if val ~= '' then
                cleanArgs[key] = val
            end
        else
            cleanArgs[key] = val
        end
    end
    return cleanArgs
end

-- Main function to generate map
local p = {}

-- This will display the map based on provided coordinates
p.main = function(frame)
    local parent = frame.getParent(frame)
    local parentArgs = parent.args
    local config = trimArgs(parentArgs)

    -- Extract coordinates (if provided)
    local coords = config.coordinates or config.coord

    if not coords then
        return ''  -- Return an empty string if no coordinates are provided
    end

    -- Configure mapframe arguments
    local args = {}
    args.display = "inline"
    args.frame = "yes"
    args.plain = "yes"
    args["frame-width"] = config["frame-width"] or DEFAULT_FRAME_WIDTH
    args["frame-height"] = config["frame-height"] or DEFAULT_FRAME_HEIGHT
    args.zoom = config.zoom or DEFAULT_ZOOM
    args["frame-coord"] = coords

    -- Return the mapframe code as a string
    return frame:preprocess('{{#mapframe:' .. mw.uri.encodeArgs(args) .. '}}')
end

return p
"https://schoolwiki.in/index.php?title=ഘടകം:Slippymap/sandbox&oldid=2624391" എന്ന താളിൽനിന്ന് ശേഖരിച്ചത്