Modulo:Mapframe: differenze tra le versioni
Contenuto cancellato Contenuto aggiunto
riportato dalla versione in sandbox il supporto per la legenda (parametro elenco) |
m modulo no globals obsoleto |
||
(7 versioni intermedie di un altro utente non mostrate) | |||
Riga 1:
require('
local getArgs = require('Module:Arguments').getArgs
local mWikidata = require('Module:Wikidata')
Riga 14 ⟶ 15:
local function getLegenda(points, ncols)
local divStyle = {
['-webkit-column-count'] = ncols
}
local divNode = mw.html.create('div'):css(divStyle)
Riga 23 ⟶ 25:
for _, point in ipairs(points) do
local pNode = mw.html.create('p')
:css('font-size', '90%') :css('margin-top', '0')
local codeNode = mw.html.create('code')
:css('font-weight', 'bold')
Riga 30 ⟶ 34:
:css('border', '2px solid ' .. point.col)
:css('background', point.col)
if not point.simb
codeNode:wikitext(' ')
elseif point.simb:find('-number') == 1 then
codeNode:wikitext(currNum)
currNum = currNum + 1
Riga 53 ⟶ 59:
function p._mappa(args)
local points = {}
local geo = args.dati or -1▼
local sinottico = tonumber(args.sinottico) or 0
local colore = args.colore or '#b80000'
local simbolo = args.simbolo or
local gruppo = args.gruppo or ''
local autozoom = args.autozoom or 's'
local elenco = (args.elenco == '1' or args.elenco == '2') and args.elenco or nil
local dsimbolo = 'medium'
local cornice▼
▲ if args.cornice then cornice = tonumber(args.cornice) or 1 else cornice = 1 end
local lat1, lat2, lon1, lon2 = 400, -400, 400, -400
width = args.larghezza or (sinottico == 1 and 260 or 350),
height = args.altezza or (sinottico == 1 and 260 or 300),
align = args.allinea or (sinottico == 1 and 'center' or 'right'),
}▼
-- =================================
-- popola la sequence points
-- =================================
local num = 1
if sinottico == 1 and args.lat1 == nil and args.lon1 == nil then
Riga 96 ⟶ 109:
end
num = num + 1
-- non utilizza nessun simbolo con un solo punto e args.simbolo e args.simbolo1 non definiti
if #points == 1 and args.simbolo == nil and args.simbolo1 == nil then
points[1].simb = nil
end
end
-- =================================
-- popola la table m_args
-- =================================
▲ end
▲ -- elimina cornice per cornice = 0 e per sinottico = 1
▲ if cornice ~= 1 or sinottico == 1 then m_args.frameless = 1 end
-- valore ingrandimento
if args.zoom then
m_args.zoom = tonumber(args.zoom)
elseif
if #points == 1 then
m_args.zoom = 10 -- valore predefinito per singolo punto
Riga 149:
if args.centro_lon then
m_args.longitude = tonumber(args.centro_lon)
elseif
if #points == 1 then
m_args.longitude = points[1].lon
Riga 159:
if args.centro_lat then
m_args.latitude = tonumber(args.centro_lat)
elseif
if #points == 1 then
m_args.latitude = points[1].lat
Riga 171:
end
-- =================================
-- popola la table m_dati
-- =================================
local m_dati
if
m_dati = args.dati
else▼
m_dati = { type = 'FeatureCollection', features = {} }
for i,
m_dati.features[i] = {
type = 'Feature',
properties = {
['marker-color'] = point.col,
title = point.nome,
description = point.desc
},
geometry = {
type = 'Point',
coordinates = {
}
}
▲ m_dati.features[i].properties['marker-symbol'] = points[i].simb
▲ m_dati.features[i].properties['marker-size'] = points[i].dsimb
end
m_dati = mw.text.jsonEncode(m_dati)
▲ else
end
|