Modulo:Maplink: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
mNessun oggetto della modifica
m sistemazione stringhe
Riga 4:
local p = {}
local pp = {}
local sstxt = ''{}
 
local function agg(t)
table.insert(txt,t)
end
 
function p.mappa(frame)
Riga 70 ⟶ 75:
end
if (zoom < 0) then zoom = 0 elseif (zoom>18) then zoom = 18 end
local ss = ''
if (cornice == 1) then
ss = agg('\n{| class="wikitable')
if (allinea == 'right') then ss = ss..agg(' floatright') elseif (allinea == 'left') then ss = ss..agg(' foatleft') end
ss = ss..agg('" style="border: 1px solid darkgray;')
if (allinea == 'center') then ss = ss..agg('margin-left: auto; margin-right: auto') end
ss = ss..agg('"\n|-\n|style="width: '..largh..'px;"|')
end
ss = ss..agg('{{Graph:Street map with marks|lat='..centroy..'|lon='..centrox..'|zoom='..zoom..'|width='..largh..'|height='..altezza..'| minimap=0')
ss = ss..agg('|{"lat":'..centroy..',"lon":'..centrox..',"img":"wikirawupload:{{filepath:Mapscaleline.svg|120}}","width":50,"height":8,"offsetX":'..(math.floor(largh/2)-37))
ss = ss..agg(',"offsetY": '..(math.floor(altezza/2)-10)..',"textAlign":"right","textDx":22,"textDy":-2,"textColor": "grey","textFont":"Tahoma","textFontSize":9,"text": "')
local zz = {}
if (math.abs(centroy)<20) then
Riga 91 ⟶ 95:
zz = {'10 000km','5000km','3000km','900km','400km','160km','80km','40km','20km','7km','4km','2km','1km','600m','350m','160m','80m','40m','20m' }
end
ss = ss..agg(zz[zoom+1]..'" }')
for i=1,#pp do
ss = ss..agg(',{"lat":'..pp[i].lat..',"lon":'..pp[i].lon..',"size":"200","color":"'..pp[i].col..'","strokeColor":"","shape":"circle","text":"","textAlign":"left","textBaseline":"middle","textDx":0,"textDy":1,"textFontSize":10}')
ss = ss..agg(',{"lat":'..pp[i].lat..',"lon":'..pp[i].lon..',"shape":"square","size": "0","text":"'..pp[i].num..'","textAlign":"center","textBaseline":"bottom","textDx":0,"textDy":5.5,"textFont":"Arial","textFontSize": 11,"textFontWeight":"bold","textColor":"white"}')
end
ss = ss..agg(' }}\n<div style="text-align:left;font-size:70%;color:grey"><span style="font-size:125%">{{#tag:maplink|\n[ {"type": "FeatureCollection", "features": [')
for i=1,#pp do
if (i>1) then ss = ss..agg(',') end
ss = ss..agg('{"type":"Feature","geometry":{"type":"Point","coordinates":['..pp[i].lon..','..pp[i].lat..'] }')
ss = ss..agg(',"properties":{"title": "'..pp[i].nome..'","description":"","marker-symbol": "-number'..gruppo..'","marker-size":"medium","marker-color":"'..pp[i].col..'" } }')
end
ss = ss..agg('] } ]|zoom='..zoom..'|latitude='..centroy..'|longitude='..centrox..'|text="[Schermo intero]"}}</span>')
ss = ss..agg('<div style="float:right" class="plainlinks nourlexpansion">[https://wikimediafoundation.org/wiki/Maps_Terms_of_Use Wikimedia] | © [https://www.openstreetmap.org/copyright OSM]</div></div>')
 
if (cornice == 1) then
ss = ss..agg('\n|-')
if (not dida == '') then ss = ss..agg('\n|style="font-size:90%"|'..dida) end
if (elenco == '2') then
ss =ss..agg('\n|\n{| width="100%"\n|-\n|width=50% valign=top|<small>')
for i=1,#pp do
ss = ss..agg('{{NumLegenda|'..pp[i].num..'|'..pp[i].col..'|'..pp[i].nome..'}}<br/>')
if (i == math.floor(#pp/2 +0.5)) then ss = ss..agg('</small>\n|width=50% valign=top|<small>') end
end
ss = ss..agg('</small>\n|}')
elseif (elenco == '1') then
if (dida == '') then ss =ss..agg('\n|style="font-size:90%"|') else ss = ss..agg('<br/>') end
ss = ss..agg('<small>')
for i=1,#pp do
ss = ss..agg('{{NumLegenda|'..pp[i].num..'|'..pp[i].col..'|'..pp[i].nome..'}}<br/>')
end
end
ss = ss..agg('</small>\n|}')
end
return frame:preprocess(sstable.concat(txt))
else
return err