Module:Location map/multi
- Afrikaans
- Аԥсшәа
- العربية
- Asturianu
- Авар
- Azərbaycanca
- تۆرکجه
- Basa Bali
- বাংলা
- 閩南語 / Bân-lâm-gí
- Беларуская
- भोजपुरी
- Bikol Central
- བོད་ཡིག
- Bosanski
- Буряад
- Català
- Чӑвашла
- Cebuano
- Chamoru
- Chi-Chewa
- Dansk
- الدارجة
- Ελληνικά
- Euskara
- فارسی
- Føroyskt
- Gaeilge
- ગુજરાતી
- 한국어
- Hausa
- Հայերեն
- हिन्दी
- Hrvatski
- Ilokano
- Bahasa Indonesia
- Íslenska
- עברית
- ಕನ್ನಡ
- ქართული
- Kurdî
- Latviešu
- Magyar
- Madhurâ
- मैथिली
- Македонски
- മലയാളം
- मराठी
- مصرى
- ဘာသာမန်
- مازِرونی
- Bahasa Melayu
- Mirandés
- Мокшень
- Монгол
- မြန်မာဘာသာ
- नेपाली
- 日本語
- Nordfriisk
- Norsk bokmål
- Oʻzbekcha / ўзбекча
- ਪੰਜਾਬੀ
- ပအိုဝ်ႏဘာႏသာႏ
- پښتو
- Português
- Qaraqalpaqsha
- Română
- Scots
- Shqip
- සිංහල
- Simple English
- سنڌي
- Slovenščina
- کوردی
- Српски / srpski
- Suomi
- Tagalog
- தமிழ்
- တႆး
- తెలుగు
- ไทย
- Türkçe
- Türkmençe
- Українська
- اردو
- Tiếng Việt
- 粵語
- 中文
- Kadazandusun
Appearance
From Wikipedia, the free encyclopedia
This module is rated as ready for general use. It has reached a mature state, is considered relatively stable and bug-free, and may be used wherever appropriate. It can be mentioned on help pages and other Wikipedia resources as an option for new users. To minimise server load and avoid disruptive output, improvements should be developed through sandbox testing rather than repeated trial-and-error editing.
Page template-protected This module is currently protected from editing.
See the protection policy and protection log for more details. Please discuss any changes on the talk page; you may submit an edit request to ask an administrator to make an edit if it is uncontroversial or supported by consensus. You may also request that this page be unprotected.
See the protection policy and protection log for more details. Please discuss any changes on the talk page; you may submit an edit request to ask an administrator to make an edit if it is uncontroversial or supported by consensus. You may also request that this page be unprotected.
Warning This Lua module is used on approximately 34,000 pages and changes may be widely noticed. Test changes in the module's /sandbox or /testcases subpages, or in your own module sandbox. Consider discussing changes on the talk page before implementing them.
Usage
This module implements the {{Location map+ }} and {{Location map many }} templates. Please see the template pages for usage instructions.
This section may require cleanup to meet Wikipedia's quality standards . The specific problem is: The load() function is used on its own. We should document it. Please help improve this section if you can; the talk page may contain suggestions.
Tracking/maintenance category
The above documentation is transcluded from Module:Location map/multi/doc. (edit | history)
Editors can experiment in this module's sandbox (edit | diff) and testcases (create) pages.
Subpages of this module.
Editors can experiment in this module's sandbox (edit | diff) and testcases (create) pages.
Subpages of this module.
require('strict') localp={} localgetArgs=require('Module:Arguments').getArgs locallocmap=require('Module:Location map') localfunctionswitcherSeparate(s) ifs==nilthenreturn{}end localretval={} foriinstring.gmatch(s..'#','([^#]*)#')do i=mw.text.trim(i) retval[#retval+1]=(i~=''andi) end returnretval end functionp.container(frame,args,map) localcaption_list={} ifnotargsthen args=getArgs(frame,{wrappers='Template:Location map+',valueFunc=locmap.valueFunc}) end ifnotmapthen ifargs[1]then map={} formapnameinstring.gmatch(args[1],'[^#]+')do map[#map+1]=locmap.getMapParams(mapname,frame) end ifargs['caption']then ifargs['caption']==""then while#caption_list<#mapdo caption_list[#caption_list+1]=args['caption'] end else forcaptioninmw.text.gsplit(args['caption'],'##',true)do caption_list[#caption_list+1]=caption end end end if#map==1thenmap=map[1]end else map=locmap.getMapParams('World',frame) end end iftype(map)=='table'then localplaceslist=mw.text.gsplit(args.places,'#PlaceList#') localpermaplaces={} localnumbermaps=#map localcount=0 fori=1,numbermapsdo permaplaces[i]={} end forplaceinplaceslistdo table.insert(permaplaces[count%numbermaps+1],place) count=count+1 end localaltmaps=switcherSeparate(args.AlternativeMap) if#altmaps>#mapthen error(string.format('%d AlternativeMaps were provided, but only %d maps were provided',#altmaps,#map)) end localoverlays=switcherSeparate(args.overlay_image) if#overlays>#mapthen error(string.format('%d overlay_images were provided, but only %d maps were provided',#overlays,#map)) end if#caption_list>#mapthen error(string.format('%d captions were provided, but only %d maps were provided',#caption_list,#map)) end localoutputs={} args.autoSwitcherLabel=true fork,vinipairs(map)do args.AlternativeMap=altmaps[k] args.overlay_image=overlays[k] args.caption=caption_list[k] args.places=table.concat(permaplaces[k]) outputs[k]=p.container(frame,args,v) end return'<div class="switcher-container">'..table.concat(outputs)..'</div>' else returnlocmap.top(frame,args,map)..(args.placesandargs.places:gsub('%s*\n%s*','')or'')..locmap.bottom(frame,args,map) end end localfunctionmanyMakeArgs(fullArgs,n) ifn==1then return{ lat=fullArgs.lat1orfullArgs.lat, long=fullArgs.long1orfullArgs.long, coordinates=fullArgs.coordinates1orfullArgs.coordinates, lat_deg=fullArgs.lat1_degorfullArgs.lat_deg, lat_min=fullArgs.lat1_minorfullArgs.lat_min, lat_sec=fullArgs.lat1_secorfullArgs.lat_sec, lat_dir=fullArgs.lat1_dirorfullArgs.lat_dir, lon_deg=fullArgs.lon1_degorfullArgs.lon_deg, lon_min=fullArgs.lon1_minorfullArgs.lon_min, lon_sec=fullArgs.lon1_secorfullArgs.lon_sec, lon_dir=fullArgs.lon1_dirorfullArgs.lon_dir, outside=fullArgs.outside1orfullArgs.outside, mark=fullArgs.mark1orfullArgs.mark, marksize=fullArgs.mark1sizeorfullArgs.marksize, link=fullArgs.link1orfullArgs.link, label=fullArgs.label1orfullArgs.label, label_size=fullArgs.label1_sizeorfullArgs.label_size, label_width=fullArgs.label1_widthorfullArgs.label_width, position=fullArgs.position1orfullArgs.pos1orfullArgs.positionorfullArgs.pos, background=fullArgs.background1orfullArgs.bg1orfullArgs.backgroundorfullArgs.bg } else return{ lat=fullArgs['lat'..n], long=fullArgs['long'..n], coordinates=fullArgs['coordinates'..n], lat_deg=fullArgs['lat'..n..'_deg'], lat_min=fullArgs['lat'..n..'_min'], lat_sec=fullArgs['lat'..n..'_sec'], lat_dir=fullArgs['lat'..n..'_dir'], lon_deg=fullArgs['lon'..n..'_deg'], lon_min=fullArgs['lon'..n..'_min'], lon_sec=fullArgs['lon'..n..'_sec'], lon_dir=fullArgs['lon'..n..'_dir'], outside=fullArgs['outside'..n], mark=fullArgs['mark'..n], marksize=fullArgs['mark'..n..'size'], link=fullArgs['link'..n], label=fullArgs['label'..n], label_size=fullArgs['label'..n..'_size'], label_width=fullArgs['label'..n..'_width'], position=fullArgs['position'..n]orfullArgs['pos'..n], background=fullArgs['background'..n]orfullArgs['bg'..n] } end end functionp.many(frame,args,map) ifnotargsthen args=getArgs(frame,{wrappers='Template:Location map many',valueFunc=locmap.valueFunc}) end ifnotargs[1]then args[1]='World' end ifnotmapthen map={} formapnameinstring.gmatch(args[1],'[^#]+')do map[#map+1]=locmap.getMapParams(mapname,frame) end if#map~=1then localoutputs={} args.autoSwitcherLabel=true fork,vinipairs(map)do outputs[k]=p.many(frame,args,v) end return'<div class="switcher-container">'..table.concat(outputs)..'</div>' end map=map[1] end localmarks={} localmarkhigh ifargs.markhighthen mw.log('Removed parameter markhigh used.') localparent=frame:getParent() ifparentthen mw.log('Parent is '..parent:getTitle()) end mw.logObject(args,'args') markhigh=true end fork,vinpairs(args)do-- @todo change to uargs once we have that ifvthen ifstring.sub(k,-4)=='_deg'then k=string.sub(k,1,-5) end ifstring.sub(k,1,3)=='lat'then k=tonumber(string.sub(k,4)) ifkthen table.insert(marks,k) end elseifstring.sub(k,1,11)=='coordinates'then k=tonumber(string.sub(k,12)) ifkthen table.insert(marks,k) end end end end table.sort(marks) ifmarks[1]~=1and(args.latorargs.lat_degorargs.coordinates)then table.insert(marks,1,1) end localbody='' for_,vinipairs(marks)do -- don't try to consolidate this into the above loop. ordering of elements from pairs() is unspecified body=body..tostring(locmap.mark(frame,manyMakeArgs(args,v),map)) ifargs['mark'..v..'high']then mw.log('Removed parameter mark'..v..'high used.') localparent=frame:getParent() ifparentthen mw.log('Parent is '..parent:getTitle()) end mw.logObject(args,'args') markhigh=true end end args.label=nil-- there is no global label returnlocmap.top(frame,args,map)..body..locmap.bottom(frame,args,map)..(markhighand'[[Category:Location maps with possible errors|Page using removed parameter]]'or'') end functionp.load(frame,args,map) ifnotargsthen args=getArgs(frame,{frameOnly=true}) end localdataModule=mw.loadData(args[1]) localcontainerArgs=dataModule.containerArgs ifnotmapthen map={} formapnameinstring.gmatch(containerArgs[1],'[^#]+')do map[#map+1]=locmap.getMapParams(mapname,frame) end if#map~=1then localoutputs={} args.autoSwitcherLabel=true fork,vinipairs(map)do outputs[k]=p.load(frame,args,v) end return'<div class="switcher-container">'..table.concat(outputs)..'</div>' end map=map[1] end localmarks={} ifdataModule.marksthen fork,markArgsinipairs(dataModule.marks)do marks[k]=tostring(locmap.mark(frame,markArgs,map)) end end ifdataModule.secondaryModulesthen for_,modnameinipairs(dataModule.secondaryModules)do for_,markArgsinipairs(mw.loadData(modname).marks)do marks[#marks+1]=tostring(locmap.mark(frame,markArgs,map)) end end end ifargs.autoSwitcherLabelthen localTableTools=require('Module:TableTools') containerArgs=TableTools.shallowClone(containerArgs) containerArgs.autoSwitcherLabel=true end returnlocmap.top(frame,containerArgs,map)..table.concat(marks)..locmap.bottom(frame,containerArgs,map) end returnp