Template:OSM Location map/doc

This template provides a map in a frame, for any location and scale. At its simplest it can simply show the OpenStreetMap image and a scale indicator for a given area of land. Optionally a range of marker, label and annotation tools are available to include location markers, labels, numbered dots, a heading, caption, mini-locator map and overlays. The map also provides a link to an 'Interactive fullscreen' version.

Purpose
OSM Location map allows an editor to include a map in a frame for anywhere in the world, at any scale from the whole world down to one or two streets. It makes use of the OpenStreetMap mapping data, and enables a place-based page or topic to simply show the area being described, without the need for pre-determined map templates or external graphics. The underlying map will be updated and improved automatically as the OSM data develops. A zoom level appropriate to the topic can be selected and a scale marker is provided in the bottom right corner. This only offers a rough guide to the distances on the map, as the map projection results in scale changes depending on the latitude. Some allowance has been made for this, but only in large 20 degree chunks.

The map can also be made to show multiple marks, images and labels (currently limited to 60). The resulting framed map also has a link to an interactive full-screen version, which shows the same location 'over the top' of the current page. This is not able to show any text or other images, so is limited to pointer marks. However in other respects it has a richer map interface, can be re-scaled and panned by the user, can be given popup thumbnail images and captions on the marker points, and also provides yet further links to access a wide range of maps, satellite images etc. (The fullscreen option uses the
 * }

Single marker
By using mostly default settings a map with a 'Red pog' marker and dark red label can be produced. The example below also adds some additional items (the last three parameters) that are used by the Interactive fullscreen version.


 * Code blank

Multiple markers, labels and images
In addition to the un-numbered mark parameter set, there are 60 numbered ones. These are otherwise identical to the one above, but the name terminates in a number (1-60). Each mark and label has its own set of parameters (mark1, mark-coord1, label1, label-pos1 etc...mark2, mark-coord2, label2, label-pos2 etc.) Values can be inherited either from the 'mark1 master parameter set', or from a special 'markD' Default set that provides override defaults. When set, these values are inherited by the other numbered sets to avoid having to repeat for each, whilst they can still be set individually where required.

Inherited values
To minimise repetition of code, there is a sliding scale of inheritance that applies to each value in each parameter set. For example, if  is set, that will always take precedence. If label-size4 has not been set, it will inherit the value from the special Default setting (defined using ). If no Default has been set, it will inherit the value set by the 'master parameter set',. If that is also undefined it will fall back to the underlying default, which in the case of label-size is 12. The same is true of all the variables relating to marks and labels, (although not to the coordinates, labels themselves, or mark-titles, which are always unique to the particular mark they relate to.)

Adding a Minimap in the left or right corner
Many pages with info-boxes already include a locator map to give readers a proper sense of where the topic or place is located within a broader area. For those that don't it might be helpful to include one within your map. The underling 'Graph' module that OSM Location map uses offers a built-in map of the world option, which will act as a mini locator map and automatically adds a red locator dot. Unfortunately it is too general for most purposes, so an alternative, but rather less automated, option is to make use of an existing 'Location map' file. This can be seen in the Llanfechell map example.

