Help:Extension:Kartographer

This page documents how to use the kartographer>Extension:Kartographer|Kartographer extension and its   and   tags.

Getting started


This code will insert a simple interactive map (like what you see on the right), with the ability to maximize it by either double-clicking the map or clicking the icon in the right corner.

You may use the   parameter to override default alignment to left, right, or center.

  usage
 { "type": "Feature", "geometry": { "type": "Point", "coordinates": [-122.3988, 37.8013] }, "properties": { "title": "Exploratorium", "description": "", "marker-symbol": "museum", "marker-size": "large", "marker-color": "0050d0" } }

The content of the   tag has to be either empty or a valid GeoJSON with styling, as produced by a [http://geojson.io/#map=15/37.7977/-122.4057 GeoJSON editor]. Kartographer supports the [https://github.com/mapbox/simplestyle-spec/tree/master/1.1.0</> simplestyle specification] with maki>Maps/Icons</>|Maki icons (Licensed under Creative Commons Zero).

Frames
Frameless maps are good for insertion as part of a template, whereas framed maps are good for insertion directly into the page, either by hand or by using the visual editor.


 * To insert a map without a frame, add the "frameless" attribute:
 * To add a caption, use the  attribute.

Note: Adding the text attribute automatically enables a frame, even if there is a  attribute.

== </> to <tvar|maplink> </> creates a link to a full screen map:

<tvar|maplink> </> also accepts an extra parameter "text" to specify link text instead of the coordinates:

The <tvar|maplink> </> tag may contain the same geojson as <tvar|mapframe> </>.

=== <tvar|maplink> </> creates a link that shows a full screen map when clicked. The link text can be set with the <tvar|text> </> attribute. Without this attribute, the coordinates will be shown (example: </> is set to the magic <tvar|minusnumber> </> or <tvar|minusletter> </> value. In this case each <tvar|minusnumber2> </> will be replaced with an incremental counter <tvar|onetwothree> </>, and <tvar|minusletter2> </> with <tvar|az> </> values.

If GeoJSON has more than one counter, the value of the first one will be shown as the link text. Optionally, editors may add a suffix to have multiple counters on the page at the same time. This way <tvar|numbermuseum> </> will have different counter from <tvar|numberbar> </>.

It would make sense to use a distinct color for each counting group. All data added via <tvar|maplink> </> will also be shown in all maps inserted with <tvar|mapframe> </>, unless the <tvar|group> </> attribute is used.

could be expanded into

The attributes <tvar|zoom> </>, <tvar|latitude> </>, and <tvar|longitude> </> control the location of the popup map. Use <tvar|text> </> for the text of the link (could be any valid wikitext markup). Use <tvar|group> </> to add the contents of this tag to the named group (see below).

Groups
For use on the Wikivoyage project, there is a need to show a map whose data is defined somewhere else on the page. For example, there may be multiple points of interest (POI) defined with <tvar|maplink> </> tags, and one common map on the side of the page that shows them all.

The grouping concept allows editors to share data between multiple <tvar|mapframe> </> and <tvar|maplink> </> tags.

By default, the data inside the <tvar|mapframe> </> or <tvar|maplink> </> tag is shown only for that one tag, and will not be shown anywhere else.

If <tvar|mapframe> </> or <tvar|maplink> </> specify the <tvar|group> </> attribute, the data inside those tags will be placed into a named group, together with all the other data by the same group name. As a result, any tags with the same group name will show the same map data, and each tag may incrementally add data to the group.

A tag may also show other groups, regardless if it belongs to a group or not, by specifying the <tvar|show> </> attribute. Comma-separated multiple group names may be specified. The group name may only contain lower case English letters. This matrix shows what data will be shown for each tag.

External data
<mapframe text="A geoshape of Alaska" width=300 height=300 zoom=3 longitude=-152.58 latitude=64.01> { "type": "ExternalData", "service": "geoshape", "ids": "Q797" }

In addition to drawing polygons using GeoJSON, you may also get outlines of the well known geographical objects by their Wikidata ID if they are marked as such in the OpenStreetMap database. For example, the Wikidata item for Alaska is Q797, and we can draw it on a map by using the "external data" reference. More than one ID may be specified separated by a comma.

To create a mask over the areas of interest, use the "geoshape" service. To invert this and create a mask over everything else, use the "geomask" service.

Note: Wikidata IDs are relatively new to the OSM community. There are only about 40,000 polygons with IDs. To add more, visit https://www.openstreetmap.org/ and add <tvar|wikidata> </> tag with the  value. The data should become available to Kartographer within 2 days.

GeoShape by Wikidata ID with properties
<mapframe text="Interstate Highway I-696" width="300" height="300" latitude="42.4883" longitude="-83.2297" zoom="9"> { "type": "ExternalData", "service": "geoline", "ids": "Q2108", "properties": { "title": "Highway I-696", "description": "", "stroke": "#ffb100", "stroke-width": 8 } } For external data, you can also add styles and titles, using the properties keyword.

The main style keys are: "stroke" (color), "stroke-width", "stroke-opacity", "fill" (color), "fill-opacity".

Combining multiple data types
<mapframe text="Caderousse city wall" width="300" height="300" zoom="15" longitude="4.75600" latitude="44.10200" > [ {    "type": "ExternalData", "service": "geoshape", "ids": "Q13518258", "properties": { "stroke": "#ffb100", "stroke-width": 6, } },  {    "type": "Feature", "geometry": { "type": "Point", "coordinates": [4.75566, 44.104498] }, "properties": { "title": "Porte de Castellan" } },  {    "type": "Feature", "geometry": { "type": "Point", "coordinates": [4.75829, 44.10258] }, "properties": { "title": "Porte Léon Roche" } } ] You can also combine ExternalData, Feature, and FeatureCollection together in the same &lt;mapframe> or &lt;maplink> element

GeoShapes via Wikidata Query
<mapframe latitude="52" longitude="-110" zoom="3" width="500" height="500" text="Governors of US states with their party affiliation"> { "type": "ExternalData", "service": "geoshape", "query": " SELECT ?id ?head (SAMPLE(?img) as ?img)   (min(?partyId) as ?party)   (if(?party = '0', '#800000', if(?party = '1', '#000080', '#008000')) as ?fill)  (concat(, ?headLabel, ) as ?title)  (concat(?stateLabel, '\\n', '') as ?description) WHERE {    ?id wdt:P31 wd:Q35657 .  ?id wdt:P6 ?head .  ?head wdt:P102 ?party .  BIND(if(?party = wd:Q29468, '0', if(?party = wd:Q29552, '1', '2')) as ?partyId)   SERVICE wikibase:label {    bd:serviceParam wikibase:language 'en' .    ?head rdfs:label ?headLabel .    ?id rdfs:label ?stateLabel .  }  OPTIONAL {    ?head wdt:P18 ?img .  }  ?link schema:about ?head .  ?link schema:isPartOf <https://en.wikipedia.org/> . } GROUP BY ?id ?head ?headLabel ?link ?stateLabel "} While this helps with the simple use cases when the Wikidata ID is well known, sometimes you may want to get a list of IDs as a result of a Wikidata query. A SPARQL query gets a list of all US states in the ID column of the result, and geoshapes service adds the geometrical outlines for each state. All other columns in the SPARQL query result become values in the "properties" object. The "fill" column changes the color of the state. The "title" column shows state governor's name, and "description" has wiki markup to show the state name and the governor's picture. To edit this query, copy the query parameter after the "#" symbol at ''' https://query.wikidata.org/#... ''':