local export = {}
local m_data = mw.loadData("Module:fi-dialects/map/data")
function export.show(args)
local frame = args.frame
local parishes = args.parishes
local pin = args.pin
local width = args.width
local height = args.height
local features = {}
for _, parish in ipairs(parishes) do
local feature = pin(parish)
if feature then
if feature[1] then
for _, subfeature in ipairs(feature) do
table.insert(features, subfeature)
end
else
table.insert(features, feature)
end
end
end
local geojson
if #features > 0 then
geojson = "," .. mw.ustring.gsub(mw.ustring.gsub(mw.text.jsonEncode(features), "^%s*%[", ""), "%]%s*$", "")
else
geojson = ""
end
geojson = m_data.borders_geojson_start .. geojson .. m_data.borders_geojson_end
return '<div style="position:relative;display:inline-block;">' .. frame:extensionTag("mapframe", geojson, {
class = "fi-dial-map__map",
mapstyle = "osm-intl",
width = width,
height = height,
}) .. "</div>"
end
return export