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.
This module is subject to page protection. It is a highly visible module in use by a very large number of pages, or is substituted very frequently. Because vandalism or mistakes would affect many pages, and even trivial editing might cause substantial load on the servers, it is protected from editing.
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 as default.
If a page has a rendering time by Lua of between 5 seconds and 10 seconds using {{Maplink}} the use of the direct module call by syntax like: {{#tag:mapframe|[raw GeoJSON]|frameless=[1 for frame]|align=[left/right/center]|text=[caption]|width=[in px]|height=[in px]|latitude=[decimal degrees]|longitude=[decimal degrees]|zoom=[zoom factor]}} saves Lua over-head. An example of this substitution is at https://en.wikipedia.org/w/index.php?diff=970846012. Such code minimises the chances of hitting the ten second Lua timeout if the back-end servers are busy.
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)
Set up on another wiki
Create template and module:
Import this module and its template to that wiki (or copy the code over, giving attribution in the edit summary). Optionally, give them a name that makes sense in that wiki's language
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)
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)localArgs={}functionsetCleanArgs(argsTable)localcleanArgs={}forkey,valinpairs(argsTable)doiftype(val)=='string'thenval=val:match('^%s*(.-)%s*$')ifval~=''thencleanArgs[key]=valendelsecleanArgs[key]=valendendreturncleanArgsendfunctionmakeTag(name,attributes,content)localtag--todoreturntagendfunctionmakeContentJson(contentArgs)localdata={}ifcontentArgs.type=='point'thendata.type="Feature"elsedata.type="ExternalData"end--todo: fill out rest of datareturnmw.text.jsonEncode(data)endlocalp={}functionp.main(frame)localparent=frame.getParent(frame)Args=setCleanArgs(parent.args)localcontent={};localcontentIndex='';whileArgs['type'..contentIndex]dolocalcontentArgs={}contentArgs['type']=Args['type'..contentIndex]--todo: Add other relevant argscontent[contentIndexor1]=makeContentJson(contentArgs)contentIndex=(contentIndexor1)+1localmapContentlocaloutput=''--if needsTitleTagreturnoutputendreturnpend