Extension:Kartographer

Kartographer is an experimental extension to add Maps to Wikis. It is very similar to Maps extension, but its functionality will be specifically targetting Wikimedia communities such as Wikivoyage and Wikipedia.

Goals

 * A simple method to insert a map into an article without requiring common.js code changes
 * Ability to add extra information (marks, area, popups, text, links) to the map
 * Ability to generate static images on the server with all the extra layers (faster loading, allows to print)
 * Ability to incrementally add features to the map. For example, each usage of the restaurant template in WikiVoyage adds a single point of interest (POI), and the map shows all of them.
 * Multiple items added` independently need to be indexable. E.g. the first restaurant template would show [1] on the page, and map would show POI as a clickable [1] element. There could be multiple index counters at the same time, each for its own type of POIs.
 * Ability to gather map usage statistics (KPI) to better gauge how and what should be improved.
 * Path for experimentation - if the user is aware of the privacy implications, the map should be able to show external data from non-production source, e.g. wmflabs. TBD: Static, server-side rendered images will not include the extra data added via this method until the extra data source is hosted in the secure production environment and can be shown without the user action.

Usage Ideas
The simplest but not very useful map that will be shown as a static image, but if clicked, becomes interactive. This inserts a default static image of a map that does not allow any user interactions. The map is rendered on the server and will be very fast to load. All above parameters are mandatory.

Adding Data
The content of the tag has to be either empty or a valid GeoJSON with styling. The content of the tag may also contain any template expansions, such as Template:TemplateName or default value. This should not cause any problems because the "{{ " is an impossible construct in JSON.

Map Modes

 * Show the map as a static image at first, but upon clicking, it will become interactive. This allows much faster initial map loading, and saves on bandwidth and power until user actually wants to browse the map.
 * Same as, but instead of expanding on click to full screen, it will become interactive but will stay within the same size.
 * Show provided wiki markup as a link. Clicking the link shows a map as a popup window of a width x height size or as full screen.
 * Do not output any wiki markup, but store the data to be used by the map.

Combining Data (for Wikivoyage & Lists)
Wikivoyage tends to have a large number of POIs, such as museums and restaurants, listed on a page. Each POI is usually added with a template, but all of them should appear on the same map. Also, each POI should be referable by showing an icon with a number, both in the text of the article, and on the map.

To help with that,   has a data mode. All features of all  tags in data mode will be combined together, in the order appearing on the page, and can be shown together by using   attribute.

Optionally we could introduce a grouping concept - if there is more than one list on the page, and they should not be shown together on the same map, we could specify  attribute on the data tag, and a   key in the feature. Lastly, we could even introduce cross-page by specifying  value to point to the data on another page.

Why Is This So Complicated?

 * A popup link, like the green square here, needs to be a tag with JavaScript, so it has to be generated by MediaWiki
 * The popup's appearance must be customizable by the community
 * Part of the link's appearance must be the sequential index, in the order of appearance on the page. We do not support any parser functions with a state, such as counters, for performance reasons (parallelism). Cite extension has an elaborate way of working around this problem, and we would have to implement something similar, including Parsoid support.
 * The appearance of the link, such as the green square, needs to be the same in three places: on wiki page, on the map rendered client-side with Leaflet, and on the map when rendered in the Kartotherian's static service. So even though it will be rendered by different systems (i.e. HTML, Canvas, SVG, WebGL), the code that generates should hopefully stay in one place.