"ഘടകം:Slippymap/sandbox" എന്ന താളിന്റെ പതിപ്പുകൾ തമ്മിലുള്ള വ്യത്യാസം
No edit summary |
No edit summary |
||
| (ഒരേ ഉപയോക്താവ് ചെയ്ത ഇടയ്ക്കുള്ള 16 നാൾപ്പതിപ്പുകൾ പ്രദർശിപ്പിക്കുന്നില്ല) | |||
| വരി 1: | വരി 1: | ||
local | local DEFAULT_FRAME_WIDTH = "270" | ||
local DEFAULT_FRAME_HEIGHT = "200" | |||
local DEFAULT_ZOOM = 10 | |||
-- | -- Trim whitespace from arguments | ||
local | 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 | end | ||
function p. | -- 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 | end | ||
return p | return p | ||