Module:Mapframe: Difference between revisions

Content deleted Content added
restore last version with check for parameter key type (no positional parameters are used, although some templates have them)
per tper
 
(5 intermediate revisions by 4 users not shown)
Line 9:
-- Modue dependencies
local transcluder -- local copy of https://www.mediawiki.org/wiki/Module:Transcluder loaded lazily
-- "Module:No globalsstrict" should not be used, at least until all other modules which require this module are not using globals.
 
-- Template parameter names (unnumbered versions only)
Line 92:
dsep = ",", -- separator between inline and title (comma in the example above)
 
-- valid values for type paramterparameter
line = "line", -- geoline feature (e.g. a road)
shape = "shape", -- geoshape feature (e.g. a state or province)
Line 198:
-- However, *don't* strip control characters from wikitext (text or description parameters) or you'll break strip markers
-- Alternatively it might be better to only strip control char from raw parameter content
if util.matchesParam('text', key) or util.matchesParam('description', key, key:gsub('^.%D+(%d+)$', '%1') ) then
cleanArgs[key] = val
else
Line 380:
 
local lat_d = tonumber(parts[1])
assert(lat_d, "Unable to get latitude from input '"..coords.."'.")
local lat_m = tonumber(parts[2]) -- nil if coords are in decimal format
local lat_s = lat_m and tonumber(parts[3]) -- nil if coords are either in decimal format or degrees and minutes only
Line 388 ⟶ 389:
 
local long_d = tonumber(parts[1+#parts/2])
assert(long_d, "Unable to get longitude from input '"..coords.."'.")
local long_m = tonumber(parts[2+#parts/2]) -- nil if coords are in decimal format
local long_s = long_m and tonumber(parts[3+#parts/2]) -- nil if coords are either in decimal format or degrees and minutes only
Line 798 ⟶ 800:
local spanAttribs = {
style = "font-size: small;",
id = "mapframe-coordinates"
}
returnlocal indicatorContent = mw.text.tag('span', spanAttribs, titleTag)
return mw.getCurrentFrame():extensionTag {
name = "indicator",
content = indicatorContent,
args = {
name = "zzz-mapframe" --zzz: show as last indicator
}
}
end