-- <pre>
-- IMPORTANT: This module should be considered UNSTABLE and not be used widely
-- until further testing/bugfixing
		Used to display a map given a set of coordinates or page name
		Note that this module is INVOKE only. If you're looking for LUA usage,
		you probably want Module:TileMap, which this module utilizes.
		For documentation, see Template:CoordinateMap
-- Constants -------------------------------------------------------------------
-- Map constants, only needs changing if the map is updated
local MAPS = mw.loadData('Module:CoordinateMap/data')
-- Metamodules -----------------------------------------------------------------
local Coordinates = require('Module:Coordinates')
local TileMap = require('Module:TileMap')
local yesno = require('Module:Yesno')
-- INVOKE function -------------------------------------------------------------
local CoordinateMap = {}
function CoordinateMap.main(frame)
	if not frame or not frame.args then
		error('CoordinateMap.main() couldn\'t find the frame. This is an '..
			'invoke function; if you\'re calling this function in LUA, you '..
			'probably want Module:TileMap instead')
	local rargs = frame.args -- Raw args
	local args = { -- Clean(ish) args
		coords = rargs[1],
		map = string.lower(rargs[2] or ''),
		width = tonumber(rargs.width) or 250,
		height = tonumber(rargs.height) or 250,
		align = string.lower(rargs.align or ''),
		smw = (rargs.smw and rargs.smw ~= '') and rargs.smw or 'false'
	-- Check coords are valid
	if not args.coords then -- no coords passed
		error('CoordinateMap requires either a page name or a set of '..
			' coordinates passed as the first parameter')
	-- Check map is valid
	if not MAPS[] then = 'worldmap'
	-- Parse coords
	local coords = Coordinates.create(args.coords,, true)
	if not coords then
		error(string.format('Could not find location "%s". If it is '..
			'coordinates, make sure they are formed correctly. If it is a '..
			'page name, make sure there is a map on the target page with '..
			'smw=yes', args.coords))
	elseif coords.mapid and not MAPS[coords.mapid] then
		error(string.format('Invalid map name "%s" returned. If "%s" is a '..
			'page, ensure it has a valid map and does not have an erroneous '..
			'"Map name" SMW property set', coords.mapid, args.coords))
	-- Create TileMap
	local tmap = TileMap.create(
		coords:pixel().x - args.width/2, -- xmin
		coords:pixel().y - args.height/2, -- ymin
		args.width, -- width
		args.height, -- height
		MAPS[coords.mapid] -- map data
	-- Alignment
	if args.align == 'left' then
	elseif args.align == 'right' then
	elseif args.align == 'center' then
		tmap.container:css('margin','0 auto')
	-- Reticle
			position = 'absolute',
			border = '2px solid rgba(158,223,251,0.75)',
			['background-color'] = 'rgba(158,223,251,0.25)',
			height = '50px',
			width = '50px',
			margin = '-27px 0 0 -27px',
			top = '50%',
			left = '50%'
	-- Only add SMW data if the map was not retrieved from SMW, and
	-- 'smw' arg is truthy--]]--
	if not coords.fromsmw and yesno(args.smw) then
			:css('display', 'none')
					'[[Map coordinates::%s,%s]]\n[[Map name::%s]]',
					coords:pixel().x, coords:pixel().y,
	return tmap
return CoordinateMap
Community content is available under CC-BY-SA unless otherwise noted.