(Translated by https://www.hiragana.jp/)
模組:Infobox mapframe - 维基百科,自由的百科全书

ぐみ:Infobox mapframe

文档图示 かたぎ块文档[查看] [编辑] [历史] [きよしじょ缓存]

用法ようほう

该模块可生成せいせい适合しんいきかまちてきmapframe,编者ただ需输いれ少量しょうりょうしんじいきそく

通用つうよう用法ようほう

ただ使用しようばん{{Infobox mapframe}},按照其文档进ぎょう操作そうさそく。该模块也以导いれいた另一个Lua块中。

しんいきかまちちゅうてき动地图

しめせれい编辑: Template:Infobox prisonTemplate:Infobox prison/doc

编辑しんいきかまちばんある其沙盒)。

ざいしんいきかまちちゅう添加てんか类似以下いかしめせれいてきぎょうはた数字すうじ4ある97いたり99がえ换为适当てき数字すうじ具体ぐたい数字すうじ决于やめゆう多少たしょう其他图像あるdataさんすう

如果ざいしんいきかまち顶部附近ふきん 如果放置ほうちざいしんいきかまち底部ていぶある底部ていぶ附近ふきん
| image4     = {{#invoke:Infobox mapframe|auto}}
| caption4   = {{#invoke:Infobox mapframe|autocaption}}
| header97   = {{#if:{{{mapframe|}}}|图}}
| data98     = {{#invoke:Infobox mapframe|auto}}
| data99     = {{#invoke:Infobox mapframe|autocaption}}

如果ばんちゅう使用しようりょう{{#invoke:Check for unknown parameters}},请向其添加てんか以下いかさんすう

|mapframe|mapframe-area_km2|mapframe-area_mi2|mapframe-caption|mapframe-coord|mapframe-coordinates|mapframe-custom|mapframe-frame-coord|mapframe-frame-coordinates|mapframe-frame-height|mapframe-frame-width|mapframe-geomask|mapframe-geomask-fill|mapframe-geomask-fill-opacity|mapframe-geomask-stroke-color|mapframe-geomask-stroke-colour|mapframe-geomask-stroke-width|mapframe-height|mapframe-id|mapframe-length_km|mapframe-length_mi|mapframe-marker|mapframe-marker-color|mapframe-marker-colour|mapframe-point|mapframe-shape|mapframe-shape-fill|mapframe-shape-fill-opacity|mapframe-stroke-color|mapframe-stroke-colour|mapframe-stroke-width|mapframe-switcher|mapframe-width|mapframe-wikidata|mapframe-zoom

完成かんせい操作そうさきさきばんそく使用しよう上述じょうじゅつさんすう。 这些まいり数也かずや以在前述ぜんじゅつ#invoke调用ちゅう指定していだま认值,れい{{#invoke:Infobox mapframe|auto|mapframe-marker=library}}表示ひょうじだま使用しよう“library”图标,じょこうばん传递不同ふどうてき值。

  • だま认情况下图是关闭てき,这意味いみじょざいばん调用时出现|mapframe=yesいや则地图不かい显示。ようだま认打开地图,ざい上述じょうじゅつ#invoke调用ちゅう添加てんか|onByDefault=yes——这意味いみじょばん调用ちゅう包含ほうがん|mapframe=noいや则将显示图。onByDefault也可以设おけ为一个条件じょうけんれい如:|onByDefault={{#if:{{pushpin_map|}}|no|yes}}
  • 更新こうしん板文いたぶん档中てきまいりすう说明。使用しよう{{Infobox mapframe/doc/parameters}}つう过以|まいりすうめい=值てき形式けいしき指定していだま认值(如果ざい#invoke调用ちゅう使用しようりょうだま认值)。以下いかだま认输
延伸えんしん內容
  • 基本きほんさんすう
    • mapframe指定していyesあるno以显しめせある隐藏图,くつがえ盖默认值。だま认:no
    • mapframe-caption图说あかりだま认: 空白くうはくある如果设置りょう|mapframe-geomask=,则:“ざい<さえぎ罩标签>てき位置いち”)
    • mapframe-custom使用しようてい义地图代替だいたい动地图框。请使用しよう{{maplink}}ばんある其他生成せいせい图框てきばんある图像ぶん件名けんめいしょう。如果使用しようきさき续的mapframeさんすうはたゆるがせりゃくだま认:指定してい
    • mapframe-idあるidあるqidよう使用しようてき维基すうすえ项QID。だま认:とうぜん页面对应すうすえ
    • mapframe-coordinatesあるmapframe-coordあるcoordinatesあるcoord指定していてきすわ标,而不维基すうすえじょうてきすわ标。使用しよう{{Coord}}ばんれい如:|coord={{Coord|12.34|N|56.78}}だま认:维基すうすえてきすわ
    • mapframe-wikidataとう设置りょう|coord=时,设为yes以显しめせ维基すうすえちゅうてきめん/线特せい(如果ゆう)。だま认: 指定してい
  • てい义显しめせ哪些とくせい
    • mapframe-point — 设为none时关闭点标记てき显示。设为on强制きょうせい显示てん标记。だま认: 指定してい
    • mapframe-line — 设为none时关闭线とくせいてき显示。だま认: 指定してい
    • mapframe-shape — 设为none时关闭面とくせいてき显示。设为inverse使用しようはん转形じょう(geomask)代替だいたいつね规形じょうだま认: 指定してい
    • mapframe-geomaskようさくさえぎ罩的维基すうすえ项(さえぎ罩边界外かいげてき区域くいき变暗)。以是特定とくていてき维基すうすえ项(QID),あるかずすえ项的属性ぞくせいれい如,P17表示ひょうじ国家こっか (P17)P131表示ひょうじ所在しょざい行政ぎょうせい领土实体 (P131))。だま认: 指定してい
    • mapframe-switcher — 设置为autoあるgeomasksあるzooms,以启ようきり换多个地图框てきこうのう(以Template:Switcherてき风格)。だま认: 指定してい
      • auto — 以维基数きすうすえ项的位置いち (P276)所在しょざい行政ぎょうせい领土实体 (P131)こえしょう为遮罩进ぎょうきり换,递归搜索そうさくれい如,すうすえ项的城市じょうし、该城いくわしゅう以及该州てき国家こっか
      • geomasksざいmapframe-geomaskさんすうちゅうてき维基すうすえ项(QID)れつひょう(以逗ごうぶんへだた指定していてきさえぎ罩之间切换。
      • zoomsざい“zoomed in”/“zoomed midway”/“zoomed out”间切换,其中“zoomed in”为默认缩放(最小さいしょう值为3),“zoomed out”为1,而“zoomed midway”为平均へいきん值。
  • 其他选参すう
    • mapframe-frame-widthあるmapframe-widthかまち宽度。だま认:270
    • mapframe-frame-heightあるmapframe-heightかまち高度こうどだま认:200
    • mapframe-shape-fillめんとくせいてきはまたかし颜色。だま认:#606060
    • mapframe-shape-fill-opacityめんとくせいはまたかしてき不透明ふとうめいすう值介于01これ间。だま认:0.5
    • mapframe-stroke-colorあるmapframe-stroke-colour — 线特せいめんとくせい轮廓てき颜色。だま认:#ff0000
    • mapframe-stroke-width — 线特せいめんとくせい轮廓てき细。だま认:5
    • mapframe-markerよう于坐标点标记てき符号ふごう具体ぐたい选项さんmw:Help:Extension:Kartographer/Iconsだま认: 指定していそくblank)
      • 也可以设おけblank以覆盖默认标记符ごう
    • mapframe-marker-colorあるmapframe-marker-colourてん标记てき背景はいけい颜色。だま认:#5E74F3
    • mapframe-geomask-stroke-colorあるmapframe-geomask-stroke-colourさえぎ罩轮くるわてき颜色。だま认:#555555
    • mapframe-geomask-stroke-widthさえぎ罩轮くるわてき细。だま认:2
    • mapframe-geomask-fillさえぎ罩外区域くいきてきはまたかし颜色。だま认:#606060
    • mapframe-geomask-fill-opacityさえぎ罩外区域くいきはまたかしてき不透明ふとうめいすう值介于01これ间。だま认:0.5
    • mapframe-zoom — 设置缩放级别,从“1”(ぜんたま图)いた “18”(最大さいだい级别),よう于无ほうすえ对象长度あるめん积自动确てい缩放级别てきじょう况。だま认:10
    • mapframe-length_kmあるmapframe-length_miあるmapframe-area_km2あるmapframe-area_mi2どおり过输にゅう对象てき长度(以公さとある英里えり为单あるめん积(以平いたいらかた公里くりある平方ひらかた英里えり为单らい确定缩放级别。だま认:指定してい
    • mapframe-frame-coordinatesあるmapframe-frame-coord图初はじめ位置いちてき备用すわ标,使用しよう使用しよう{{coord}}ばんだま认:衍生项目すわ
  • かたぎいたすうすえ部分ぶぶん插入そうにゅう下面かめんてきしめせれいらい更新こうしん
延伸えんしん內容

无描じゅつ

ばんさんすう

さんすう描述类型じょう
Show mapframe mapmapframe

Specify yes or no to show or hide the map, overriding the default

だま认值
no
しめせれい
yes
くし推荐
Mapframe captionmapframe-caption

Caption for the map. If mapframe-geomask is set, then the default is "Location in <<geomask's label>>"

くし
Custom mapframemapframe-custom

Use a custom map instead of the automatic mapframe. Specify either a {{maplink}} template, or another template that generates a mapframe map, or an image name. If used, other mapframe parameters will be ignored.

ばん
Mapframe Wikidata itemmapframe-id id qid

Id (Q-number) of Wikidata item to use.

だま认值
(item for current page)
くし
Mapframe coordinates mapframe-coordinates mapframe-coord coordinates coord

Coordinates to use, instead of any on Wikidata. Use the {{Coord}} template.

だま认值
(coordinates from Wikidata)
しめせれい
{{Coord|12.34|N|56.78|E}}
ばん
Mapframe shapes from Wikidatamapframe-wikidata

et to yes to show shape/line features from the wikidata item, if any, when coordinates are specified by parameter

しめせれい
yes
くし
Mapframe point featuremapframe-point

Override display of mapframe point feature. Turn off display of point feature by setting to "none". Force point marker to be displayed by setting to "on"

くし
Mapframe shape featuremapframe-shape

Override display of mapframe shape feature. Turn off by setting to "none". Use an inverse shape (geomask) instead of a regular shape by setting to "inverse"

くし
Mapframe widthmapframe-frame-width mapframe-width

Frame width in pixels

だま认值
270
数字すうじ
Mapframe heightmapframe-frame-height mapframe-height

Frame height in pixels

だま认值
200
数字すうじ
Mapframe shape fillmapframe-shape-fill

Color used to fill shape features

だま认值
#606060
くし
Mapframe shape fill opacitymapframe-shape-fill-opacity

Opacity level of shape fill, a number between 0 and 1

だま认值
0.5
数字すうじ
Mapframe stroke colormapframe-stroke-color mapframe-stroke-colour

Color of line features, and outlines of shape features

だま认值
#ff0000
くし
Mapframe stroke widthmapframe-stroke-width

Width of line features, and outlines of shape features

だま认值
5
数字すうじ
Mapframe markermapframe-marker

Marker symbol to use for coordinates; see [[mw:Help:Extension:Kartographer/Icons]] for options

しめせれい
museum
くし
Mapframe marker colormapframe-marker-color mapframe-marker-colour

Background color for the marker

だま认值
#5E74F3
くし
Mapframe geomaskmapframe-geomask

Wikidata item to use as a geomask (everything outside the boundary is shaded darker). Can either be a specific Wikidata item (Q-number), or a property that specifies the item to use (e.g. P17 for country, or P131 for located in the administrative territorial entity)

しめせれい
Q100
页面名称めいしょう
Mapframe geomask stroke colormapframe-geomask-stroke-color mapframe-geomask-stroke-colour

Color of outline of geomask shape

だま认值
#555555
くし
Mapframe geomask stroke widthmapframe-geomask-stroke-width

Width of outline of geomask shape

だま认值
2
数字すうじ
Mapframe geomask fillmapframe-geomask-fill

Color used to fill outside geomask features

だま认值
#606060
くし
Mapframe geomask fill opacitymapframe-geomask-fill-opacity

Opacity level of fill outside geomask features, a number between 0 and 1

だま认值
0.5
数字すうじ
Mapframe zoommapframe-zoom

Set the zoom level, from "1" to "18", to used if the zoom level cannot be determined automatically from object length or area

だま认值
10
しめせれい
12
数字すうじ
Mapframe length (km)mapframe-length_km

Object length in kilometres, for automatically determining zoom level. ONLY use ONE of the available parameters for length or area

数字すうじ
Mapframe length (mi)mapframe-length_mi

Object length in miles, for automatically determining zoom level. ONLY use ONE of the available parameters for length or area

数字すうじ
Mapframe area (km^2)mapframe-area_km2

Object arean square kilometres, for automatically determining zoom level. ONLY use ONE of the available parameters for length or area

数字すうじ
Mapframe area (mi^2)mapframe-area_mi2

Object area in square miles, for automatically determining zoom level. ONLY use ONE of the available parameters for length or area

数字すうじ
Mapframe frame coordinatesmapframe-frame-coordinates mapframe-frame-coord

Alternate latitude and longitude coordinates for initial placement of map, using {{coord}}

しめせれい
{{Coord|12.35|N|56.71|E}}
ばん
Mapframe switchermapframe-switcher

Set to "auto" or "geomasks" or "zooms" to enable Template:Switcher-style switching between multiple mapframes. IF SET TO auto – switch geomasks found in location (P276) and located in the administrative territorial entity (P131) statements on the page's Wikidata item, searching recursively. E.g. an item's city, that city's state, and that state's country. IF SET TO geomasks – switch between the geomasks specified as a comma-separated list of Wikidata items (Q-numbers) in the mapframe-geomask parameter. IF SET TO zooms – switch between "zoomed in"/"zoomed midway"/"zoomed out", where "zoomed in" is the default zoom (with a minimum of 3), "zoomed out" is 1, and "zoomed midway" is the average.

くし

まいり

local mf = require('Module:Mapframe')
local getArgs = require('Module:Arguments').getArgs
local yesno = require('Module:Yesno')
local infoboxImage = require('Module:InfoboxImage').InfoboxImage

-- Defaults
local DEFAULT_FRAME_WIDTH = "270"
local DEFAULT_FRAME_HEIGHT = "200"
local DEFAULT_ZOOM = 10
local DEFAULT_GEOMASK_STROKE_WIDTH = "1"
local DEFAULT_GEOMASK_STROKE_COLOR = "#777777"
local DEFAULT_GEOMASK_FILL = "#888888"
local DEFAULT_GEOMASK_FILL_OPACITY = "0.5"
local DEFAULT_SHAPE_STROKE_WIDTH = "3"
local DEFAULT_SHAPE_STROKE_COLOR = "#FF0000"
local DEFAULT_SHAPE_FILL = "#606060"
local DEFAULT_SHAPE_FILL_OPACITY = "0.5"
local DEFAULT_LINE_STROKE_WIDTH = "5"
local DEFAULT_LINE_STROKE_COLOR = "#FF0000"
local DEFAULT_MARKER_COLOR = "#5E74F3"


-- Trim whitespace from args, and remove empty args
function trimArgs(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 getBestStatement(item_id, property_id)
	if not(item_id) or not(mw.wikibase.isValidEntityId(item_id)) or not(mw.wikibase.entityExists(item_id)) then
		return false
	end
	local statements = mw.wikibase.getBestStatements(item_id, property_id)
	if not statements or #statements == 0 then
		return false
	end
	local hasNoValue = ( statements[1].mainsnak and statements[1].mainsnak.snaktype == 'novalue' )
	if hasNoValue then
		return false
	end
	return statements[1]
end

function hasWikidataProperty(item_id, property_id)
	return getBestStatement(item_id, property_id) and true or false
end

function getStatementValue(statement)
	return statement and statement.mainsnak and statement.mainsnak.datavalue and statement.mainsnak.datavalue.value or nil
end

function relatedEntity(item_id, property_id)
	local value = getStatementValue( getBestStatement(item_id, property_id) )
	return value and value.id or false
end

function idType(id)
	if not id then 
		return nil
	elseif mw.ustring.match(id, "[Pp]%d+") then
		return "property"
	elseif mw.ustring.match(id, "[Qq]%d+") then
		return "item"
	else
		return nil
	end
end

function getZoom(value, unit)
	local length_km
	if unit == 'km' then
		length_km = tonumber(value)
	elseif unit == 'mi' then
		length_km = tonumber(value)*1.609344
	elseif unit == 'km2' then
		length_km = math.sqrt(tonumber(value))
	elseif unit == 'mi2' then
		length_km = math.sqrt(tonumber(value))*1.609344
	end
	-- max for zoom 2 is 6400km, for zoom 3 is 3200km, for zoom 4 is 1600km, etc
	local zoom = math.floor(8 - (math.log10(length_km) - 2)/(math.log10(2)))
	-- limit to values below 17
	zoom = math.min(17, zoom)
	-- take off 1 when calculated from area, to account for unusual shapes
	if unit == 'km2' or unit == 'mi2' then
		zoom = zoom - 1
	end
	-- minimum value is 1
	return math.max(1, zoom)
end

function shouldAutoRun(frame)
	-- Check if should be running
	local explicitlyOn = yesno(mw.text.trim(frame.getParent(frame).args.mapframe or "")) -- true of false or nil
	local onByDefault = (explicitlyOn == nil) and yesno(mw.text.trim(frame.args.onByDefault or ""), false) -- true or false
	return explicitlyOn or onByDefault
end

function argsFromAuto(frame)
	-- Get args from the frame (invoke call) and the parent (template call).
	-- Frame arguments are default values which are overridden by parent values
	-- when both are present
	local args = getArgs(frame, {parentFirst = true})
	
	-- Discard args not prefixed with "mapframe-", remove that prefix from those that remain
	local fixedArgs = {}
	for name, val in pairs(args) do
		local fixedName = string.match(name, "^mapframe%-(.+)$" )
		if fixedName then
			fixedArgs[fixedName] = val
		-- allow coord, coordinates, etc to be unprefixed
		elseif name == "coordinates" or name == "coord" or name == "coordinate" and not fixedArgs.coord then
			fixedArgs.coord = val
		-- allow id, qid to be unprefixed, map to id (if not already present)
		elseif name == "id" or name == "qid" and not fixedArgs.id then
			fixedArgs.id = val
		end
	end
	return fixedArgs
end

local p = {}

p.autocaption = function(frame)
	if not shouldAutoRun(frame) then return "" end
	local args = argsFromAuto(frame)
	if args.caption then
		return args.caption
	elseif args.switcher then 
		return ""
	end
	local maskItem
	local maskType = idType(args.geomask)
	if maskType == 'item' then
		maskItem = args.geomask
	elseif maskType == "property" then
		maskItem = relatedEntity(args.id or mw.wikibase.getEntityIdForCurrentPage(), args.geomask)
	end
	local maskItemLabel = maskItem and mw.wikibase.getLabel( maskItem )
	return maskItemLabel and "ざい" .. maskItemLabel .. "てき位置いち" or ""
end

function parseCustomWikitext(customWikitext)
	-- infoboxImage will format an image if given wikitext containing an
	-- image, or else pass through the wikitext unmodified
	return infoboxImage({
		args = {
			image = customWikitext
		}
	})
end

p.auto = function(frame)
	if not shouldAutoRun(frame) then return "" end
	local args = argsFromAuto(frame)
	if args.custom then
		return frame:preprocess(parseCustomWikitext(args.custom))
	end
	local mapframe = p._main(args)
	return frame:preprocess(mapframe)
end

p.main = function(frame)
	local parent = frame.getParent(frame)
	local parentArgs = parent.args
	local mapframe = p._main(parentArgs)
	return frame:preprocess(mapframe)
end

p._main = function(_config)
	-- `config` is the args passed to this module
	local config = trimArgs(_config)
	
	-- Require wikidata item, or specified coords
	local wikidataId = config.id or mw.wikibase.getEntityIdForCurrentPage()
	if not(wikidataId) and not(config.coord) then
		return ''
	end

	-- Require coords (specified or from wikidata), so that map will be centred somewhere
	-- (P625 = coordinate location)
	local hasCoordinates = hasWikidataProperty(wikidataId, 'P625') or config.coordinates or config.coord
	if not hasCoordinates then  
		return ''
	end

	-- `args` is the arguments which will be passed to the mapframe module
	local args = {}

	-- Some defaults/overrides for infobox presentation
	args.display = "inline"
	args.frame = "yes"
	args.plain = "yes"
	args["frame-width"]  = config["frame-width"] or config.width or DEFAULT_FRAME_WIDTH
	args["frame-height"] = config["frame-height"] or config.height or DEFAULT_FRAME_HEIGHT
	args["frame-align"]  = "center"

	args["frame-coord"] = config["frame-coordinates"] or config["frame-coord"] or ""
	-- Note: config["coordinates"] or config["coord"] should not be used for the alignment of the frame;
	-- see talk page ( https://en.wikipedia.org/wiki/Special:Diff/876492931 )

	-- deprecated lat and long parameters
	args["frame-lat"]    = config["frame-lat"] or config["frame-latitude"] or ""
	args["frame-long"]   = config["frame-long"] or config["frame-longitude"] or ""

	-- Calculate zoom from length or area (converted to km or km2)
	if config.length_km then
		args.zoom = getZoom(config.length_km, 'km')
	elseif config.length_mi then
		args.zoom = getZoom(config.length_mi, 'mi')
	elseif config.area_km2 then
		args.zoom = getZoom(config.area_km2, 'km2')
	elseif config.area_mi2 then
		args.zoom = getZoom(config.area_mi2, 'mi2')
	else
		args.zoom = config.zoom or DEFAULT_ZOOM
	end

	-- Conditionals: whether point, geomask should be shown
	local hasOsmRelationId = hasWikidataProperty(wikidataId, 'P402') -- P402 is OSM relation ID
	local shouldShowPointMarker;
	if config.point == "on" then
		shouldShowPointMarker = true 
	elseif config.point == "none" then
		shouldShowPointMarker = false
	else
		shouldShowPointMarker = not(hasOsmRelationId) or (config.marker and config.marker ~= 'none') or (config.coordinates or config.coord)
	end
	local shouldShowShape = config.shape ~= 'none'
	local shapeType = config.shape == 'inverse' and 'shape-inverse' or 'shape'
	local shouldShowLine = config.line ~= 'none'
	local maskItem
	local useWikidata = wikidataId and true or false -- Use shapes/lines based on wikidata id, if there is one
	-- But do not use wikidata when local coords are specified (and not turned off), unless explicitly set
	if useWikidata and config.coord and shouldShowPointMarker then
		useWikidata = config.wikidata and true or false
	end
	
	-- Switcher
	if config.switcher == "zooms" then
		-- switching between zoom levels
		local maxZoom = math.max(tonumber(args.zoom), 3) -- what zoom would have otherwise been (if 3 or more, otherwise 3)
		local minZoom = 1 -- completely zoomed out
		local midZoom = math.floor((maxZoom + minZoom)/2) -- midway between maxn and min
		args.switch = "zoomed in, zoomed midway, zoomed out"
		args.zoom = string.format("SWITCH:%d,%d,%d", maxZoom, midZoom, minZoom)
	elseif config.switcher == "auto" then
		-- switching between P276 and P131 areas with recursive lookup, e.g. item's city,
		-- that city's state, and that state's country
		args.zoom = nil -- let kartographer determine the zoom
		local maskLabels = {}
		local maskItems = {}
		local maskItemId = relatedEntity(wikidataId, "P276") or  relatedEntity(wikidataId, "P131") 
		local maskLabel = mw.wikibase.getLabel(maskItemId)
		while maskItemId and maskLabel and mw.text.trim(maskLabel) ~= "" do
			table.insert(maskLabels, maskLabel)
			table.insert(maskItems, maskItemId)
			maskItemId = maskItemId and relatedEntity(maskItemId, "P131")
			maskLabel = maskItemId and mw.wikibase.getLabel(maskItemId)
		end
		if #maskLabels > 1 then
			args.switch = table.concat(maskLabels, "###")
			maskItem = "SWITCH:" .. table.concat(maskItems, ",")
		elseif #maskLabels == 1 then
			maskItem = maskItemId[1]
		end
	elseif config.switcher == "geomasks" and config.geomask then
		-- switching between items in geomask parameter
		args.zoom = nil -- let kartographer determine the zoom
		local separator = (mw.ustring.find(config.geomask, "###", 0, true ) and "###") or
			(mw.ustring.find(config.geomask, ";", 0, true ) and ";") or ","
		local pattern = "%s*"..separator.."%s*"
		local maskItems = mw.text.split(mw.ustring.gsub(config.geomask, "SWITCH:", ""), pattern)
		local maskLabels = {}
		if #maskItems > 1 then
			for i, item in ipairs(maskItems) do
				table.insert(maskLabels, mw.wikibase.getLabel(item))
			end
			args.switch = table.concat(maskLabels, "###")
			maskItem = "SWITCH:" .. table.concat(maskItems, ",")
		end
	end
	
	-- resolve geomask item id (if not using geomask switcher)
	if not maskItem then --  
		local maskType = idType(config.geomask)
		if maskType == 'item' then
			maskItem = config.geomask
		elseif maskType == "property" then
			maskItem = relatedEntity(wikidataId, config.geomask)
		end
	end
	
	-- Keep track of arg numbering
	local argNumber = ''
	local function incrementArgNumber()
		if argNumber == '' then
			argNumber = 2
		else
			argNumber = argNumber + 1
		end
	end
	
	-- Geomask
	if maskItem then
		args["type"..argNumber] = "shape-inverse"
		args["id"..argNumber] = maskItem
		args["stroke-width"..argNumber] = config["geomask-stroke-width"] or DEFAULT_GEOMASK_STROKE_WIDTH
		args["stroke-color"..argNumber] = config["geomask-stroke-color"] or config["geomask-stroke-colour"] or DEFAULT_GEOMASK_STROKE_COLOR
		args["fill"..argNumber] = config["geomask-fill"] or DEFAULT_GEOMASK_FILL
		args["fill-opacity"..argNumber] = config["geomask-fill-opacity"] or DEFAULT_SHAPE_FILL_OPACITY
		-- Let kartographer determine zoom and position, unless it is explicitly set in config
		if not config.zoom and not config.switcher then
			args.zoom = nil
			args["frame-coord"] = nil
			args["frame-lat"] = nil
			args["frame-long"] = nil 	
			local maskArea = getStatementValue( getBestStatement(maskItem, 'P2046') )
		end
		incrementArgNumber()
		-- Hack to fix phab:T255932
		if not args.zoom then
			args["type"..argNumber] = "line"
			args["id"..argNumber] = maskItem
			args["stroke-width"..argNumber] = 0
			incrementArgNumber()
		end
	end
	
	-- Shape (or shape-inverse)
	if useWikidata and shouldShowShape then
		args["type"..argNumber] = shapeType
		if config.id then args["id"..argNumber] = config.id end
		args["stroke-width"..argNumber] = config["shape-stroke-width"] or config["stroke-width"] or DEFAULT_SHAPE_STROKE_WIDTH
		args["stroke-color"..argNumber] = config["shape-stroke-color"] or config["shape-stroke-colour"] or config["stroke-color"] or config["stroke-colour"] or DEFAULT_SHAPE_STROKE_COLOR
		args["fill"..argNumber] = config["shape-fill"] or DEFAULT_SHAPE_FILL
		args["fill-opacity"..argNumber] = config["shape-fill-opacity"] or DEFAULT_SHAPE_FILL_OPACITY
		incrementArgNumber()
	end
	
	-- Line
	if useWikidata and shouldShowLine then
		args["type"..argNumber] = "line"
		if config.id then args["id"..argNumber] = config.id end
		args["stroke-width"..argNumber] = config["line-stroke-width"] or config["stroke-width"] or DEFAULT_LINE_STROKE_WIDTH
		args["stroke-color"..argNumber] = config["line-stroke-color"] or config["line-stroke-colour"] or config["stroke-color"] or config["stroke-colour"] or DEFAULT_LINE_STROKE_COLOR
		incrementArgNumber()
	end

	-- Point
	if shouldShowPointMarker then
		args["type"..argNumber] = "point"
		if config.id then args["id"..argNumber] = config.id end
		if config.coord then args["coord"..argNumber] = config.coord end
		if config.marker then args["marker"..argNumber] = config.marker end
		args["marker-color"..argNumber] = config["marker-color"] or config["marker-colour"] or DEFAULT_MARKER_COLOR
		incrementArgNumber()
	end

	local mapframe = args.switch and mf.multi(args) or mf._main(args)
	local tracking = hasOsmRelationId and '' or '[[Category:Infobox mapframeざい维基すうすえじょうぼつゆうOSM关系标识]]'
	return mapframe .. tracking
end

return p