makeTextItem(result, row, shape, align, tlink, row.labelText, 0)
else
makeTextItem(result, row, shape, align, '', '<b>'..row.dotTag..'</b>', 1)
makeTextItem(result, row, shape, align, tlink, row.dotTag, 2) -- tag is ouside the dot
end
end
else
if (row.labelText and row.labelText~='') then -- just the label. No tag
makeTextItem(result, row, shape, align, tlink, row.labelText, 0)
end
end
end
if tlink and tlink~='' then
table.insert(result,makeLinkBox(row.gridx, row.gridy,w+3,row.dotTag..' '..row.title,tlink))
end
return table.concat(result)
end  
local function getmapframecontent(args,use)
local result, comma={},''
if use=='basemap' then table.insert(result,'[') end
if args['map-data-inverse'] then
table.insert(result,'{ "type": "ExternalData", "service": "geomask", "ids": "'..args['map-data-inverse']..'", "properties": {')
table.insert(result,' "title": "Wikidata: '..args['map-data-inverse']..'", "fill": "#555555", "fill-opacity": 0.1, "stroke": "#555555", "stroke-width": 1, "stroke-opacity": 0.5 } }')
comma=', '
end
if args['map-data-heavy'] then
table.insert(result,comma..'{ "type": "ExternalData", "service": "geoline", "ids": "'..args['map-data-heavy']..'", "properties": {' )
table.insert(result,'"stroke": "#000000", "stroke-width": 9, "stroke-opacity": 0.1 } }')
comma=', '
end
if args['map-data-light'] then
table.insert(result,comma..' { "type": "ExternalData", "service": "geoline", "ids": "'..args['map-data-light']..'", "properties": {' )
table.insert(result,'"stroke": "#000000", "stroke-width": 3, "stroke-opacity": 0.1 } }' )
comma=', '
end
if args['map-data'] then
table.insert(result,comma..'{ "type": "ExternalData", "service": "geoline", "ids": "'..args['map-data']..'", "properties": {' )
table.insert(result,'"title": "'..(args['map-data-text'] or '')..'", "stroke": "#000000", "stroke-width": 6, "stroke-opacity": 0.1 } }' )
end
if use=='basemap' then table.insert(result,']') end
return table.concat(result)
end  
--eg | minilocator=filename,bottom ,132px153px, 38%,60%,
local function makeLocatorMap (args, result)
local miniFile,pos,itemlist,miniW,miniH, miniX,miniY,miniBox, miniBH
if args['mini-locator'] then
pos,miniFile=extractItem(args['mini-locator']) -- first item is filename, in quotes if it includes commas
itemlist=splitItem(pos,5) -- put items in a table filename removed, position,WpxHpx, x%y%,box
pos=itemlist[2] or ''
miniW,miniH=getsize(itemlist[3])
miniX=tonumber(string.match(itemlist[4] or '0','[%d]+'))*miniW/100
miniY=tonumber(string.match(itemlist[5] or '0','[%d]+'))*miniH/100
miniBox=tonumber(string.match(itemlist[6] or '0','[%d]+'))
miniBox=miniBox*miniW/100
miniBH=miniBox * maplist.height/maplist.width
elseif args['mini-file'] then
miniFile = args['mini-file']
pos=string.lower(args.minimap or '')
if pos=='file' then pos='' end
miniW,miniH = tonumber(args['mini-width'] or 60), tonumber(args['mini-height'] or 60) -- find top corner of locator
miniBox,miniBH=tonumber(args['minimap-boxwidth'] or '0'),0 -- firm up pos offsets for dot (with % or not) and boxsize if any,
miniX, miniY=args['minipog-gx'],args['minipog-gy']
if not miniX then miniX=tonumber(args['minipog-x'] or '0') else miniX=tonumber(miniX)*tonumber(miniW)/100 end
if not miniY then miniY=tonumber(args['minipog-y'] or '0') else miniY=tonumber(miniY)*tonumber(miniH)/100 end
if args['minipog-gx'] then miniBox=miniBox*miniW/100 end
miniBH=miniBox * maplist.height/maplist.width
else return end
local miniTop,miniLeft=0,1
if not string.find(pos,'top') then --only use top , as link box is in top or put bottom or
miniTop=maplist.height+2-miniH
if string.find(pos,'') then
miniTop=miniTop-15 -- to avoid (c) line
miniLeft=maplist.width-1-miniW
end
end
table.insert(result,'<div></div>')
if miniX and miniX>0 then
if args['minipog-y'] then miniY=miniY/1.04 end
if args['minipog-x'] then miniX=miniX/1.04 end
if miniBox<1 then
table.insert(result,'<div></div>')
else
table.insert(result,'<div></div>')
end
end
end  
local function makeArcText(args,result,nval)
local items, itemlist='',{}
local arcText=''
if args['arc'..nval] then
items=convertCoords (args['arc'..nval])
items,arcText=extractItem(items) -- first item is text, in quotes if it includes commas
itemlist=splitItem(items,9) -- put items in a table: text, lat,lon,size,color,angle,gap,radius,ellipse
if itemlist[4]=='' then itemlist[4]='12' end
itemlist[4]=string.match((itemlist[4] or '12'),"[%.%-?%d]+")
if itemlist[5]=='' then itemlist[5]='grey' end
itemlist[6]=string.match((itemlist[6] or '0'),"[%.%-?%d]+")
itemlist[7]=string.match((itemlist[7] or '0'),"[%.%-?%d]+")
itemlist[8]=string.match((itemlist[8] or '0'),"[%.%-?%d]+")
end
if args['arc-coord'..nval] then
local itemTab=splitItem(convertCoordsTrad (args['arc-coord'..nval]),2)
maplist.lat=tonumber(string.match(itemTab[1],"[%.%-?%d]+"))
maplist.lon=tonumber(string.match(itemTab[2],"[%.%-?%d]+"))
else
maplist.lat=tonumber(string.match(args['arc-lat'..nval] or itemlist[2] or '0',"[%.%-?%d]+"))
maplist.lon=tonumber(string.match(args['arc-lon'..nval] or itemlist[3] or '0',"[%.%-?%d]+"))
end
local arcX,arcY=maptogrid(maplist,6)
arcText = args['arc-text'..nval] or arcText
local fontSize =tonumber(args['arc-text-size'..nval] or itemlist[4] or '12')
local textColor=getColor(string.gsub(args['arc-text-color'..nval] or itemlist[5] or 'grey','[%s]+','') )
local arcAngle= tonumber((args['arc-angle'..nval]) or (itemlist[6]) or '45')-90
local arcRadius =tonumber(args['arc-radius'..nval] or itemlist[8] or '0.05')
local arcGap = tonumber(args['arc-gap'..nval] or itemlist[7] or '1')* ( ( math.sin(8-math.rad(arcRadius))^8 )+0.4 )*( ( fontSize+6 )/15 )
arcRadius=450*arcRadius*0.75
local ellipseFactor=tonumber(args['ellipse-factor'..nval] or itemlist[9] or '1')
local arcRotate =arcAngle+90
if arcGap<0 then arcRotate=arcAngle-90 end
local latF=arcY - fontSize + (0-(math.sin(math.rad(arcAngle))) * arcRadius)
local lonF=arcX - fontSize +(0-(math.cos(math.rad(arcAngle))) * arcRadius)  
local step=1
for codepoint in mw.ustring.gcodepoint( arcText ) do -- block step=1,#arcText do
table.insert(result,'<div>'..mw.ustring.char(codepoint)..'</div>')
step=step+1
end
end  
local function makeFullscreenItem (itemtitle,itemdescription,lat,lon,group,itemcolor)
local item={}
itemdescription=stripdivs(itemdescription or '')
local templon=lon
if lon > 180 then templon=lon-360 end --for hemisphere+ or -1 dots
if lon < -180 then templon=lon+360 end -- use 'real' coordinates for geohack label, while retaining shifted coords for plot
if itemcolor=='transparent' then itemcolor='white' end
itemcolor=getColor(itemcolor) -- ensure no opacity, which breaks maplink
if string.find(itemcolor,'#')==1 and #itemcolor>7 then itemcolor=string.sub(itemcolor,1,7) end
table.insert(item, '{ "type": "Feature", "properties": {')
table.insert(item, ' "title": "'..itemtitle..'",')
table.insert(item, ' "description": "'..itemdescription)
table.insert(item, ' (table.insert(item, '_dim:2000 '..tostring(lat)..','..tostring(templon)..')",')
table.insert(item, ' "marker-symbol": "-number-'..string.gsub(group,'%W','')..'", "marker-size": "medium", "marker-color": "'..itemcolor..'" },')
table.insert(item, ' "geometry": {"type": "Point", "coordinates": ['..tostring(lon)..','..tostring(lat)..'] } }')
return table.concat(item)
end  
local function makeLegendBox(result,args)
local legend ={}
local line,count, max,1,8
local item
line,item=extractItem(args.legendBox or '')
local a='' for c in item:gmatch('.') do a=a..(c:gsub('%^','
') or c) end
legend.Text = a -- convert hats to line breaks
line=splitItem(line,6) -- (text, size, poition,background color, text/outline color, param options)
legend.Size=line[2] or '150px80px1px'
legend.Pos=line[3] or '10px10px'
legend.Background=line[4] or 'beigeground'
legend.Color=line[5] or 'darkbrown'
legend.Param= line[6] or ''
local argnum,legendCount,title,1,0
if (legend.Text and legend.Text~='') then
titleHeight=15+(13.4*(select(2, string.gsub(legend.Text,"
", ""))))
end