The width and height of the Location map both have to be decided upon, specified (and calculated so as to not distort the map dimensions). Some location maps may already highlight the feature, but if not, an optional locator 'pog' can be placed by calculating and specifying the minipog-gx and -gy values, using a 100x100 grid across the minimap. (so gx and gy values of 25 and 50 would place a dot a quarter of the way across and half way down the minimap. It does not pick up or use latitude and longitude values. The origin (0,0) is in the top left of the minimap and the map itself defaults to the bottom right corner, but can also use,   and  . The dot will remain in the right place even if you subsequently choose a different size for the minimap. (Note, the now redundant minipog-x and minipog-y are retained for compatibility. These used the same pixel dimensions as the width and height of the map, which made them harder to calculate/guess and needed to be re-done if the size was changed. Much better to use gx and gy from here on.

If the area of the actual map is a large portion of the mini-map, an open red box can be included instead of a dot, so as to show the bounds of the main map. To use this feature, simply specify the width of the required box:  where xx = the percentage of the minimap width for the box. In general anything much below xx=15 will be better served by a dot. The required width will require some trial and error to pin down. The box height is then matched in proportion to the actual map and will scale if the minimap size changes.

Text on an arc
Text for broader geographic features can be placed around an arc, to convey a sense of a broader area, or to follow the curve of a river, mountain range, coastline, etc. This works entirely separately from the other labels. It does not attach itself to any mark or dot, and does not create any fullscreen markers. It requires coordinates for the first letter, parameters for the starting angle, radius of arc and gap between letters. Text size and color can also be specified, or inherited from Default settings.

Alternative marks
Instead of using the standard 'Red pog' for mark points on the map, other images can be used. Any image from Wikimedia Commons can be specified. The Pentre Ifan example above uses 'Archaeological site icon (red).svg'. If a particular image file is specified in, all subsequent marks will use it as well unless they name their own image file. If the image is not square, a dimension value also needs to be set (width ratio for a height of 1)

Transparent overlay
A marker image does not have to be small and opaque. A larger overlay image (with a transparent background) can be used to show particular features not included in the base map, such as a town's former walls (see the adjacent map). Such images can be created in several ways (such as tracing over a copy of the base map); they are invoked like any other marker image file. (For a detailed guide to creating and deploying an overlay for these maps see User:J. Johnson/OSM overlay how-to).

Text color
Color of label text can be specified using. Standard html colors can be specified by name, and any color can be specified using the hex triplets coding #xxyyzz (see Web colors). However, to create a consistent look and feel across the wikipedia maps, there are some OSM Location map specific colors, with a more muted tone range that fit well with the color scheme of the base maps. In general it is best to make use of this range, unless there are good reasons for using other particular shades for specific features. Under normal usage, the following label color scheme should be followed:-

Shape opacity and giving a shape a halo
With the 2021 changes to how the maps are displayed it has become possible to use opacity settings for the built-in shapes, to allow for transparency of both the shapes and outlines. In implementing this, it also became possible to offer a semi-transparent halo around built-in shapes and also around marks such as Red pog.svg. The table below shows a variety of possibilities for using these features.

Text effects

 * multi-line label: Where label text is too long to fit on a single line, using, two further label lines can be used:   and.


 * Label with no mark: If  this has the effect of a free-floating label with no marker


 * Angled label: It is possible to specify a, which will pivot the label text around the centre of the marker point by the specified angle. Using an angled label which also has no marker is particularly good for labelling various geographic and linear features. A more characterful alternative is to set the text on an arc, using the ArcText options, illustrated by the 'Preseli Hills' text on the Pentre Ifan map. For stylistic consistency settlement and building names should not normally be given an angle.

Numbered dots
If numbered dots are needed, instead of (or as well as) text labels, this can be achieved using the built in shapes. For example,  will place a numbered dot at that coord position (or   for letters). Generally it is much better to use the dots in sequence, so each numbered mark gives a numbered dot, and they will match the full screen ones. If  then the caption will generate a numbered list using the   entries. For example:-

The other built-in shapes can be used in the same way (,  etc.). The  value sets the colour for the number (unlike normal, when it sets the shape-outline), and as with the others, only the   parameter values need to be set, to establish the default for this map, which can be overridden as required. The  parameters can override the automatic numbers or letters to use your own values for each mark. Flushing Meadows-Corona Park map is a useful real life example in template form.

Use in infoboxes
OSM Location map can be imbedded in infoboxes which allow the  parameter, for instance infobox school by using the instruction. For an example, see St John Fisher Catholic School which uses the map to show its two sites within an infobox map. Some infoboxes also allow it to be incorporated within the caption below an image. However, this only works if an image and some caption text are also present. (see Inishmore Lighthouse).

Underlying technology
OSM Location map itself has no map or display ability of its own. Everything within the frame is produced through the template Graph:Street map with marks, created by User:Yurik. This in turn calls internal processes that turn all the data supplied at edit time into a rendered bitmap image, so that there is no calculation overhead by the time the page is read by a user, any more than any other commons image.

Whilst the map is being edited and previewed, the page is supplied with a rasterised image, collating the base-map, marks, labels, etc. on the fly. It will be particularly noticeable on small fonts that when the 'Publish Changes' button is pressed, the resulting bitmap has much worse fonts than the preview. (Maybe this will be improved at some point). The process of updating the map image and providing the right bitmap is all handled internally and invisibly. One of the consequences of the 'bitmap' solution, which is different from the standard Location map method, is that there is no text or objects on the final image, so there is no possibility of adding wikilinks within the template.

The full screen option, which can be clicked through from below the map, provides an entirely different mapping approach, using the same base-map data. This provides an interactive map that can be panned and zoomed. It also replicates (although at present only as numbered markers) the various marks from the page map. These can then be given more content, by way of a title, caption and image along with displaying the coordinate values. The caption and title can then be given all the wikilinks and other markup features that may be desired, providing a map-based page that will offer another way of engaging with the article content.

Future development of the various mapping technologies is likely to result in further options for showing maps on Wikipedia. In particular, maplink, which initially just created a text link to a full-screen map, can now create a framed image including dot-markers, roads, boundaries, etc., and can acquire data directly from wikidata to do this. Again, the processor overheads are reduced by initially showing a bitmap, which can be clicked to become interactive within its frame. Maplink is being effectively rolled out within info-boxes, where the map is automatically generated from already available data.

This template, on the other hand, is probably better suited to a hand-editable map, in which the area displayed and the selection of items and labels included are selected, edited, and added to, to suit the specifics of the subject in hand. A further approach, which is not currently supported within this template, but is available via the inderlying Graph:Street map with marks template, is to draw the data from Wikidata, using a SPARKL query that provides the selection of marks requested.

The 'Graph' technology used here is described as under development, so while it is highly likely that this or a similar solution will still be available, it may evolve over time.