Documentation for this module may be created at Module:VisitedMap/doc
local p = {} local function parse_qids(qid_str) local qids = {} if qid_str and qid_str ~= "" then for qid in string.gmatch(qid_str, '([^,]+)') do local trimmed = mw.text.trim(qid) if trimmed ~= "" then table.insert(qids, trimmed) end end end return qids end local function build_shapes(qids, fill_color, group_title) local shapes = {} local chunk_size = 20 for i = 1, #qids, chunk_size do local chunk = {} for j = i, math.min(i + chunk_size - 1, #qids) do table.insert(chunk, qids[j]) end table.insert(shapes, { type = "ExternalData", service = "geoshape", ids = table.concat(chunk, ","), properties = { title = group_title, fill = fill_color, ["fill-opacity"] = 0.5, stroke = "#ffffff", ["stroke-width"] = 1 } }) end return shapes end local function get_arg(frame, key) local val = frame.args[key] if val and mw.text.trim(val) ~= "" then return mw.text.trim(val) end if frame:getParent() then val = frame:getParent().args[key] if val and mw.text.trim(val) ~= "" then return mw.text.trim(val) end end return "" end function p.render(frame) local country_qids_str = get_arg(frame, 1) local subdiv_qids_str = get_arg(frame, 2) if subdiv_qids_str == "" then subdiv_qids_str = get_arg(frame, "subdivisions") end local map_params = { latitude = "15", longitude = "13.5", zoom = "2", width = "100%", height = "500", align = "center" } local country_qids = parse_qids(country_qids_str) local subdiv_qids = parse_qids(subdiv_qids_str) if #country_qids == 0 and #subdiv_qids == 0 then return frame:extensionTag('mapframe', '', map_params) end local final_shapes = {} if #country_qids > 0 then local country_shapes = build_shapes(country_qids, "#006699") for _, shape in ipairs(country_shapes) do table.insert(final_shapes, shape) end end if #subdiv_qids > 0 then local subdiv_shapes = build_shapes(subdiv_qids, "#339966") for _, shape in ipairs(subdiv_shapes) do table.insert(final_shapes, shape) end end return frame:extensionTag('mapframe', mw.text.jsonEncode(final_shapes), map_params) end return p 
French
Deutsch