User talk:Matroc/Mapdraw2

From Wikivoyage
Jump to navigation Jump to search

General Info[edit]

This is based on experiments and a revamp of an earlier Module that I had created in order to add a little flexibility to maps.
Further work will stop at this time and will be making notes an hopefully clarifying any information provided.
Anyone can comment if so desired and I think this may be worthwhile.


  • Specialized use only - not to replace any existing templates/modules but to add shapes to a map.
  • Used to build a mapframe or different style maplinks and display any shapes contained in the list below and produce Kartographer <mapframe> and <maplink> code directly. (GeoJSON)
  • Available shapes:
x, arrow, box (square), equitri (equilateral triangle), star, star2, multiside, ellipse, boxframe, crescent, cross, rhombus, diamond, sun, pointer,
stadium, hexagram, bar, kite, annulus, wedge, keystone, cog, pentagram, rectangle (simple stylized rectangle), point and line.
A special shape empty was introduced in case no shape is desired and a blank mapframe or maplink is to be created.
A New shape external is for OpenStreetMap - geomask, geoshape, geoline and page. Used to retrieve a mapshape or file from Commons.
  • A Lua module (User:Module:Sandbox/Matroc/Mapdraw2) was created to provide calculation and other work associated with the template User:Matroc/Mapdraw2. The module itself should probably be rewritten in a much saner manner and approach. Different methods were used to calculate and build shapes making the argument for revamping.
  • A special template is called to produce the mapframe or maplink (Note: Template used to make a single standalone mapframe or maplink)
