Documentation for this module may be created at Module:Mapframe/doc
-- Module:OpenStreetMapFrame local p = {} local getArgs = require('Module:Arguments').getArgs -- Default settings local DEFAULT_WIDTH = 300 local DEFAULT_HEIGHT = 200 local DEFAULT_ZOOM = 10 -- Main function to render the map frame function p.main(frame) local args = getArgs(frame) return p.renderMapFrame(args) end -- Function to generate the map frame HTML function p.renderMapFrame(args) -- Extract parameters local coord = args.coord or args.coordinates local zoom = tonumber(args.zoom) or DEFAULT_ZOOM local width = tonumber(args.width) or DEFAULT_WIDTH local height = tonumber(args.height) or DEFAULT_HEIGHT -- Validate coordinates if not coord or not coord:match("^[%d.-]+,[%d.-]+$") then return '<strong class="error">Error: Invalid coordinates provided.</strong>' end -- Extract latitude and longitude local lat, lon = coord:match("^([%d.-]+),([%d.-]+)$") -- Construct the OpenStreetMap tile URL local osmTileUrl = string.format("https://tile.openstreetmap.org/%d/%s/%s.png", zoom, lon, lat) -- Construct the HTML for the image local html = string.format( '<img src="%s" alt="Map at coordinates %s" width="%d" height="%d" />', osmTileUrl, coord, width, height ) return html end -- Export the module's functions return p