Module:OrganizationsMap: Difference between revisions
Appearance
Created page with "local p = {} function p.main(frame) local args = frame:getParent().args local picture = 'File:Person reading a newspaper (Unsplash).jpg' if args['picture'] ~= nil and args['picture'] ~= 'File:' then picture = args['picture'] end return '100px|link=' end return p" |
No edit summary |
||
| (28 intermediate revisions by the same user not shown) | |||
| Line 2: | Line 2: | ||
function p.main(frame) | function p.main(frame) | ||
local args = frame:getParent().args | -- local args = frame:getParent().args | ||
local | local arr = mw.visualdata.query( 'Organization', '[[geolocation/latitude::+]]', {}, {} ) | ||
-- https://maps.extension.wiki/wiki/Displaying_Leaflet_maps | |||
-- Location~Popup title~Popup text~File:CustomIcon~Group~Inline label~File:VisitedIcon | |||
local ret = {} | |||
for i,v in ipairs(arr) do | |||
local v_ = v.data.geolocation.latitude .. ',' .. v.data.geolocation.longitude .. '~'.. v.data.name .. '~' .. v.data.city .. ' (' .. v.data.country .. ')' | |||
table.insert(ret, v_) | |||
--ret[#ret + 1] = string.gsub(v_, "^%s*(.-)%s*$", "%1") | |||
end | |||
-- return string.gsub(ret, "^%s*(.-)%s*$", "%1") | |||
local mapData = table.concat(ret, '\n' ) | |||
return frame:preprocess( "<display_map>" .. mapData .. "</display_map>" ) | |||
-- Gent, Belgie~The city Ghent~Ghent is awesome~ ~ ~Ghent | |||
-- Brussel~The city Brussel~The capital of Belgium~ ~ ~Brussels | |||
-- Antwerp~The city Antwerp~ ~ ~ ~Antwerp | |||
-- return 'display_map' mw.text.jsonEncode(ret) | |||
end | end | ||
return p | return p | ||
Latest revision as of 11:45, 27 September 2025
Documentation for this module may be created at Module:OrganizationsMap/doc
local p = {}
function p.main(frame)
-- local args = frame:getParent().args
local arr = mw.visualdata.query( 'Organization', '[[geolocation/latitude::+]]', {}, {} )
-- https://maps.extension.wiki/wiki/Displaying_Leaflet_maps
-- Location~Popup title~Popup text~File:CustomIcon~Group~Inline label~File:VisitedIcon
local ret = {}
for i,v in ipairs(arr) do
local v_ = v.data.geolocation.latitude .. ',' .. v.data.geolocation.longitude .. '~'.. v.data.name .. '~' .. v.data.city .. ' (' .. v.data.country .. ')'
table.insert(ret, v_)
--ret[#ret + 1] = string.gsub(v_, "^%s*(.-)%s*$", "%1")
end
-- return string.gsub(ret, "^%s*(.-)%s*$", "%1")
local mapData = table.concat(ret, '\n' )
return frame:preprocess( "<display_map>" .. mapData .. "</display_map>" )
-- Gent, Belgie~The city Ghent~Ghent is awesome~ ~ ~Ghent
-- Brussel~The city Brussel~The capital of Belgium~ ~ ~Brussels
-- Antwerp~The city Antwerp~ ~ ~ ~Antwerp
-- return 'display_map' mw.text.jsonEncode(ret)
end
return p