Template makes use of {{#tag:mapframe... or {{#tag:maplink... to quickly build and make these elements live. User:Matroc/Mapdraw2 is current experimental template.
Template provides some default parameters when calling the module Mapdraw2 and the module provides several internal defaults as well. Reminder that not all parameters are required - test it out.
This makes use of the group and show parameters. (not all sites do this)
Rather than make a large number of templates and modules - all of this is contained within 1 template and 1 module.
  • JSON errors mostly occur when an id or lat,long parameters are missing. (in rare instances, an id may not point to a Wikidata record that has a latitude or longitude associated with it. This may produce an error that may be cleared up by adding lat and long parameters as well). Bad format of fill, color parameters or other simple editorial mistakes - so there is an incentive to check your parameter data. An error may occur if a mapshape in OSM or file in Commons does not exist.

Mapdraw2 Template[edit]

  • Template parameters: Not all parameters are required as template and Module have built in defaults. Will try and clarify a bit as there are different choices or options available for certain shapes.
Parameter Description
map frame, link, linkc or hidden. (determines what to make ie. a mapframe or maplink) - Required
type poly, line - produce a polygon or just a line for most shapes. Default is poly. In a few rare instances type is not used.
shape shape to draw in a mapframe or maplink - see list above. (empty builds no GeoJSON code - thus can have a basic mapframe or maplink). Some shapes appear centered on the coordinates (lat, long) or point to the position.
zoom default is 10 for mapframe and 17 for link, linkc as issue with popup map when using zoom. (template marker has same issue)
width width of mapframe (default 420)
height height of mapframe (default 420)
align default right for mapframe
group default group is shapes or enter a different group name as desired.
show enter groups to show or display - ie. show=sites,see,vicinity or leave blank and only members of those groups will appear
direction some shapes can be placed facing a direction ie. horizontally (h) or vertically (v) or according to 8 points of a compass (1-8) - equitri (1-8), ellipse (h or v), bar (h or v), rhombus (h or v), arrow (1-8), wedge (1-8) and pointer (1-8). Default of h or 1 are used.
id Wikidata ID ie. Q20 - used to build lat long if parameters lat & long are not available. Not capturing an article's id at this time in the (frame) argument used by the the Mapdraw2 module. id is required when building mapshapes from OSM.
id2 only used to create a line from coordinates found in wikidata id and id2
lat latitude 90 and -90 - if no id then lat and long should be provided
long longitude 180 and -180 - if no id then lat and long should be provided
lang proposed internationalization for mapframe ie. lang=jp (2 char code) or lang=local
radius size is based on radius of a circle - default is .5, MAX set at 10 -- and can not be less than or equal to 0 -- .00010 is about 40 meters, 3 is about 50 km (large range of sizes available)
fill fill color for type poly (polygon) ie. #ff0000
fillopacity opacity of fill color -- values 0.0-1.0 - 0.0 being none and 1.0 being solid (use decimal places) The higher the opacity, makes the filled in area darker and almost blanks out the underlying streets, names etc. on the map.
stroke color of outline of polygon or line ie. #ffccff
strokeopacity opacity of outline of polygon or line -- values 0.0-1.0 0.0 being none and 1.0 being solid (use decimal places)
strokewidth thickness of outline of polygon or line -- defaults set to 1 - value >= 0
title title to be part of popup found in displayed shape
class icon or no-icon - default icon - used basically for maplink
text name placed at bottom of a mapframe map or text used for maplink on a page - text has this double use. Certain characters will need to be backslashed in order to appear correctly.
desc description as part of popup in shape. Not only can one use actual text but an Image may be used within a description. If one uses " in a description it should be entered as \". Multi-paragraphs can be separate by </br>. Note description text normally appears with centered lines. Only point shape has been coded to start at left, right or center using parameter descattr.
descattr l (left), r (right), c (center) --- Under development testing. Default is c or center.
sides number of sides - used in multiside only - (can be used to draw a circle 90+ would suffice for sides parameter). The default is 3 (triangle). 4 can produce a square, 5 a pentagon, 8 an octagon etc.
geotype geomask, geoshape, geoline (to be used to create shape from OSM - requires id) and page (page to be used with shape=external requires file to work with data file in Commons). These are used with shape=external
file name of file found in Commons - required if geotype=page and shape=external - these are virtually complete as far as code goes and does not need many of the parameters listed.
symbol symbol specific to creating a Point - use with shape point only - maki (city, town, zoo etc.) -letter or -number (with or without counter names) not recommended as output may be slightly different from that which one would expect - see testing pages
color #ff0000 - color specific for a Point - (city symbol in red)
size small, medium or large size specific for a Point - default is medium.
  • Will attempt to clarify parameters somewhat.
  • Considering multiple point, multi-line and other types but not at this time as well as creating and/or eliminating some defaults.

Mapdraw2 examples[edit]

  • Example Code to create mapframe shown here:
{{User:Matroc/Mapdraw2 | map=frame | text=A FRAME TEST | type=poly | shape=pointer | direction=6 | lat=41.9032 | long=12.4526 | radius=.004 | fill=#ff0000 | title=An example of a pointer | zoom=10 | show=shape,hidden }}

Maplink samples[edit]


  • This maplink has an icon and a word to click on Africa that will display a six sided shape.
  • This maplink has just an icon and sill display a boxframe somewhere in Norway.
  • This maplink has words to click on click me and displays a Point with a Maki symbol for city.
  • This maplink has words to click on click me and justs goes to place on map just as in a marker.



  • In addition, the main mapframe on this test page has a number of links (shapes) not referenced in page text. Open up full map found on page, zoom out and you should see small yellow crosses (World War I sites from listings found on wikivoyage page World War I)

{{User:Matroc/Mapdraw2 | map=hidden | group=hidden | type=poly | shape=cross | radius=.5 | fill=#ffff00 | title=Battle of Vittorio Veneto | lat=45.955833 |long=12.346944 | desc=Marked the end of the WWI on the Italian front. }}

  • Build a frame using OpenStreetMap (geoshape) - Mapframe for Uttarakhand. Image added as well as text. link for image goes to Wikivoyage article. Descriptive text added as well.
  • OSM link for original Llanfairpwllgwyngyll external shape no longer available changing frame example to Uttarakhand.

{{User:Matroc/Mapdraw2 | map=frame | group=shape | show=external,shape,hidden | type=poly | shape=external | geotype=geoshape | fill=#ff00ff | title={{flag|India}} Uttarakhand | text=Uttarakhand | id=Q1499 | zoom=6 | descattr=c | desc=[[File:Nainital-Hills-Udayan.JPG|link=Uttarakhand]] [[Uttarakhand]] (Hindi: उत्तराखण्ड), until 2007 known as '''Uttaranchal''', is a stunningly beautiful state in the [[Himalayan North]] of [[India]]. }}

  • Build a frame using external file from Commons - ie. a highway in Israel

{{User:Matroc/Mapdraw2 | map=frame | group=shape | show=external,shape,hidden | type=poly | shape=external | geotype=page | title=Israel Highway | file=IsraelHighways/ | zoom=8 | lat=31.914271 | long=35.084371 }}