Affiche une carte avec un ou plusieurs marqueurs donnant leurs coordonnées.
Paramètres[]
Tous optionnels
Paramètre | Par défaut | Description |
---|---|---|
map | Map The Island.jpg | Nom de fichier de la carte |
mapsize | 300 | Taille de carte en px |
markersize | 10 | Taille du marqueur en px |
markercolor | #f30 | |
markericon | Nom de fichier ou de l’icône | |
opacity | 1 | Opacité du marqueur |
text | Celui affiché sous la carte | |
float | Côté où la carte s'aligne (left/right) | |
borderCoordT | 7.2 | Coordonnées du haut |
borderCoordR | 92.8 | Coordonnées de droite |
borderCoordB | 92.8 | Coordonnées du bas |
borderCoordL | 7.2 | Coordonnées de la gauche |
Les lieux doivent être donnés séparés par des valeurs communes séparées par des virgules et doivent être donnés dans cet ordre (seules les lat et lon sont obligatoires) lat,lon,markersize,markercolor,markertooltip,markericon[,markericon2[,markericon3...]]
. Les paramètres laissés en blanc seront donnés par défaut. Par ex. écrire 20,50,,green
pour un marqueur vert en (20/50) avec la taille par défaut.
- Les virgules ne sont pas autorisées dans le titre du texte (elles brisent le format)
- Un signe égal doit être écrit
{{=}}
, une barre verticale ou un / oblique doivent être écrits{{!}}
.
Exemple[]
{{MapLocations|30,50|20,80,20}}
{{MapLocations|40,50|30,80|text=Tellement de points|80,50,30,yellow,Je suis un marqueur jaune!|opacity=0.7|50,50,5|markercolor=green|mapsize=200|10,10,5}}
tant de points |
La documentation ci-dessus est transcluse de Module:MapLocations/doc. (modifier | historique)
local p = {}
function p.maplocations( f )
local args = f:getParent().args
-- set default values (borderCoords are for top, right, bottom, left)
local map, borderCoords, mapsize, markersize, markercolor, markericon, opacity, text, float = 'Map The Island.jpg', {t=7.2,r=92.8,b=92.8,l=7.2}, 300, 10, '#f40','', 1, '', ''
-- get values from parameters
if args.map ~= nil then
map = args.map
-- if the map is given as just the name, apply the default map-file
if map == 'The Island' then map = 'The Island Topographic Map.jpg'
elseif map == 'The Center' then map = 'The Center Topographic Map.jpg'
elseif map == 'Scorched Earth' then map = 'Scorched Earth Topographic Map.jpg'
elseif map == 'Ragnarok' then map = 'Ragnarok Topographic Map.jpg'
elseif map == 'Aberration' then map = 'Aberration Topographic Map.jpg'
end
-- use the default borders of the chosen map
if map == 'The Center Topographic Map.jpg' then
borderCoords = {t=-2.0,r=100.0,b=100.0,l=0.0}
elseif map == 'Scorched Earth Topographic Map.jpg' then
borderCoords = {t=0.0,r=100.0,b=100.0,l=0.0}
elseif map == 'Ragnarok Topographic Map.jpg' then
borderCoords = {t=11,r=89,b=89,l=11}
elseif map == 'Ragnarok Ocean Topographic Map.jpg' then
borderCoords = {t=-2.6,r=102.4,b=102.4,l=-2.6}
elseif map == 'Ragnarok Map.png' then
borderCoords = {t=0.0,r=100.0,b=100.0,l=0.0}
elseif map == 'Aberration Topographic Map.jpg' then
borderCoords = {t=7.2,r=92.8,b=92.8,l=7.2}
end
end
if args.mapsize ~= nil then
mapsize = args.mapsize
end
if args.markersize ~= nil and type(args.markersize)=='number' and args.markersize >= 0 then
markersize = args.markersize
end
if args.markercolor ~= nil then
markercolor = args.markercolor
end
if args.markericon ~= nil then
markericon = args.markericon
end
if args.opacity ~= nil then
opacity = args.opacity
end
if args.text ~= nil then
text = args.text
end
if args.float ~= nil then
float = args.float
end
if args.borderCoordT ~= nil then
borderCoords.t = args.borderCoordT
end
if args.borderCoordR ~= nil then
borderCoords.r = args.borderCoordR
end
if args.borderCoordB ~= nil then
borderCoords.b = args.borderCoordB
end
if args.borderCoordL ~= nil then
borderCoords.l = args.borderCoordL
end
-- variables for a single marker: lat, lon, ms (markersize), mc (markercolor), mt (markertext/title/tooltip), mis (markericons)
local locations, lat, lon, ms, mc, mt, mis = {}, 0, 0, 0, '','', {}
for _,l in ipairs(args) do
ms = markersize
mc = markercolor
mis = {}
mis[1] = markericon
local parts,i = {},0
for part in string.gmatch(l..',', "([^,]*),") do
table.insert(parts,part:match "^%s*(.-)%s*$")
end
if #parts > 1 then
lat = parts[1]
lon = parts[2]
mt = 'lat '..lat..', lon '..lon
if #parts > 2 and string.len(parts[3])>0 then
ms = parts[3]
end
if #parts > 3 and string.len(parts[4])>0 then
mc = parts[4]
end
if #parts > 4 and string.len(parts[5])>0 then
mt = parts[5]..'
'..mt
end
i=5
while #parts > i do
mis[i-4] = parts[i+1]
i = i + 1
end
if #mis > 0 and string.len(mis[1]) > 0 then
table.insert(locations,'<div style="position:absolute;line-height:0;left:'.. 100*((lon-borderCoords.l)/(borderCoords.r-borderCoords.l) - ms/(2*mapsize)) ..'%;top:'.. 100*((lat-borderCoords.t)/(borderCoords.b-borderCoords.t) - ms/(2*mapsize)) ..'%;padding:0;opacity:'..opacity..'" title="'..mt..'"><div style="position:absolute">[[File:'..table.concat(mis,'|'..ms..'px]]</div><div style="position:absolute">[[File:')..'|'..ms..'px]]</div></div>')
else
table.insert(locations,'<div style="position:absolute;line-height:0;left:'.. 100*((lon-borderCoords.l)/(borderCoords.r-borderCoords.l) - ms/(2*mapsize)) ..'%;top:'.. 100*((lat-borderCoords.t)/(borderCoords.b-borderCoords.t) - ms/(2*mapsize)) ..'%;padding:0;width:'..ms..'px;height:'..ms..'px;border-radius:50%;background-color:'..mc..';border:1px solid black;opacity:'..opacity..'" title="'..mt..'"></div>')
end
end
end
local subtitle = ''
if text ~= '' then
subtitle = '\n|-\n| align="middle" | '..text
end
return '{| class="wikitable" style="float:'..float..'"\n|-\n|<div class="noviewer" style="position: relative;width:'..mapsize..'px;height:'..mapsize..'px">'..table.concat(locations)..'[[File:'..map..'|'..mapsize..'px]]</div>'..subtitle..'\n|}'
end
return p