ATLAS Wiki
Explore
Main Page
All Pages
Interactive Maps
navigation
Main page
Community portal
Recent changes
Random page
Admin noticeboard
Report a bad ad
Useful pages
Item IDs
Map
NPCs
Resources
Ships
Taming
ATLAS links
Official site
Discord
Facebook
Reddit
Steam
Twitch
Twitter
YouTube
Wiki links
Wiki Discord
Gamepedia
Gamepedia support
Report a bad ad
Help Wiki
Contact us
FANDOM
Fan Central
BETA
Games
Anime
Movies
TV
Video
Wikis
Explore Wikis
Community Central
Start a Wiki
Don't have an account?
Register
Sign In
Sign In
Register
ATLAS Wiki
2,357
pages
Explore
Main Page
All Pages
Interactive Maps
navigation
Main page
Community portal
Recent changes
Random page
Admin noticeboard
Report a bad ad
Useful pages
Item IDs
Map
NPCs
Resources
Ships
Taming
ATLAS links
Official site
Discord
Facebook
Reddit
Steam
Twitch
Twitter
YouTube
Wiki links
Wiki Discord
Gamepedia
Gamepedia support
Report a bad ad
Help Wiki
Contact us
Editing
Module:MapLocations
Back to page
Edit source
View history
Talk (0)
Edit Page
Module:MapLocations
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
local p = {} local args local map local tableArg local borderCoords local mapSize local defaultMarkerSize local defaultMarkerColor local defaulatMarkerIcon local defaultMarkerOpacity local text local float local markerNameTable = {} local areArgsParsed = false function isEmpty(x) return x == nil or x == '' end -- copies args or assigns default function p.parseArgs (f) if areArgsParsed then return end args = require('Module:ProcessArgs').merge(true) map = args.map or 'Map The Island.jpg' tableArg = 'class="wikitable"' borderCoords = { t = args.borderCoordT or 100, r = args.borderCoordR or 100, b = args.borderCoordB or 0, l = args.borderCoordL or 0} mapSize = args.mapsize or 300 defaultMarkerSize = args.markersize or 10 defaultMarkerColor = args.markercolor or '#f40' defaulatMarkerIcon = args.markericon or '' defaultMarkerOpacity = args.opacity or 1 text = args.text or '' float = args.float or '' areArgsParsed = true end function p.maplocations(f) p.parseArgs(f) return p.drawMap(f) end function p._maplocations(_map , _tableArg ,_borderCoordT ,_borderCoordR ,_borderCoordB ,_borderCoordL ,_mapsize ,_markersize ,_markercolor ,_markericon ,_opacity ,_text ,_float ,... ) args = {...} map = _map or "map.jpg" tableArg = _tableArg or 'class="wikitable"' borderCoords = { t = _borderCoordT or 100, r = _borderCoordR or 100, b = _borderCoordB or 0, l = _borderCoordL or 0 } mapSize = _mapsize or 300 defaultMarkerSize = _markersize or 10 defaultMarkerColor = _markercolor or '#f40' defaulatMarkerIcon = _markericon or '' defaultMarkerOpacity = _opacity or 1 text = _text or '' float = _float or '' areArgsParsed = true return p.printArgs() .. p.drawMap() end -- function p.drawMap(f) local subtitle = '' if text ~= '' then subtitle = '\n|-\n| align="middle" | '..text end return '{| ' .. tableArg.. ' style="float:' .. float .. '"\n|-\n|'..p.generateMapDiv(f)..subtitle..'\n|}' end function p.generateMapDiv (f) p.parseArgs(f) return p._generateMapDiv( map, borderCoords.t, borderCoords.r, borderCoords.b, borderCoords.l, mapSize, defaultMarkerSize, defaultMarkerColor, defaulatMarkerIcon, defaultMarkerOpacity) end function p._generateMapDiv( _map ,_borderCoordT ,_borderCoordR ,_borderCoordB ,_borderCoordL ,_mapsize ,_markersize ,_markercolor ,_markericon ,_opacity ) map = _map or "map.jpg" borderCoords = { t = _borderCoordT or 100, r = _borderCoordR or 100, b = _borderCoordB or 0, l = _borderCoordL or 0 } mapSize = _mapsize or 300 defaultMarkerSize = _markersize or 10 defaultMarkerColor = _markercolor or '#f40' defaulatMarkerIcon = _markericon or '' defaultMarkerOpacity = _opacity or 1 areArgsParsed = true local locations = p.generateLocationTable(args) return '<div class="noviewer" style="position: relative;' .. 'width:' .. _mapsize .. 'px;' .. 'height:' .. _mapsize .. 'px">' .. table.concat(locations) .. '[[File:'.._map..'|'..mapSize..'px]]' .. '</div>' end function p.generateLocationTable () local locations = {} for _,l in ipairs(args) do local markerSize = defaultMarkerSize local markerColor = defaultMarkerColor local markerIcons = {} markerIcons[1] = defaulatMarkerIcon local parts,i = {},0 -- We are assuming the only arguments with commas locations for part in string.gmatch(l..',', "([^,]*),") do table.insert(parts,part:match "^%s*(.-)%s*$") end if #parts > 1 then -- lat/long are manditory local latitude = parts[1] or 0 local longitude = parts[2] or 0 local markerName = 'lat '..latitude..', lon '..longitude if isEmpty(parts[3]) then markerSize = defaultMarkerSize else markerSize = parts[3] end if isEmpty(parts[4]) then markerColor = defaultMarkerColor else markerColor = parts[4] end if not isEmpty(parts[5]) then table.insert(markerNameTable,parts[5]) markerName = parts[5]..'
'..markerName end i=5 while #parts > i do markerIcons[i-4] = parts[i+1] i = i + 1 end --Construct a colored div or icon marker local markerDivStart = '<div style="position: absolute;' .. 'line-height:0;' .. 'padding:0;' .. 'opacity:'..defaultMarkerOpacity..';' local markerDivPosition = 'left:'.. p.calculateLeftSide(longitude,markerSize) .. '%;' .. 'top:' .. p.calculateTopSide(latitude,markerSize) ..'%;' local markerSizeAndColor = 'width:'..markerSize..'px;' .. 'height:'..markerSize..'px;' .. 'border-radius:50%;' .. 'background-color:'..markerColor..';' .. 'border:1px solid black' local markerDivEnd = '" title="'..markerName..'">' local divClose = '</div>' if #markerIcons > 0 and string.len(markerIcons[1]) > 0 then local iconDelimeter = '|'..markerSize..'px]]</div><div style="position:absolute">[[File:' local iconDiv = '<div style="position:absolute">[[File:'..table.concat(markerIcons,iconDelimeter)..'|'..markerSize..'px]]</div>' table.insert(locations,markerDivStart..markerDivPosition..markerDivEnd..iconDiv..divClose) else table.insert(locations,markerDivStart..markerDivPosition..markerSizeAndColor..markerDivEnd..divClose) end end end return locations end -- Calculates the top left side of the marker function p.calculateLeftSide(longitude, markerSize) local markerRadiusPercentage = p.calculateMarkerRadiusAsPercentage(markerSize) local width = (borderCoords.r-borderCoords.l) local xOffset = (longitude-borderCoords.l) return 100*(xOffset/width - markerRadiusPercentage) end -- Calculates the top edge of the marker function p.calculateTopSide(latitude, markerSize) local markerRadiusPercentage = p.calculateMarkerRadiusAsPercentage(markerSize) local height = (borderCoords.b-borderCoords.t) local yOffset = (latitude-borderCoords.t) return 100*(yOffset/height - markerRadiusPercentage) end -- Calculates marker radius as percentage of map width function p.calculateMarkerRadiusAsPercentage (markerSize) return markerSize/(2*mapSize) end -- Useful for debugging your input function p.printArgs(f) p.parseArgs(f) return '\n<br>map = ' .. map .. '<br>tableArg = ' .. tableArg .. '<br>borderCoords = ' .. borderCoords.t.. ','.. borderCoords.r..' '.. borderCoords.b..','.. borderCoords.l .. '<br>mapsize = ' .. mapSize .. '<br>defaultMarkerSize = ' .. defaultMarkerSize .. '<br>defaultMarkerColor = ' .. defaultMarkerColor .. '<br>markericon = ' .. defaulatMarkerIcon .. '<br>defaultMarkerOpacity = ' .. defaultMarkerOpacity .. '<br>text = ' .. text .. '<br>float = ' .. float .. '\n' end return p
Summary:
Please note that all contributions to the ATLAS Wiki are considered to be released under the CC BY-NC-SA
Cancel
Editing help
(opens in new window)
Templates used on this page:
Template:Doc/end
(
view source
)
Template:Doc/start
(
view source
)
Template:MapLocations
(
view source
)
Template:MapLocations/doc
(
view source
)
Module:MapLocations
(
edit
)
Module:MapLocations/doc
(
edit
)
Module:ProcessArgs
(
edit
)
Follow on IG
TikTok
Join Fan Lab