Module:Location map: Difference between revisions

From Chalo Chatu, Zambia online encyclopedia
No edit summary
No edit summary
Line 393: Line 393:
local mark = args.mark or map('mark')
local mark = args.mark or map('mark')
if mark == '' then
if mark == '' then
mark = 'Red pog.png'
mark = 'Red pog.svg'
end
end
local marksize = tonumber(args.marksize) or tonumber(map('marksize')) or 8
local marksize = tonumber(args.marksize) or tonumber(map('marksize')) or 8
Line 402: Line 402:
end
end
return builder:node(markOuterDiv(x, y, imageDiv, labelDiv))
return builder:node(markOuterDiv(x, y, imageDiv, labelDiv))
end
local function switcherSeparate(s)
if s == nil then return {} end
local retval = {}
for i in string.gmatch(s .. '#', '([^#]*)#') do
i = mw.text.trim(i)
retval[#retval + 1] = (i ~= '' and i)
end
return retval
end
end


Line 423: Line 433:
end
end
if type(map) == 'table' then
if type(map) == 'table' then
local altmaps = switcherSeparate(args.AlternativeMap)
if #altmaps > #map then
error(string.format('%d AlternativeMaps were provided, but only %d maps were provided', #altmaps, #map))
end
local overlays = switcherSeparate(args.overlay_image)
if #overlays > #map then
error(string.format('%d overlay_images were provided, but only %d maps were provided', #overlays, #map))
end
local outputs = {}
local outputs = {}
args.autoSwitcherLabel = true
args.autoSwitcherLabel = true
for k,v in ipairs(map) do
for k,v in ipairs(map) do
args.AlternativeMap = altmaps[k]
args.overlay_image = overlays[k]
outputs[k] = p.main(frame, args, v)
outputs[k] = p.main(frame, args, v)
end
end