Module:Mapframe
Appearance
![]() | This module is rated as beta, and is ready for widespread use. It is still new and should be used with some caution to ensure the results are as expected. |
On English Wikipedia, this module is called by {{Maplink}}
, see that template's documentation for usage instructions.
Usage
- Standard usage
- Just use {{Maplink}}, which passes its parameters to this module's main function.
- From another module
-
- Import this module, e.g.
local mf = require('Module:Mapframe')
- Pass a table of parameter names/values to the _main function. See {{Maplink}} documentation for parameter names and descriptions. E.g.
local mapframe = mf._main(parameters)
- Preprocess _main's output before returning it, e.g.
return frame:preprocess(mapframe)
- Import this module, e.g.
Set up on another wiki
- Create template and module:
- Localise the module
- Edit the top bits of the module, between the comments
-- ##### Localisation (L10n) settings #####
and-- #### End of L10n settings ####
, replacing values between"
"
symbols with local values (when necessary)
- Edit the top bits of the module, between the comments
- Add documentation
- to the template (e.g. by translating Template:Maplink/doc, adjusting as necessary per any localisations made in the previous step)
- to the module (please transfer/translate these instructions so that wikimedians who read your wiki but not the English Wikipedia can also set up the module and template on another wiki).
--Parameter for cleaned-up parent.args (whitespace trimmed, blanks removed)
local Args = {}
function setCleanArgs(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
function makeTag(name, attributes, content)
local tag --todo
return tag
end
function makeContentJson(contentArgs)
local data = {}
if contentArgs.type == 'point' then
data.type = "Feature"
else
data.type = "ExternalData"
end
--todo: fill out rest of data
return mw.text.jsonEncode(data)
end
local p = {}
function p.main(frame)
local parent = frame.getParent(frame)
Args = setCleanArgs(parent.args)
local content = {};
local contentIndex = '';
while Args['type'..contentIndex] do
local contentArgs = {}
contentArgs['type'] = Args['type'..contentIndex]
--todo: Add other relevant args
content[contentIndex or 1] = makeContentJson(contentArgs)
contentIndex = (contentIndex or 1) + 1
local mapContent
local output = ''
--if needsTitleTag
return output
end
return p
end