Módulo:Layers

De Wikiviajes, la guía libre de viajes
Saltar a: navegación, buscar

La documentación para este módulo puede ser creada en Módulo:Layers/doc

local p = {}
local getArgs = require('Module:Argumentos').getArgs

function p.Filter(frame)
	local args = getArgs(frame)
	local layers = args[1] or ''
	local filteredLayers = extract(layers,'W')
	if filteredLayers == '' then
		filteredLayers = 'W' -- currently there are only two acceptable base layer. 'W' will be set if 'M' is not specified
	end
	-- Add additional & acceptable layer parameters
	filteredLayers = filteredLayers
		.. extract(layers,'S') -- hill shading from WM server
		.. extract(layers,'D') -- destination from Wikivoyage
		.. extract(layers,'G') -- GPX file from Wikivoyage
		.. extract(layers,'P') -- POI from Wikivoyage
		.. extract(layers,'E') -- add search box inside the map
	return filteredLayers
end

function extract(layers, layer)
	if string.match(layers, layer) ~= nil then
		return string.match(layers, layer)
	else
		return ''
	end
end

return p