"ഘടകം:Slippymap/sandbox" എന്ന താളിന്റെ പതിപ്പുകൾ തമ്മിലുള്ള വ്യത്യാസം

No edit summary
No edit summary
വരി 1: വരി 1:
local p = {}
local p = {}


-- Cleans input of excessive whitespace typically added by linebreaks and spaces
-- Function to clean input values by trimming spaces and handling nil values
local function clean(input)
local function clean(input)
return input and #input > 0 and mw.text.trim(input) or nil
return input and mw.text.trim(input) or nil
end
end


വരി 9: വരി 9:
local args = (frame:getParent() or frame).args
local args = (frame:getParent() or frame).args


-- Set map options with default values
-- Map configuration options
local options = {}
local options = {
options.latitude = tonumber(clean(args.lat)) or 51.3432699
latitude = tonumber(clean(args.lat)) or 51.3432699,
options.longitude = tonumber(clean(args.lon)) or 0.52700328
longitude = tonumber(clean(args.lon)) or 0.52700328,
options.height = tonumber(clean(args.height)) or 400
height = tonumber(clean(args.height)) or 400,
options.zoom = tonumber(clean(args.zoom)) or 12
width = clean(args.width) == "full" and "full" or tonumber(clean(args.width)) or 400,
options.align = clean(args.alignment) or "center"
zoom = tonumber(clean(args.zoom)) or 12,
options.text = clean(args.text)
align = clean(args.alignment) or "center",
text = clean(args.text) or "Custom Marker",
}


if clean(args.width) == "full" then
-- GeoJSON content for the marker with a custom image
options.width = "full"
local content = mw.text.jsonEncode({
elseif args.width then
type = "FeatureCollection",
options.width = tonumber(clean(args.width)) or 400
features = {
else
{
options.width = 400
type = "Feature",
end
geometry = {
 
type = "Point",
-- Handle marker display
coordinates = { options.longitude, options.latitude },
local content = nil
},
if clean(args.marker) ~= "no" then
properties = {
content = mw.text.jsonEncode({
title = options.text,
type = "FeatureCollection",
icon = {
features = {
iconUrl = "//schoolwiki.in/images/5/5f/63rd_state_kalolsavam_logo.png", -- Custom image URL
{
iconSize = { 50, 50 }, -- Size of the marker icon
type = "Feature",
iconAnchor = { 25, 50 }, -- Position of the icon's anchor point
geometry = {
popupAnchor = { 0, -50 }, -- Popup position relative to the marker
type = "Point",
coordinates = { options.longitude, options.latitude },
},
properties = {
title = options.text or "Marker", -- Title for the popup
icon = {
iconUrl = "//schoolwiki.in/images/5/5f/63rd_state_kalolsavam_logo.png", -- Path to the image file
iconSize = { 50, 50 }, -- Width and height of the icon
iconAnchor = { 25, 50 }, -- Anchor point (center bottom of the icon)
popupAnchor = { 0, -50 }, -- Popup anchor position
},
},
},
},
},
},
},
})
},
end
})


-- Return the mapframe tag
-- Generate the mapframe tag with marker and options
return frame:extensionTag {
return frame:extensionTag {
name = "mapframe",
name = "mapframe",
"https://schoolwiki.in/ഘടകം:Slippymap/sandbox" എന്ന താളിൽനിന്ന് ശേഖരിച്ചത്