Module:Layers

विकियात्रा से
Jump to navigation Jump to search

"इस मॉड्यूल हेतु प्रलेख Module:Layers/doc पर बनाया जा सकता है"

local p = {}
local getArgs = require('Module:Arguments').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