Jump to content

User:Bellezzasolo/Location Maps

From Wikipedia, the free encyclopedia

Hello. I am Bellezzasolo, a Template Editor on English Wikipedia, and this is my guide to location maps. First a quick FAQ.

  1. What is a Location map?
    • A location map is Wikipedia’s system for displaying maps of encyclopaedia entries, when appropriate. So an article on a person doesn’t get a map (normally), the Golden Gate Bridge does (a person can move, the bridge doesn't tend to go for walks).
  2. Where in the article should maps go?
    • Location maps often are placed in the Infobox. However, other positions can be appropriate depending on the article. For example, an article about the Wars of the Roses has a map (not a location map) in the article body. Some articles don't have an infobox, and some infobox templates don't support maps.
  3. Infobox templates? What's a template?
    • Please see my below section on templates
  4. I know about templates, should I skip the section?
    • Feel free to skip any section with which you are comfortable (or indeed not, I'm not forcing you to read this!). However, I often find the different writings on a topic about which I know can bring a different perspective.

My involvement with maps

[edit]

As a template editor, I am able to edit high use templates and modules on Wikipedia (I'll explain more in later sections). I'm fairly involved with the mapping templates. These are used on as many has half a million pages, so only Administrators and template editors can change them. I study Computer Science along with Maths, so am quite technically minded (helpful, but certainly not required to help with templates!). I am more than willing to answer any questions you may have, ask me on my talk page.

Modules and templates

[edit]

Wikipedia articles, in the main, are written in a manner similar to using a word processor. We even have the visual editor. However, wikitext is a markup language. One of the more advanced capacities of this language is reusing commonly used code. Infoboxes, which are used on 52% of Wikipedia articles, all use the same basic template. Rather than rewriting the code 3 million times, then fixing 3 million separate articles, instead we have the page Template:Infobox. The contents of the page are included wholesale (mostly, there are caveats) by writing {{Infobox}} in the source editor (visual editor will prevent the infobox from being generated, and generally struggles with templates as of writing).

Modules are an extra level of learning beyond templates. While templates are largely written in wikitext, albeit with special syntax, modules are written in the programming language Lua. This is OK, but you need to learn a fully blown programming language to edit them. There are more areas to make mistakes - as an anecdote, an experienced template editor was caught out by a function that looks for a certain sequence of characters. When it finds it, it returns the number of occurrences. When it's not found, it doesn't return 0. It returns none, which is not a number. Comparing it to 0 caused an error - displaying ugly red text.

The above anecdote is a cautionary tale, it shouldn't put you off. Modules are highly technical, but that is surmountable. When mastered, modules can perform functions of which templates are not capable. The learning curve is steeper, but the rewards are greater. Modules power the location map suite of templates. From a user standpoint, modules are generally used through helper templates. The contents of the template are typically a single {{#invoke:}} statement.

Don't worry too much about the danger of breaking millions of pages - you probably can't. Any template used on a really large number of pages, is protected. Either template protected, like {{Infobox}}, or fully protected, like {{cite web}}. And, due to the way MediaWiki software works, any mistake you make won't immediately affect thousands of pages. The software runs a job queue, which updates the affected pages. For anything more than 500 pages, the changes won't show up on all pages immediately- for the most used templates, this process can take over a week to complete. Plus, if you follow my advice on good editing practices, you're unlikely to break anything anyway.

Good editing practices

[edit]

Most heavily used templates have a sandbox, at the /sandbox subpage. Even if the template is protected, you will be able to edit the sandbox. This is the place to test changes. There is an accompanying page /testcases, which will have a number of different samples of the template, alongside the sandbox version. If a template does not have a sandbox, you can always create it! Testcases should not generally change in appearance, at all. If your change intentionally changes the appearance of a template, then you should discuss the change before implementing it, preferably at the Village Pump. The more pages affected, the more crucial this is. The advice about being a Template Editor is good advice, you don't need the user right to apply it! Note that adding new parameters also generally requires discussion. Of course, if you're writing a template from scratch, and it's still fairly new, you're unlikely to meet objections to your changes. However, you still don't own the template.

Parameters

[edit]

The main power of templates comes from parameters. Needless to say, modules take parameters too. More can be found on the page about Templates, but when you edit an article, they look like |name=Bellezzasolo. In the template, any occurence of {{{name}}} is replaced with Bellezzasolo. Generally, wiki syntax works in parameters too, although there are some pitfalls (the preview function is really useful here).

The Location Map templates

[edit]

So, now you know what templates do, we can cover location maps. The most used location map template is {{Location map}}. If you want a map with more than one marker, you can use either {{Location map+}} or {{Location map many}}. These all use the module Location map. The multiple marker templates also use Location map/multi.

Using the templates

[edit]

The template pages have a documentation page, which is helpfully included when you visit the template page (the green box). However, there are a number of different cases to be aware of. Often, more developed infoboxes will automatically display a location map - they actually contain a {{Location map}} call. There is no universal convention for these templates. However, there are general comments. Geographical infoboxes (i.e. the ones to which you add maps) mostly take a coordinates parameter (it may be |coords=, |coordinates=, both may work, or neither may work and the name is more exotic). As always, read the template documentation. Generally, you pass these using the {{coord}} template, whereas the map templates take |lat_deg= and |lon_deg= seperately. If the template has no documentation, try reading the template source to work it out. The other parameter taken is which map to use (more details later). This looks like |location_map=, |pushpin_map= or similar. Less advanced infoboxes will often have a parameter by this name, but you will have to pass the whole {{Location map}} template call. Often, the more advanced templates will allow both formats (so you can pass a {{Location map+}}, if you desire).
If the map is placed in the article body, you almost always will have to invoke the template in full.

The map parameter

[edit]
Bellezzasolo/Location Maps is located in Oxford city centre
Bellezzasolo/Location Maps
Carfax Tower, shown in Oxford City Centre (Oxford (central))...
Bellezzasolo/Location Maps is located in Oxford
Bellezzasolo/Location Maps
...the whole of Oxford (United Kingdom Oxford)...
Bellezzasolo/Location Maps is located in the United Kingdom
Bellezzasolo/Location Maps
...within the UK (United Kingdom)

The location map templates take the map to display as 1, or the first unnamed parameter. This is passed as |map name (no equals sign). The templates are capable of displaying more than one map, with the marker suitably positioned on each. This is done by seperating the maps with a '#' sign. This parameter is used to look up map data, consisting of the image to display, as well as the information required to position the marker (generally the coordinates for the edges of the map). These are found at Module:Location map/data/<map name>. For example, the location map United Kingdom Oxford is found at Module:Location map/data/United Kingdom Oxford. Some older maps use the alternative format Template:Location map <mapname>, e.g. Template:Location map Slovakia. There is an ongoing effort to migrate from the latter format to the former, hence the deleted template.

Captions

[edit]

Below the map, a caption will be displayed. This is done using the |caption= parameter (again, infoboxes can and do use different names). For multiple maps with captions, use a '##' sign to split the captions.

Positioning of markers

[edit]

Most maps you will encounter are equirectangular projections, or very close thereto. The module will automatically calculate the position of markers based on this assumption. To this end, the map data typically returns a left, right, top and bottom parameter from which the position of the coordinates provided are calculated. However, the module also supports non-equirectangular projections. For example, Module:Location map/data/Russia is an equidistant conic projection.

Moscow is located in Russia
Moscow
Moscow
This isn't a rectangular projection...

Lua error in Module:Location_map at line 526: Unable to find the specified location map definition: "Module:Location map/data/Russia (equirectangular)" does not exist.

Non-rectangular projections are implemented using the alternative parameters x and y. These should return 0 for the left/top and 100 for the right/bottom, taking latitude as $1 and longitude as $2 (as was documented on the USSR location map). Using this system requires a knowledge of spherical geometry, I do not recommend using it unless you absolutely have to.

Getting the map image

[edit]

When making a location map, you may wonder where to begin. Unless you're skilled with cartography, you're unlikely to want to draw the map. You may think to screenshot google maps. Please don't, this is a copyright violation. Instead, generally, data from OpenStreetMap can be used. OpenStreetMap is the page. The export button looks tempting, but generally shouldn't be used. Instead, on the right hand side, there is a toolbar with a share button. When you have chosen an area to display, use the share button. With the image subsection, export as SVG if possible. This can cause problems saving the resultant image on mobile devices, in which case use PNG.
Getting coordinates of edges - with the above technique, you now have an image, but no obvious coordinates for the module. These can be found in the URL - for example, render.openstreetmap.org/cgi-bin/export?bbox=-1.2802934646606448%2C51.748713979726574%2C-1.247076988220215%2C51.765104316529886&scale=10711&format=svg. Of importance here is the bbox parameter. This is of the format left,bottom,right,top.