| This module is rated as pre-alpha. It is incomplete and may or may not be in active development. Do not use it in article namespace pages. A module remains in pre-alpha until its developer, or another editor who adopts it if it is abandoned for some time, considers the basic structure complete. |
This Module is designed to merge OpenStreetMap and Pushpin maps and satellite maps and others into one radio button. And its aim is to reduce infobox images, making it more readably and useful. It is aimed to provide the least arguments to it, so no need for providing mapframe-id and coordinates, therefore it works by providing only a mapQuery argument which is its first one.
{{#invoke:MergedMap|function_name}}
Firts argument of this template is “mapQuery” which should provide order of maps in the radio button, separated by ‘#’. For openstreetmap use “OSM”, and for pushpin maps use the name of one of maps in Template:Location map/List. Other OSM maps can be added by OSM1 to OSM10 and a full mapframe should be provided for it. For satellite maps, use customMap1 to customMap10 and customMap1Caption1 to customMap1Caption10 for its caption. Other arguments include:
mapframe-zoom for zoom of main OSM. mapframe-marker for marker of main OSM mapframe-shape for shape of main OSM mapframe-id for id of main OSM
There is no need to provide coordinates and mapframe-id in main articles because they are fetched from Wikidata.
<div class="center">
<div style = "width: 270px;">
{{#invoke:MergedMap|main|mapQuery={{{mapQuery|{{#invoke:String|replace| {{#if:{{{pushpin_map|}}}|{{{pushpin_map|}}}^}}{{#ifeq:{{{mapframe|}}}|yes|OSM^}}{{#if:{{{satelliteMap|}}}|customMap1^}}{{#if:{{{pictureMap|}}}|customMap2^}}|pattern= ^ |replace= # }}}}}
|coordinates = {{{coordinates|{{#invoke:coordinates|coord2text|{{#:property:625}}}}}}}
|label = {{{MergedMap_label|{{{label|{{PAGENAMEBASE}}}}}}}}
| customMap1 = {{{satelliteMap|}}}
| customMap1Caption = Satellite map
| customMap2 = {{{pictureMap|}}}
| customMap2Caption = Picture map
}}
</div>
</div>
require('strict') local pushpinModule = require ('Module:MergedMapGetPushPin') local OSMModule = require ('Module:MergedMapGetOSM') local im = require ('Module:InfoboxImage') local imf3 = require ('Module:Infobox mapframe/sandbox3') local infoboxImage = require('Module:InfoboxImage').InfoboxImage local getArgs = require('Module:Arguments').getArgs local p = {} function p.parseCustomWikitext(customWikitext) -- infoboxImage will format an image if given wikitext containing an -- image, or else pass through the wikitext unmodified return infoboxImage({ args = { image = customWikitext } }) end function p.ltrim(s) return (string.gsub(s, "^%s*(.-)%s*$", "%1")) end function p.main(frame, args) local caption_list = {} local args = getArgs(frame) if args.useWikidata == nil then args.useWikidata = true end local maps = {} local mapNamesList = {} local queryString if args['mapQuery'] then queryString = args['mapQuery'] elseif args[1] then queryString = args[1] end if queryString then queryString = p.ltrim (queryString) for mapname in string.gmatch(queryString, '[^#]+') do if mapname == "OSM" then if args['mapframe-switcher'] == "zooms" then local OSMCustomText if args['mapframe-zoom'] then OSMCustomText = p.parseCustomWikitext('{{Infobox mapframe|id= ' .. args['mapframeId'] .. ' |zoom = ' .. args['mapframe-zoom'] .. ' }}') else OSMCustomText = p.parseCustomWikitext('{{Infobox mapframe|id= ' .. args['mapframeId'] .. '}}') end OSMCustomText = frame:preprocess(OSMCustomText) maps[#maps + 1] = OSMCustomText mapNamesList[#mapNamesList + 1] = 'Show OpenStreetMap' local OSMCustomTextZoomIn = p.parseCustomWikitext('{{Infobox mapframe|id= ' .. args['mapframeId'] .. '|zoom = 13}}') OSMCustomTextZoomIn = frame:preprocess(OSMCustomTextZoomIn) maps[#maps + 1] = OSMCustomTextZoomIn mapNamesList[#mapNamesList + 1] = 'Show OpenStreetMap in Zoom in' local OSMCustomTextZoomOut = p.parseCustomWikitext('{{Infobox mapframe|id= ' .. args['mapframeId'] .. '|zoom = 1}}') OSMCustomTextZoomOut = frame:preprocess(OSMCustomTextZoomOut) maps[#maps + 1] = OSMCustomTextZoomOut mapNamesList[#mapNamesList + 1] = 'Show OpenStreetMap in Zoom out' else local OSMArgs = args --OSMArgs['mapframe-shape'] = 'yes' --frame.args['mapframe-wikidata'] = 'yes' --frame.args['mapframe-caption'] = args['mapframe-caption'] for k,v in pairs(args) do frame.args[k] = v end maps[#maps + 1] = '<div align = center id = "OSMMergedMap"><div style= "text-align: center;">' .. OSMModule.main(frame, args) .. '</div></div>' local count = 0 for mapname in string.gmatch(queryString, '[^#]+') do count = count + 1 end if count == 1 then if not args['mapframe-caption'] then mapNamesList[#mapNamesList + 1] = 'OpenStreetMap' end else mapNamesList[#mapNamesList + 1] = 'Show OpenStreetMap' end end elseif string.match(mapname, "OSM%d") then local OSMCustomText = args[mapname] maps[#maps + 1] = OSMCustomText local OSMNumeber = string.match(mapname, "%d") mapNamesList[#mapNamesList + 1] = args['OSM' .. OSMNumeber .. 'Caption'] or mapname elseif string.match(mapname, "File%d") then local FileCustomText = args[mapname] maps[#maps + 1] = FileCustomText local FileNumeber = string.match(mapname, "%d") mapNamesList[#mapNamesList + 1] = args['File' .. FileNumeber .. 'Caption'] or mapname elseif string.match(mapname, "customMap%d") then local customMapText = args[mapname] local ImageURL = args[mapname] local imageArgs = {} imageArgs['image'] = ImageURL frame.args['image'] = ImageURL frame.args['maxsize'] = 270 maps[#maps + 1] = '<div>' .. im.InfoboxImage (frame) .. '</div>' local CustomNumeber = string.match(mapname, "%d") local myString = 'Show satellite map' if tonumber(CustomNumeber) > 1 then myString = myString .. CustomNumeber end mapNamesList[#mapNamesList + 1] = args['customMap' .. CustomNumeber .. 'Caption'] or myString else local pushpinArgs = {} local pushpinMapName = mw.ustring.gsub(mapname, '^%s*(.-)%s*$', '%1') pushpinArgs[1] = mapname for k,v in pairs(args) do pushpinArgs[k] = v end frame.args = pushpinArgs maps[#maps + 1] = '<div style= "text-align: left;">' .. pushpinModule.main(frame, args) .. '</div>' mapNamesList[#mapNamesList + 1] = 'Show in ' .. mapname end end end local root = mw.html.create('div'):addClass('switcher-container') for i =1, #maps do local span = root :tag('div') :wikitext(maps[i]) :tag('span') :addClass('switcher-label') :wikitext(mapNamesList[i]) :css('display', 'none') --:event('onclick','document.getElementById("OSMMergedMap").innerHTML = "aaaaaaaaaa"') if i == 1 then span:attr('data-switcher-default', '') end end return '<div align = center ><div style = "width: 270px;">' .. tostring(root) .. '</div></div>' end return p

