ഘടകം:Slippymap/sandbox
ഈ ഘടകത്തിന്റെ വിവരണം ഘടകം: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