User:Wikid77/Template:Location map skew/doc

The Template:Location_map_skew shows a location map as a composite image of an existing map in either equirectangular projection or skewed projection, with multiple (up to 4) markers and optional labels superimposed onto it. This template functions in the style of Template:Location_map, but allows 4 markers and labels (rather than just one marker). Note: For brevity, parameters "pos" & "bg" are aliases (for "position" & "background").


 * Also see: For an unlimited list of markers/labels, see: Template:Location_map+,
 * which specifies points as a coded template list of markers/labels.

Usage
Parameter locname refers to {Template:Location map locname} containing the image name and coordinates of a particular map.

Available maps
List of live templates named Template:Location_map_  (without "Template:" prefix here):


 * [ Processes " " ]

Creating new maps

 * 1) Find an appropriate blank map in equirectangular projection (otherwise, coordinates will drift off, typically further north)
 * 2) Create a template named "Template:Location_map_locname" (copy the content of any other map template into it and enter appropriate values).
 * 3) Set default parameter values (using those parameter names), such as setting "mark" with image-file name and "marksize" for pixels wide/tall, or set default label font size ("label_size = 78" percent).
 * 4) Parameter names not used by "Template:Location_map" will be ignored by it, and only used for multiple-markers (such as defaulting "label2_size = 78" percent, or "mark2size=7" pixels).

Implementation notes
The map and markers are implemented using the typical wiki parser-functions ( "" ), described at: WikiMedia Help:ParserFunctions.

Explanation of skewing
The skewing of map coordinates, when placing markers/labels on the map image, is performed by a linear interpolation of the longitude relative to the height of the latitude (higher latitudes skew longitude more). A skew factor < 1.0 squeezes longitudes together near the top latitudes, while a skew factor > 1.0 spreads longitudes apart near the top.

The formula is roughly:


 * To skew by latitude ratio (skewing longitude more towards top):
 * skew factor = ( (1 - skew) * lat_ratio + skew ), where:
 * lat_ratio = (maxlat - latitude) / (maxlat - minlat).

Use of HTML divisions
The map with markers/labels is implemented as nested HTML divisions. The map-box is in an HTML division, containing the map-image division, then containing each point as a percent-locator division containing a marker-image sub-division plus a label sub-division. Each point is calculated (for a percent-locator division) with X or Y coordinate "XX.X%" or "YY.Y%" as follows:


 * The div-tag is "&lt;div style="position: absolute; z-index: 2; top: XX.X%; left: YY.Y%; ...&gt;"
 * For placing latitude, the calculation is:
 * XX.X% = 100 * (top - (lat_deg + latmin/60 +latsec/3600) ) / (top - bottom)
 * If lat_deg is empty, the combined decimal latitude is used from "lat".
 * If lat_dir is "S" (south), the latitude is multiplied by -1.
 * (Note latitude YY.Y% is reversed, with larger YY.Y% at bottom.)


 * For placing longitude, the calculation is:
 * YY.Y% = 100 * ( (lon_deg + lonmin/60 +lonsec/3600) - left ) / (right - left)
 * If lon_deg is empty, the combined decimal longitude is used as "long".
 * If lon_dir is "W" (west), the longitude is multiplied by -1.


 * The div-tag is ended as "height: 0; width: 0; margin: 0; padding: 0;"&gt;".
 * Within that division the marker/label sub-divisions are coded as:
 * &lt;div style="position: relative text-align: center; ..."&gt;.


 * For label position, the options are shifted as:
 * when position=left, adds "left: -6.5em; text-align: right;"
 * when position=right, adds "left: 0.5em; text-align: left;"
 * when position=top, adds "top:-2.65em; left:-3em; text-align: center;"
 * when position=bottom, adds "top:-0.15em; left: -3em; text-align: center;" to div-tag.

Accuracy of numeric calculations depends on the particular wiki server handling the webpage.