ഘടകം:Slippymap/sandbox
ദൃശ്യരൂപം
ഈ ഘടകത്തിന്റെ വിവരണം ഘടകം:Slippymap/sandbox/വിവരണം എന്ന താളിൽ നിർമ്മിക്കാവുന്നതാണ്
local p = {}
-- Cleans input of excessive whitespace typically added by linebreaks and spaces
local function clean(input)
return input and #input > 0 and mw.text.trim(input) or nil
end
function p.slippymap(frame)
local args = (frame:getParent() or frame).args
-- Set map options with default values
local options = {}
options.latitude = tonumber(clean(args.lat)) or 51.3432699
options.longitude = tonumber(clean(args.lon)) or 0.52700328
options.height = tonumber(clean(args.height)) or 400
options.zoom = tonumber(clean(args.zoom)) or 12
options.align = clean(args.alignment) or "center"
options.text = clean(args.text)
if clean(args.width) == "full" then
options.width = "full"
elseif args.width then
options.width = tonumber(clean(args.width)) or 400
else
options.width = 400
end
-- Handle marker display
local content = nil
if clean(args.marker) ~= "no" then
content = mw.text.jsonEncode({
type = "FeatureCollection",
features = {
{
type = "Feature",
geometry = {
type = "Point",
coordinates = { options.longitude, options.latitude },
},
properties = {
title = options.text or "Marker", -- Title for the popup
["marker-symbol"] = "marker", -- Default marker symbol
["marker-size"] = "medium", -- Marker size (small, medium, or large)
["marker-color"] = "#FF0000", -- Marker color (hex format)
},
},
},
})
end
-- Return the mapframe tag
return frame:extensionTag {
name = "mapframe",
content = content,
args = {
latitude = options.latitude,
longitude = options.longitude,
height = options.height,
width = options.width,
zoom = options.zoom,
align = options.align,
},
}
end
return p