Jump to content

Module:AutoMapZoom

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Pppery (talk | contribs) at 15:01, 7 September 2022 (Add from old version of Module:Wikidata Infobox). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)
--  Given an input area, return a map zoom level to use with mw:Extension:Kartographer. Defaults to mapzoom=15. 
function p.autoMapZoom(frame)
	local sizestr,null = frame.args[1]:gsub("%D+%.?%D+", ""):gsub(",","")
	local size = tonumber(sizestr) or 0
	local LUT = { 5000000, 1000000, 100000, 50000, 10000, 2000, 150, 50, 19, 14, 5, 1, 0.5 } 
	for zoom, scale in ipairs(LUT) do
		if size > scale then
			return zoom+1
		end
	end
	return 15
end