Jump to content

User:Jean-Louis²/Maplink

From Wikipedia, the free encyclopedia

2 coordinates[edit]

Template:Coord, Module:Coordinates

<li>
  <span class="geo-inline">
    <style data-mw-deduplicate="TemplateStyles:r1156832818">.mw-parser-output .geo-default,.mw-parser-output .geo-dms,.mw-parser-output .geo-dec{display:inline}.mw-parser-output .geo-nondefault,.mw-parser-output .geo-multi-punct,.mw-parser-output .geo-inline-hidden{display:none}.mw-parser-output .longitude,.mw-parser-output .latitude{white-space:nowrap}
    </style>
    <span class="plainlinks nourlexpansion">
      <span style="white-space: nowrap;">
        <img src="//upload.wikimedia.org/wikipedia/commons/thumb/5/55/WMA_button2b.png/17px-WMA_button2b.png" srcset="//upload.wikimedia.org/wikipedia/commons/thumb/5/55/WMA_button2b.png/17px-WMA_button2b.png 1x, //upload.wikimedia.org/wikipedia/commons/thumb/5/55/WMA_button2b.png/34px-WMA_button2b.png 2x" class="wmamapbutton noprint" title="Show location on an interactive map" alt="" style="padding: 0px 3px 0px 0px; cursor: pointer;">
        <a class="external text" href="//geohack.toolforge.org/geohack.php?pagename=User:Hens_Jean-Louis/Maplink&params=52.499036_N_2.064032_W_region:GB_type:landmark&title=Air+vent+No.+4" style="white-space: normal;">
          <span class="geo-nondefault">
            <span class="geo-dms" title="Maps, aerial photos, and other data for this location">
              <span class="latitude">
52°29′57″N
              </span>
 
              <span class="longitude">
2°03′51″W
              </span>
            </span>
          </span>
          <span class="geo-multi-punct">
 / 
          </span>
          <span class="geo-default">
            <span class="vcard">
              <span class="geo-dec" title="Maps, aerial photos, and other data for this location">
52.499036°N 2.064032°W
              </span>
              <span style="display:none">
 / 
                <span class="geo">
52.499036; -2.064032
                </span>
              </span>
              <span style="display:none">
 (
                <span class="fn org">
Air vent No. 4
                </span>
)
              </span>
            </span>
          </span>
        </a>
      </span>
    </span>
  </span>
</li>

2 coordinates again[edit]

Map

Map

Map
Map


Maplink Mapframe[edit]

template:Maplink Module:Mapframe

--[[
Gets all named coordiates from a page or a section of a page.
@param {string|nil} page  Page name, or name#section, to get named coordinates
  from. If the name is omitted, i.e. #section or nil or empty string, then
  the current page will be used.
@returns {table} sequence of {coord, name, description} tables where coord is
  the coordinates in a format suitable for #util.parseCoords, name is a string,
  and description is a string (coordinates in a format suitable for displaying
  to the reader). If for some reason the name can't be found, the description
  is nil and the name contains display-format coordinates.
@throws {L10n.error.noNamedCoords} if no named coordinates are found.
]]--
function util.getNamedCoords(page)
	if transcluder == nil then
		-- load [[Module:Transcluder]] lazily so it is only transcluded on pages that
		-- actually use named coordinates
		transcluder = require("Module:Transcluder")
	end
	local parts = mw.text.split(page or "", "#", true)
	local name = parts[1] == "" and mw.title.getCurrentTitle().prefixedText or parts[1]
	local section = parts[2]
	local pageWikitext = transcluder.get(section and name.."#"..section or name)
	local coordTemplates = util.extractCoordTemplates(pageWikitext)
	if #coordTemplates == 0 then error(string.format(L10n.error.noNamedCoords, page or name), 0) end
	local frame = mw.getCurrentFrame()
	local sep = "________"
	local expandedContent = frame:preprocess(table.concat(coordTemplates, sep))
	local expandedTemplates = mw.text.split(expandedContent, sep)
	local namedCoords = {}
	for _, expandedTemplate in pairs(expandedTemplates) do
		local coord = mw.ustring.match(expandedTemplate, "<span class=\"geo%-dec\".->(.-)</span>")
		if coord then
			local name = (
				-- name specified by a wrapper template, e.g [[Article|Name]]
				mw.ustring.match(expandedTemplate, "<span class=\"mapframe%-coord%-name\">(.-)</span>") or
				-- name passed into coord template
				mw.ustring.match(expandedTemplate, "<span class=\"fn org\">(.-)</span>") or
				-- default to the coordinates if the name can't be retrieved
				coord
			)
			local description = name ~= coord and coord
			local coord = mw.ustring.gsub(coord, "[° ]", "_")
			table.insert(namedCoords, {coord=coord, name=name, description=description})
		end
	end
	if #namedCoords == 0 then error(string.format(L10n.error.noNamedCoords, page or name), 0) end
	return namedCoords
end

Belgium[edit]

Map
Démonstration

Coord:

Coordirection:

  • Liège {{Coordirection|50.632959|5.569750|name=Liège}}
  • Anvers {{Coordirection|51.221340|4.405149|name=Anvers}}