Help:Extension:Kartographer/Getting started/zh
主要說明頁面:
- 如何在視覺化編輯器用Kartographer建立地圖
- 目前:介紹在wikitext中的Kartographer
- Kartographer - 廣泛的幫助頁面
概述
Kartographer是一個MediaWiki的擴充功能,可讓您在wiki頁面上建立內嵌地圖和全螢幕地圖的連結,就如同是寫一行wikitext或在VisualEditor中點選選單項一樣地簡單。
本指南著重於wikitext中的地圖。
有些wiki將Kartographer的功能包裝在範本中(通常命名為Maplink
和Mapbox
)。查看本機wiki上的Kartographer說明頁面,以瞭解常用的模板。
快速入門:範例

此程式碼會在框架中產生一個簡單的250x250地圖,就像您在這節中所看到的一樣,標題是「舊金山市中心」。
<mapframe text="[[w:zh:旧金山|旧金山]]市中心" width=250 height=250 zoom=13 longitude=-122.3988 latitude=37.8013 />
加入一個地圖到頁面中
<mapframe>
要在wiki頁面上的小視窗(或框架)中添加一個地圖,請使用標籤<mapframe>
。點擊小地圖會開啟一個全螢幕的互動地圖。
- 在維基百科和其他維基媒體的維基上,內嵌的地圖是靜態的。點選靜態圖片會開啟全螢幕的互動地圖。
- 在維基導遊和test2wiki上,此內嵌地圖是互動式的。點選、按住並移動游標可以平移地圖;雙擊或點選頂部角落的全螢幕圖示可以開啟全螢幕互動地圖。
在最簡單的表單中,<mapframe>
使用下列資訊來顯示特定區域的地圖:
- 位置 (經度與緯度)
- 框架的大小(寬度和高度)
示例:
<mapframe width=400 height=400 zoom=15 longitude=13.377704 latitude=52.516275 />
For a complete explanation of the syntax as well as a list of available attributes, see the main help page.
<maplink>
Instead of an interactive map on the wiki page itself, you can also create text (with an optional marker) that links to a fullscreen interactive map, using <maplink>
.
A minimal <maplink>
tag is even shorter -- all you need is a location.
示例:
<maplink text="Downtown San Francisco" longitude=-122.3988 latitude=37.8013 />
For a complete explanation of the syntax as well as a list of available attributes, see the main help page.
GeoJSON
GeoJSON is a structured way of representing geographic information that uses the JSON standard.
A Kartographer map doesn't need any GeoJSON to work, but GeoJSON opens up a wide range of functionality that's not available in Kartographer alone, like markers, geoshapes from external sources like OpenStreetMap, special styling and more.
Composing GeoJSON
Regardless of whether you're creating your Kartographer-powered map in wikitext or the VisualEditor, you'll likely want to use a tool for composing your GeoJSON.
The GeoJSON.io editor is a great place to start, and there's this helpful guide.
What follows is a brief overview of commonly used powerful GeoJSON elements. For more in-depth coverage of the topic, see Help:Extension:Kartographer#GeoJSON and our full list of GeoJSON resources.
Markers
Instead of simply centering your map over the area you want to highlight, you can use GeoJSON to place one or more informative markers on your map.
To place a marker on your map, use the GeoJSON object "Feature"
.
You can choose the marker's exact location on the map, the symbol used, its color and size, a title, a descriptive image, and more -- including whether to use letters or numbers across multiple markers.
The example below is a good starting place; for a comprehensive list of attributes and options, see the auto-counters section of the main help page.
<mapframe text="Colorado State Capitol" longitude="-104.98491" latitude="39.73939" zoom="17" width="250", height="250">
{ "type": "Feature",
"properties":
{ "marker-symbol": "town-hall",
"marker-color": "46ea5f",
"marker-size": "medium",
"title": "[[w:Colorado_State_Capitol|CO Capitol]]",
"description": "[[File:Coloradocapitolhill2.JPG|150px]]"
},
"geometry":
{ "type": "Point",
"coordinates": [-104.98485267162323, 39.73928364167763]
}
}
</mapframe>
Shapes
GeoJSON allows you to draw shapes on top of a map. You can define simple shapes inline or import shape data from places like Wikidata and OpenStreetMap.
Though we include some illustrative examples below, much of this work is most easily done in a GeoJSON editor. If your wiki has VisualEditor enabled, refer to our guide to using VisualEditor to create maps or use this editor.
Inline
Using GeoJSON, Kartographer lets you define points (markers), lines and polygons to be drawn over your defined map area using special syntax and longitude/latitude coordinates.
<mapframe latitude="46.528635" longitude="-122.299805" zoom="6" width="246" height="272" align="right">
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {
"type": "LineString",
"coordinates": [
[-122.321777, 47.598526],
[-122.629395, 45.505662]
]
}}]}
</mapframe>
For more information, consult the Inline section of the main help page.
External data
In addition to displaying and marking up maps, Kartographer can also draw on the vast resources of geodata that Wikidata and OpenStreetMap have to offer. That data can help you highlight areas of your map using geoshapes, geographical data that describes the physical properties of an area.
Geoshapes can be rendered in three different ways, using the "service"
attribute:
"service": "geopoint"
: Draws a marker."service": "geoline"
: Draws a simple line."service": "geoshape"
: Draws a polygon with a shaded interior."service": "geomask"
: Draws a polygon and shades everything outside the polygon.
A simple example:
<mapframe text="Madagascar" width=300 height=300 zoom=4 longitude=46.523 latitude=-19.86>
{
"type": "ExternalData",
"service": "geoshape",
"ids": "Q1019"
}
</mapframe>
In addition to placing a single geoshape on your map, you can also use SPARQL queries to bring in several related geoshapes from Wikidata.
(For help writing SPARQL, take a look at Wikidata's Query Builder.)
For more information, see the External data section of the main help page.
Further resources
The world of Kartographer maps and geographical data is large, and even our main help page can't cover every aspect of it. Consult this list of resources for more information.