"ഘടകം:Slippymap/sandbox" എന്ന താളിന്റെ പതിപ്പുകൾ തമ്മിലുള്ള വ്യത്യാസം
ദൃശ്യരൂപം
No edit summary |
No edit summary |
||
| വരി 1: | വരി 1: | ||
local p = {} | local p = {} | ||
-- | -- Function to clean input values by trimming spaces and handling nil values | ||
local function clean(input) | local function clean(input) | ||
return input | 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 | ||
-- | -- Map configuration options | ||
local options = { | local options = { | ||
latitude = tonumber(clean(args.lat)) or 51.3432699, | |||
longitude = tonumber(clean(args.lon)) or 0.52700328, | |||
height = tonumber(clean(args.height)) or 400, | |||
width = clean(args.width) == "full" and "full" or tonumber(clean(args.width)) or 400, | |||
zoom = tonumber(clean(args.zoom)) or 12, | |||
align = clean(args.alignment) or "center", | |||
text = clean(args.text) or "Custom Marker", | |||
} | |||
-- GeoJSON content for the marker with a custom image | |||
local content = mw.text.jsonEncode({ | |||
type = "FeatureCollection", | |||
features = { | |||
{ | |||
type = "Feature", | |||
geometry = { | |||
type = "Point", | |||
-- | coordinates = { options.longitude, options.latitude }, | ||
local | }, | ||
properties = { | |||
title = options.text, | |||
icon = { | |||
iconUrl = "//schoolwiki.in/images/5/5f/63rd_state_kalolsavam_logo.png", -- Custom image URL | |||
iconSize = { 50, 50 }, -- Size of the marker icon | |||
iconAnchor = { 25, 50 }, -- Position of the icon's anchor point | |||
popupAnchor = { 0, -50 }, -- Popup position relative to the marker | |||
}, | }, | ||
}, | }, | ||
}, | }, | ||
} | }, | ||
}) | |||
-- | -- Generate the mapframe tag with marker and options | ||
return frame:extensionTag { | return frame:extensionTag { | ||
name = "mapframe", | name = "mapframe", | ||
17:53, 6 ജനുവരി 2025-നു നിലവിലുണ്ടായിരുന്ന രൂപം
ഈ ഘടകത്തിന്റെ വിവരണം ഘടകം:Slippymap/sandbox/വിവരണം എന്ന താളിൽ നിർമ്മിക്കാവുന്നതാണ്
local p = {}
-- Function to clean input values by trimming spaces and handling nil values
local function clean(input)
return input and mw.text.trim(input) or nil
end
function p.slippymap(frame)
local args = (frame:getParent() or frame).args
-- Map configuration options
local options = {
latitude = tonumber(clean(args.lat)) or 51.3432699,
longitude = tonumber(clean(args.lon)) or 0.52700328,
height = tonumber(clean(args.height)) or 400,
width = clean(args.width) == "full" and "full" or tonumber(clean(args.width)) or 400,
zoom = tonumber(clean(args.zoom)) or 12,
align = clean(args.alignment) or "center",
text = clean(args.text) or "Custom Marker",
}
-- GeoJSON content for the marker with a custom image
local content = mw.text.jsonEncode({
type = "FeatureCollection",
features = {
{
type = "Feature",
geometry = {
type = "Point",
coordinates = { options.longitude, options.latitude },
},
properties = {
title = options.text,
icon = {
iconUrl = "//schoolwiki.in/images/5/5f/63rd_state_kalolsavam_logo.png", -- Custom image URL
iconSize = { 50, 50 }, -- Size of the marker icon
iconAnchor = { 25, 50 }, -- Position of the icon's anchor point
popupAnchor = { 0, -50 }, -- Popup position relative to the marker
},
},
},
},
})
-- Generate the mapframe tag with marker and options
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