Jump to content
Wikipedia The Free Encyclopedia

Module:Location map

From Wikipedia, the free encyclopedia
Module documentationview edit history purge
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.
Warning This Lua module is used on approximately 989,000 pages, or roughly 1% of all pages .
To avoid major disruption and server load, any changes should be tested in the module's /sandbox or /testcases subpages, or in your own module sandbox. The tested changes can be added to this page in a single edit. Consider discussing changes on the talk page before implementing them.
This module depends on the following other modules:

Usage

This module implements the {{Location map }} and {{Location map~ }} templates. Please see the template pages for usage instructions.

Infobox maps

To insert into an Infobox, simply add the following to automatically support pushpin maps.

| image2 = {{#invoke:Location map|infobox_pushpin_map}}

For the documentation, you can use {{Location map/doc/infobox parameters}} (which is displayed below). If any default values are modified in the #invoke calls, add them as parameters in the form |parameter_name=value.

Parameters

Below are the parameters used by Module:Location map to produce the pushpin map in this Infobox. These parameters are available for editors to set in articles that use this infobox.

Parameter Description Default
|pushpin_map= The map(s) to display. For example, specifying England will use the values for England in Module:Location map/data/England.Multiple maps can be shown by providing a list of map names separated by #. For multiple maps, the first is shown by default. A reader can select the others with radio buttons. N/A
|pushpin_caption= The text of a caption to be displayed below the map. If not provided a default caption will be generated. Multiple captions can be shown when separated by ## (that's two). Location within MAPNAME
|pushpin_relief= 0/false/off will cause the template to display the map defined as image (generally not a relief map). 1/true/on will cause the template to display the map defined as image1 (generally a relief map). Any non-zero numeric value such as 2 or 3 will display image2 or image3, if those images are defined. Any other non-empty value will cause display of image1. See the example at Location map+/relief. 0
|pushpin_label= The text of the label to display next to the identifying mark; a wikilink can be used. You can enclose the label inside of {{nowrap }} if you want to make sure that it stays on a single line. N/A
|pushpin_label_size= The font size to use for the label, given as a percentage of the normal font size (<100=smaller, >100=larger); the default size is 90. Do not include %. For example, use |pushpin_label_size=80, not |pushpin_label_size=80%. If set to 0, the label is only displayed when the user hovers over the mark. 90
|pushpin_label_position= The position of the label relative to the identifying mark; valid values are left, right, top, bottom and none. This defaults to either left or right, depending on the coordinates of the marker and its position relative to the right border of the map image. When |pushpin_label_position=none, any defined label will not be displayed with the mark, but it will be used to create the default caption. N/A
|pushpin_mark= The name of an image file to display as the identifying mark; the default is Red pog.svg . See examples at Commons:Location markers and Commons:Category:Map icons. Red pog.svg
|pushpin_mark_size= The size of the identifying mark in pixels. Do not include px 8
|pushpin_alt= Alt text for map; used by screen readers. See WP:ALT. N/A
|pushpin_background= The background color to use for the label; see Web colors. The default is no background color, which shows the map image behind the label. N/A
|pushpin_map_size= Determines the width of the map in pixels, overriding any default values; do not include px. N/A

In addition, there are "hidden" parameters that can be set in an invocation to this module, but are not exposed as parameters in a calling infobox:

  • |float= --- the location map floats within the infobox, set its alignment. Defaults to "center"
  • |border= --- sets the border color of the map. Defaults to "infobox" which implements a standard border for an infobox
  • |default_width= --- if the map width is not specified, uses this width. A bare number is interpreted in pixels
  • |max_width= --- if the map width is specified in pixels, it cannot exceed this value (interpreted in pixels if bare).

Tracking/maintenance categories

See also

The above documentation is transcluded from Module:Location map/doc. (edit | history)
Editors can experiment in this module's sandbox (edit | diff) and testcases (edit) pages.
Subpages of this module.

 require('strict')

 localp={}

 localgetArgs=require('Module:Arguments').getArgs

 localfunctionround(n,decimals)
 localpow=10^(decimalsor0)
 returnmath.floor(n*pow+0.5)/pow
 end

 functionp.getMapParams(map,frame)
 ifnotmapthen
 error('The name of the location map definition to use must be specified',2)
 end
 localmoduletitle=mw.title.new('Module:Location map/data/'..map)
 ifnotmoduletitlethen
 error(string.format('%q is not a valid name for a location map definition',map),2)
 elseifmoduletitle.existsthen
 localmapData=mw.loadData('Module:Location map/data/'..map)
 returnfunction(name,params)
 ifname==nilthen
 return'Module:Location map/data/'..map
 elseifmapData[name]==nilthen
 return''
 elseifparamsthen
 returnmw.message.newRawMessage(tostring(mapData[name]),unpack(params)):plain()
 else
 returnmapData[name]
 end
 end
 else
 error('Unable to find the specified location map definition: "Module:Location map/data/'..map..'" does not exist',2)
 end
 end

 functionp.data(frame,args,map)
 ifnotargsthen
 args=getArgs(frame,{frameOnly=true})
 end
 ifnotmapthen
 map=p.getMapParams(args[1],frame)
 end
 localparams={}
 fork,vinipairs(args)do
 ifk>2then
 params[k-2]=v
 end
 end
 returnmap(args[2],#params~=0andparams)
 end

 localhemisphereMultipliers={
 longitude={W=-1,w=-1,E=1,e=1},
 latitude={S=-1,s=-1,N=1,n=1}
 }

 localfunctiondecdeg(degrees,minutes,seconds,hemisphere,decimal,direction)
 ifdecimalthen
 ifdegreesthen
 error('Decimal and DMS degrees cannot both be provided for '..direction,2)
 elseifminutesthen
 error('Minutes can only be provided with DMS degrees for '..direction,2)
 elseifsecondsthen
 error('Seconds can only be provided with DMS degrees for '..direction,2)
 elseifhemispherethen
 error('A hemisphere can only be provided with DMS degrees for '..direction,2)
 end
 localretval=tonumber(decimal)
 ifretvalthen
 returnretval
 end
 error('The value "'..decimal..'" provided for '..direction..' is not valid',2)
 elseifsecondsandnotminutesthen
 error('Seconds were provided for '..direction..' without minutes also being provided',2)
 elseifnotdegreesthen
 ifminutesthen
 error('Minutes were provided for '..direction..' without degrees also being provided',2)
 elseifhemispherethen
 error('A hemisphere was provided for '..direction..' without degrees also being provided',2)
 end
 returnnil
 end
 decimal=tonumber(degrees)
 ifnotdecimalthen
 error('The degree value "'..degrees..'" provided for '..direction..' is not valid',2)
 elseifminutesandnottonumber(minutes)then
 error('The minute value "'..minutes..'" provided for '..direction..' is not valid',2)
 elseifsecondsandnottonumber(seconds)then
 error('The second value "'..seconds..'" provided for '..direction..' is not valid',2)
 end
 decimal=decimal+(minutesor0)/60+(secondsor0)/3600
 ifhemispherethen
 localmultiplier=hemisphereMultipliers[direction][hemisphere]
 ifnotmultiplierthen
 error('The hemisphere "'..hemisphere..'" provided for '..direction..' is not valid',2)
 end
 decimal=decimal*multiplier
 end
 returndecimal
 end

 -- Finds a parameter in a transclusion of {{Coord}}.
 localfunctioncoord2text(para,coord)-- this should be changed for languages which do not use Arabic numerals or the degree sign
 locallat,long=mw.ustring.match(coord,'<span class="p%-latitude latitude">([^<]+)</span><span class="p%-longitude longitude">([^<]+)</span>')
 iflatthen
 returntonumber(para=='longitude'andlongorlat)
 end
 localresult=mw.text.split(mw.ustring.match(coord,'%-?[%.%d]+°[NS] %-?[%.%d]+°[EW]')or'','[ °]')
 ifpara=='longitude'thenresult={result[3],result[4]}end
 ifnottonumber(result[1])ornotresult[2]then
 mw.log('Malformed coordinates value')
 mw.logObject(para,'para')
 mw.logObject(coord,'coord')
 returnerror('Malformed coordinates value',2)
 end
 returntonumber(result[1])*hemisphereMultipliers[para][result[2]]
 end

 -- effectively make removeBlanks false for caption and maplink, and true for everything else
 -- if useWikidata is present but blank, convert it to false instead of nil
 -- p.top, p.bottom, and their callers need to use this
 functionp.valueFunc(key,value)
 ifvaluethen
 value=mw.text.trim(value)
 end
 ifvalue~=''orkey=='caption'orkey=='maplink'then
 returnvalue
 elseifkey=='useWikidata'then
 returnfalse
 end
 end

 localfunctiongetContainerImage(args,map)
 ifargs.AlternativeMapthen
 returnargs.AlternativeMap
 elseifargs.reliefthen
 localdigits=mw.ustring.match(args.relief,'^[1-9][0-9]?$')-- image1 to image99
 ifdigitsthen
 localimageDigits=map('image'..digits)
 ifimageDigits~=''thenreturnimageDigitsend
 end
 localyesNo=require('Module:Yesno')
 ifyesNo(args.relief,true)then
 localimage1=map('image1')
 ifimage1~=''thenreturnimage1end
 end
 end
 returnmap('image')
 end

 functionp.top(frame,args,map)
 ifnotargsthen
 args=getArgs(frame,{frameOnly=true,valueFunc=p.valueFunc})
 end
 ifnotmapthen
 map=p.getMapParams(args[1],frame)
 end
 localwidth
 localdefault_as_number=tonumber(mw.ustring.match(tostring(args.default_width),"%d*"))
 ifnotargs.widththen
 width=round((default_as_numberor240)*(tonumber(map('defaultscale'))or1))
 elseifmw.ustring.sub(args.width,-2)=='px'then
 width=mw.ustring.sub(args.width,1,-3)
 else
 width=args.width
 end
 localwidth_as_number=tonumber(mw.ustring.match(tostring(width),"%d*"))or0;
 ifwidth_as_number==0then
 -- check to see if width is junk. If it is, then use default calculation
 width=round((default_as_numberor240)*(tonumber(map('defaultscale'))or1))
 width_as_number=tonumber(mw.ustring.match(tostring(width),"%d*"))or0;
 end
 ifargs.max_width~=""andargs.max_width~=nilthen
 -- check to see if width bigger than max_width
 localmax_as_number=tonumber(mw.ustring.match(args.max_width,"%d*"))or0;
 ifwidth_as_number>max_as_numberandmax_as_number>0then
 width=args.max_width;
 end
 end
 localretval=frame:extensionTag{name='templatestyles',args={src='Module:Location map/styles.css'}}
 ifargs.float=='center'then
 retval=retval..'<div class="center">'
 end
 ifargs.captionandargs.caption~=''andargs.border~='infobox'then
 retval=retval..'<div class="locmap noresize thumb '
 ifargs.float=='"left"'orargs.float=='left'then
 retval=retval..'floatleft'
 elseifargs.float=='"center"'orargs.float=='center'orargs.float=='"none"'orargs.float=='none'then
 retval=retval..'tnone'
 else
 retval=retval..'floatright'
 end
 retval=retval..'"><div class="thumbinner" style="width:'..(width+2)..'px'
 ifargs.border=='none'then
 retval=retval..';border:none'
 elseifargs.borderthen
 retval=retval..';border-color:'..args.border
 end
 retval=retval..'"><div style="position:relative;width:'..width..'px'..(args.border~='none'and';border:1px solid lightgray">'or'">')
 else
 retval=retval..'<div class="locmap" style="width:'..width..'px;'
 ifargs.float=='"left"'orargs.float=='left'then
 retval=retval..'float:left;clear:left'
 elseifargs.float=='"center"'orargs.float=='center'then
 retval=retval..'float:none;clear:both;margin-left:auto;margin-right:auto'
 elseifargs.float=='"none"'orargs.float=='none'then
 retval=retval..'float:none;clear:none'
 else
 retval=retval..'float:right;clear:right'
 end
 retval=retval..'"><div style="width:'..width..'px;padding:0"><div style="position:relative;width:'..width..'px">'
 end
 localimage=getContainerImage(args,map)
 localcurrentTitle=mw.title.getCurrentTitle()
 retval=string.format(
 '%s[[File:%s|%spx|%s%s|class=notpageimage noviewer]]',
 retval,
 image,
 width,
 args.altor((args.labelorcurrentTitle.text)..' is located in '..map('name')),
 args.maplinkand('|link='..args.maplink)or''
 )
 ifargs.captionandargs.caption~=''then
 if(currentTitle.namespace==0)andmw.ustring.find(args.caption,'##')then
 retval=retval..'[[Category:Pages using location map with a double number sign in the caption]]'
 end
 end
 ifargs.overlay_imagethen
 returnretval..'<div style="position:absolute;top:0;left:0">[[File:'..args.overlay_image..'|'..width..'px|class=notpageimage noviewer]]</div>'
 else
 returnretval
 end
 end

 functionp.bottom(frame,args,map)
 ifnotargsthen
 args=getArgs(frame,{frameOnly=true,valueFunc=p.valueFunc})
 end
 ifnotmapthen
 map=p.getMapParams(args[1],frame)
 end
 localretval='</div>'
 localcurrentTitle=mw.title.getCurrentTitle()
 ifnotargs.captionorargs.border=='infobox'then
 ifargs.borderthen
 retval=retval..'<div style="padding-top:0.2em">'
 else
 retval=retval..'<div style="font-size:91%;padding-top:3px">'
 end
 retval=retval
 ..(args.captionor(args.labelorcurrentTitle.text)..' ('..map('name')..')')
 ..'</div>'
 elseifargs.caption~=''then
 -- This is not the pipe trick. We're creating a link with no text on purpose, so that CSS can give us a nice image
 retval=retval..'<div class="thumbcaption"><div class="magnify">[[:File:'..getContainerImage(args,map)..'| ]]</div>'..args.caption..'</div>'
 end

 ifargs.switcherLabelthen
 retval=retval..'<span class="switcher-label" style="display:none">'..args.switcherLabel..'</span>'
 elseifargs.autoSwitcherLabelthen
 retval=retval..'<span class="switcher-label" style="display:none">Show map of '..map('name')..'</span>'
 end

 retval=retval..'</div></div>'
 ifargs.caption_undefinedthen
 mw.log('Removed parameter caption_undefined used.')
 localparent=frame:getParent()
 ifparentthen
 mw.log('Parent is '..parent:getTitle())
 end
 mw.logObject(args,'args')
 ifcurrentTitle.namespace==0then
 retval=retval..'[[Category:Location maps with removed parameters|caption_undefined]]'
 end
 end
 ifmap('skew')~=''ormap('lat_skew')~=''ormap('crosses180')~=''ormap('type')~=''then
 mw.log('Removed parameter used in map definition '..map())
 ifcurrentTitle.namespace==0then
 localkey=(map('skew')~=''and'skew'or'')..
 (map('lat_skew')~=''and'lat_skew'or'')..
 (map('crosses180')~=''and'crosses180'or'')..
 (map('type')~=''and'type'or'')
 retval=retval..'[[Category:Location maps with removed parameters|'..key..' ]]'
 end
 end
 ifstring.find(map('name'),'|',1,true)then
 mw.log('Pipe used in name of map definition '..map())
 ifcurrentTitle.namespace==0then
 retval=retval..'[[Category:Location maps with a name containing a pipe]]'
 end
 end
 ifargs.float=='center'then
 retval=retval..'</div>'
 end
 returnretval
 end

 localfunctionmarkOuterDiv(x,y,imageDiv,labelDiv,label_size)
 returnmw.html.create('div')
 :addClass('od')
 :addClass('notheme')-- T236137
 :cssText('top:'..round(y,3)..'%;left:'..round(x,3)..'%;font-size:'..label_size..'%')
 :node(imageDiv)
 :node(labelDiv)
 end

 localfunctionmarkImageDiv(mark,marksize,label,link,alt,title)
 localbuilder=mw.html.create('div')
 :addClass('id')
 :cssText('left:-'..round(marksize/2)..'px;top:-'..round(marksize/2)..'px')
 :attr('title',title)
 ifmarksize~=0then
 builder:wikitext(string.format(
 '[[File:%s|%dx%dpx|%s|link=%s%s|class=notpageimage noviewer]]',
 mark,
 marksize,
 marksize,
 label,
 link,
 altand('|alt='..alt)or''
 ))
 end
 returnbuilder
 end

 localfunctionmarkLabelDiv(label,label_size,label_width,position,background,x,marksize)
 iftonumber(label_size)==0then
 returnmw.html.create('div'):addClass('l0'):wikitext(label)
 end
 localbuilder=mw.html.create('div')
 :cssText('width:'..label_width..'em')
 localdistance=round(marksize/2+1)
 ifposition=='top'then-- specified top
 builder:addClass('pv'):cssText('bottom:'..distance..'px;left:'..(-label_width/2)..'em')
 elseifposition=='bottom'then-- specified bottom
 builder:addClass('pv'):cssText('top:'..distance..'px;left:'..(-label_width/2)..'em')
 elseifposition=='left'or(tonumber(x)>70andposition~='right')then-- specified left or autodetected to left
 builder:addClass('pl'):cssText('right:'..distance..'px')
 else-- specified right or autodetected to right
 builder:addClass('pr'):cssText('left:'..distance..'px')
 end
 builder=builder:tag('div')
 :wikitext(label)
 ifbackgroundthen
 builder:cssText('background-color:'..background)
 end
 returnbuilder:done()
 end

 localfunctiongetX(longitude,left,right)
 localwidth=(right-left)%360
 ifwidth==0then
 width=360
 end
 localdistanceFromLeft=(longitude-left)%360
 -- the distance needed past the map to the right equals distanceFromLeft - width. the distance needed past the map to the left equals 360 - distanceFromLeft. to minimize page stretching, go whichever way is shorter
 ifdistanceFromLeft-width/2>=180then
 distanceFromLeft=distanceFromLeft-360
 end
 return100*distanceFromLeft/width
 end

 localfunctiongetY(latitude,top,bottom)
 return100*(top-latitude)/(top-bottom)
 end

 functionp.mark(frame,args,map)
 ifnotargsthen
 args=getArgs(frame,{wrappers='Template:Location map~'})
 end
 localmapnames={}
 ifnotmapthen
 ifargs[1]then
 map={}
 formapnameinmw.text.gsplit(args[1],'#',true)do
 map[#map+1]=p.getMapParams(mw.ustring.gsub(mapname,'^%s*(.-)%s*$','%1'),frame)
 mapnames[#mapnames+1]=mapname
 end
 if#map==1thenmap=map[1]end
 else
 map=p.getMapParams('World',frame)
 args[1]='World'
 end
 end
 iftype(map)=='table'then
 localoutputs={}
 localoldargs=args[1]
 fork,vinipairs(map)do
 args[1]=mapnames[k]
 outputs[k]=tostring(p.mark(frame,args,v))
 end
 args[1]=oldargs
 returntable.concat(outputs,'#PlaceList#')..'#PlaceList#'
 end
 localx,y,longitude,latitude
 longitude=decdeg(args.lon_deg,args.lon_min,args.lon_sec,args.lon_dir,args.long,'longitude')
 latitude=decdeg(args.lat_deg,args.lat_min,args.lat_sec,args.lat_dir,args.lat,'latitude')
 ifargs.excludefromthen
 -- If this mark is to be excluded from certain maps entirely (useful in the context of multiple maps)
 forexclusionmapinmw.text.gsplit(args.excludefrom,'#',true)do
 -- Check if this map is excluded. If so, return an empty string.
 ifargs[1]==exclusionmapthen
 return''
 end
 end

 end
 localbuilder=mw.html.create()
 localcurrentTitle=mw.title.getCurrentTitle()
 ifargs.coordinatesthen
 --		Temporarily removed to facilitate infobox conversion. See [[Wikipedia:Coordinates in infoboxes]]

 --		if longitude or latitude then
 --			error('Coordinates from [[Module:Coordinates]] and individual coordinates cannot both be provided')
 --		end
 longitude=coord2text('longitude',args.coordinates)
 latitude=coord2text('latitude',args.coordinates)
 elseifnotlongitudeandnotlatitudeandargs.useWikidatathen
 -- If they didn't provide either coordinate, try Wikidata. If they provided one but not the other, don't.
 localentity=mw.wikibase.getEntity()
 ifentityandentity.claimsandentity.claims.P625andentity.claims.P625[1].mainsnak.snaktype=='value'then
 localvalue=entity.claims.P625[1].mainsnak.datavalue.value
 longitude,latitude=value.longitude,value.latitude
 end
 ifargs.linkand(currentTitle.namespace==0)then
 builder:wikitext('[[Category:Location maps with linked markers with coordinates from Wikidata]]')
 end
 end
 ifnotlongitudethen
 error('No value was provided for longitude')
 elseifnotlatitudethen
 error('No value was provided for latitude')
 end
 ifcurrentTitle.namespace>0then
 if(notargs.lon_deg)~=(notargs.lat_deg)then
 builder:wikitext('[[Category:Location maps with different longitude and latitude precisions|Degrees]]')
 elseif(notargs.lon_min)~=(notargs.lat_min)then
 builder:wikitext('[[Category:Location maps with different longitude and latitude precisions|Minutes]]')
 elseif(notargs.lon_sec)~=(notargs.lat_sec)then
 builder:wikitext('[[Category:Location maps with different longitude and latitude precisions|Seconds]]')
 elseif(notargs.lon_dir)~=(notargs.lat_dir)then
 builder:wikitext('[[Category:Location maps with different longitude and latitude precisions|Hemisphere]]')
 elseif(notargs.long)~=(notargs.lat)then
 builder:wikitext('[[Category:Location maps with different longitude and latitude precisions|Decimal]]')
 end
 end
 if((tonumber(args.lat_deg)or0)<0)and((tonumber(args.lat_min)or0)~=0or(tonumber(args.lat_sec)or0)~=0or(args.lat_dirandargs.lat_dir~=''))then
 builder:wikitext('[[Category:Location maps with negative degrees and minutes or seconds]]')
 end
 if((tonumber(args.lon_deg)or0)<0)and((tonumber(args.lon_min)or0)~=0or(tonumber(args.lon_sec)or0)~=0or(args.lon_dirandargs.lon_dir~=''))then
 builder:wikitext('[[Category:Location maps with negative degrees and minutes or seconds]]')
 end
 if(((tonumber(args.lat_min)or0)<0)or((tonumber(args.lat_sec)or0)<0))then
 builder:wikitext('[[Category:Location maps with negative degrees and minutes or seconds]]')
 end
 if(((tonumber(args.lon_min)or0)<0)or((tonumber(args.lon_sec)or0)<0))then
 builder:wikitext('[[Category:Location maps with negative degrees and minutes or seconds]]')
 end
 ifargs.skeworargs.lon_shiftorargs.markhighthen
 mw.log('Removed parameter used in invocation.')
 localparent=frame:getParent()
 ifparentthen
 mw.log('Parent is '..parent:getTitle())
 end
 mw.logObject(args,'args')
 ifcurrentTitle.namespace==0then
 localkey=(args.skewand'skew'or'')..
 (args.lon_shiftand'lon_shift'or'')..
 (args.markhighand'markhigh'or'')
 builder:wikitext('[[Category:Location maps with removed parameters|'..key..' ]]')
 end
 end
 ifmap('x')~=''then
 x=tonumber(mw.ext.ParserFunctions.expr(map('x',{latitude,longitude})))
 else
 x=tonumber(getX(longitude,map('left'),map('right')))
 end
 ifmap('y')~=''then
 y=tonumber(mw.ext.ParserFunctions.expr(map('y',{latitude,longitude})))
 else
 y=tonumber(getY(latitude,map('top'),map('bottom')))
 end
 if(x<0orx>100ory<0ory>100)andnotargs.outsidethen
 mw.log('Mark placed outside map boundaries without outside flag set. x = '..x..', y = '..y)
 localparent=frame:getParent()
 ifparentthen
 mw.log('Parent is '..parent:getTitle())
 end
 mw.logObject(args,'args')
 ifcurrentTitle.namespace==0then
 localkey=currentTitle.prefixedText
 builder:wikitext('[[Category:Location maps with marks outside map and outside parameter not set|'..key..' ]]')
 end
 end
 localmark=args.markormap('mark')
 ifmark==''then
 mark='Red pog.svg'
 end
 localmarksize=tonumber(args.marksize)ortonumber(map('marksize'))or8
 localimageDiv=markImageDiv(mark,marksize,args.labelormw.title.getCurrentTitle().text,args.linkor'',args.alt,args[2])
 locallabel_size=args.label_sizeor91
 locallabelDiv
 ifargs.labelandargs.position~='none'then
 labelDiv=markLabelDiv(args.label,label_size,args.label_widthor6,args.position,args.background,x,marksize)
 end
 returnbuilder:node(markOuterDiv(x,y,imageDiv,labelDiv,label_size))
 end

 localfunctionswitcherSeparate(s)
 ifs==nilthenreturn{}end
 localretval={}
 foriinstring.gmatch(s..'#','([^#]*)#')do
 i=mw.text.trim(i)
 retval[#retval+1]=(i~=''andi)
 end
 returnretval
 end

 functionp.infobox_pushpin_map(frame)
 --This function is designed to be invoked from an infobox template
 --* Some parameters (generally starting with "pushpin_") are meant to be exposed as parameters
 -- in the outer infobox, settable by editors
 --* Others are meant to be "hidden" (e.g., only set inside the infobox template code)
 -- First get the combined arguments from both parent and invocation frame
 localraw_args=getArgs(frame)

 --If no map is supplied, return.
 ifnotraw_args['pushpin_map']then
 return
 end

 -- Now get arguments from just the invocation frame
 localframe_args=getArgs(frame,{frameOnly=true})

 -- parsed_args will have the resulting merged parameters 
 localparsed_args={}

 -- Default to using wikidata coodinates if no other coordiantes supplied. 
 ifraw_args.useWikidata==nilthen
 parsed_args.useWikidata=true
 else
 parsed_args.useWikidata=raw_args.useWikidata
 end

 -- Parse the arguments
 parsed_args[1]=raw_args['pushpin_map']
 parsed_args.float=frame_args.floator'center'
 parsed_args.border=frame_args.borderor'infobox'
 parsed_args.default_width=frame_args.default_width
 parsed_args.max_width=frame_args.max_width
 parsed_args.coordinates=raw_args['coordinates']
 parsed_args.caption=raw_args['pushpin_caption']
 parsed_args.relief=raw_args['pushpin_relief']
 parsed_args.label=raw_args['pushpin_label']
 parsed_args.label_size=raw_args['pushpin_label_size']
 parsed_args.position=raw_args['pushpin_label_position']
 parsed_args.mark=raw_args['pushpin_mark']
 parsed_args.marksize=raw_args['pushpin_mark_size']
 parsed_args.alt=raw_args['pushpin_alt']
 parsed_args.background=raw_args['pushpin_background']
 parsed_args.width=raw_args['pushpin_map_size']

 localmap={}
 localcaption_list={}

 formapnameinstring.gmatch(parsed_args[1],'[^#]+')do
 map[#map+1]=p.getMapParams(mw.ustring.gsub(mapname,'^%s*(.-)%s*$','%1'),frame)
 end

 ifparsed_args['caption']then
 forcaptioninmw.text.gsplit(parsed_args['caption'],'##',true)do
 caption_list[#caption_list+1]=caption
 end
 end

 if#map==1then
 map=map[1]
 ifnotparsed_args.captionthen
 parsed_args.caption='Location within '..map('name')
 end
 end

 iftype(map)=='table'then
 mw.log('----')
 mw.logObject(map)
 if#caption_list>#mapthen
 error(string.format('%d captions were provided, but only %d maps were provided',#caption_list,#map))
 elseifnotparsed_args.captionthen
 -- Set a default caption for each of the multiple maps
 fori=1,#mapdo
 caption_list[#caption_list+1]='Location within '..map[i]('name')
 end
 end

 localoutputs={}
 parsed_args.autoSwitcherLabel=true
 fork,vinipairs(map)do
 parsed_args.caption=caption_list[k]
 outputs[k]=p.main(frame,parsed_args,v)
 end
 return'<div class="switcher-container">'..table.concat(outputs)..'</div>'
 else
 returnp.top(frame,parsed_args,map)..tostring(p.mark(frame,parsed_args,map))..p.bottom(frame,parsed_args,map)
 end
 end

 functionp.main(frame,args,map)
 localcaption_list={}
 ifnotargsthen
 args=getArgs(frame,{wrappers='Template:Location map',valueFunc=p.valueFunc})
 end
 ifargs.useWikidata==nilthen
 args.useWikidata=true
 end
 ifnotmapthen
 ifargs[1]then
 map={}
 formapnameinstring.gmatch(args[1],'[^#]+')do
 map[#map+1]=p.getMapParams(mw.ustring.gsub(mapname,'^%s*(.-)%s*$','%1'),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=p.getMapParams('World',frame)
 end
 end
 iftype(map)=='table'then
 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]
 outputs[k]=p.main(frame,args,v)
 end
 return'<div class="switcher-container">'..table.concat(outputs)..'</div>'
 else
 returnp.top(frame,args,map)..tostring(p.mark(frame,args,map))..p.bottom(frame,args,map)
 end
 end

 returnp

AltStyle によって変換されたページ (->オリジナル) /