模板:Maplink/sandbox
外观
| 这是Template:Maplink(差异)的沙盒。 参见本模板的测试样例。 |
| 此模板沙盒被引用于许多页面。 为了避免造成大规模的影响,所有对此模板沙盒的编辑应先于沙盒、测试样例或您的沙盒上测试。 测试后无误的版本可以一次性地加入此模板沙盒中,但是修改前请务必于讨论页发起讨论。 模板引用数量会自动更新。 |
| 此模板使用Lua语言: |
本模板使用维基数据资源:
This template uses the OpenStreetMap tag:
概要
[编辑]本模板用于显示地图资讯的连结或是框架,支援资料格式如下:
- 储存在共享资源中的GeoJSON格式数据
- 开放街图中的线与多边形图征
- 提供或来自维基数据的坐标
- GeoJSON原始资料,最好从另一个页面嵌入
注意:
- 当前GeoJSON档案无法直接上传,而是需要在共享资源中创建一个命名空间为
Data:,并且以.map为结尾的页面——更多资讯请见mw:Help:Map Data。 - 为了能正确显示开放街图(OSM)图征,请在所对应的OSM关联输入Wikidata键值(并且等待1或2日)——更多资讯请见mw:Help:Extension:Kartographer#External_data与mw:Help:Extension:Kartographer/OSM。
使用方法
[编辑]基本使用
- 范例来自共享资源中的地图格式数据(来源:Data:ecos.fws.gov/Endangered habitat 58938/Plethodon neomexicanus.map):
{{maplink|from=}}(使用from=读取.map格式,不含前缀Data:)
- 范例来自GeoJSON原始资料(来源:{{Wikipedia:Map data/Main Roads Western Australia/Forrest Highway}}):
{{maplink|raw=}}(使用GeoJSON,建议将资料来源嵌入自Wikipedia:Map data)
- 来自开放街图(OSM):
- 想要显示在框架中,加入此参数
|frame=yes.
- 额外的参数可以用于客制化地图
完整参数 – data page
{{maplink
|display=
|from=
|zoom=
|text=
|icon=
}}
完整参数 – raw data
{{maplink
|display=
|raw= <!-- preferably {{Wikipedia:Map data/subpage}} -->
|zoom=
|text=
|icon=
}}
完整参数 – geoline/geoshape
{{maplink
|display=
|type=
|id=
|title=
|description=
|stroke-color=
|stroke-width=
|zoom=
|text=
|icon=
}}
完整参数 – 点/座标
{{maplink
|display=
|type=point
|id=
|title=
|description=
|coord=
|marker=
|zoom=
|text=
|icon=
}}
参数
[编辑]对于整体显示
[编辑]- display
- 显示模板。可用的参数;
inline- Only displays the inline link (you can forego this, as it is the default)title- Only displays the title linkinline,title- Displays the inline link as well as the title linktitle,inline- Same as above
- text
- 显示连结的文字或是地图框架的描述,预设是"Map"
- icon
- 设定
no可以关闭地图连结的图示 - zoom
- 放大等级,从
1到19(愈大距离愈近),预设是自动取决于地图
(Note that automatically determined zoom level does not work for mapframe maps except when previewing the page – see phab:T193455)
Mapframe parameters (only work with inline display)
- frame
- 设定
yes会取代连结变成地图框架- plain
- 设定
yes会显示没有外部框架(包含描述)的地图(text参数将会被忽略) - frame-align
- 用于页面对齐
left,center,或是right。预设是right - frame-width
- 地图框架宽度,预设是
300 - frame-height
- 地图框架高度,预设是
200 - frame-latitude
- (or frame-lat)
- Optional - alternate latitude coordinate for initial placement of map
- frame-longitude
- (or frame-long)
- Optional - alternate longitude coordinate for initial placement of map
- If frame latitude and longitude are not set by parameters, then coordinates in
|coord=will be used (if set), or coordinates will be retrieved from Wikidata (if available, for either the item specified in|id=parameter or for the page the template is placed on)
Raw GeoJSON
[编辑]- raw
- Raw GeoJSON (preferably transcluded from a subpage of Wikipedia:Map data) as well as <maplink> functionality not available via the other parameters. See below for more information.
对于各种特征
[编辑]Multiple features can be displayed on a single map. For each additional feature, add a sequential number to the end of the parameter name. For example, the second uses parameters like |type2=, |id2=, etc., the third feature |type3=, |id3=, etc., and so on.
- type
- Type of data. Valid values are:
line– a geoline feature from OSM (e.g. a road)shape– a geoshape feature from OSM (e.g. a state or province)shape-inverse– a geomask feature from OSM (the inverse of a geoshape - allows an unobstructed view of the map beneath)data– a geoJSON data page on Commons (parameter is optional in this case)point– a point feature (coordinates)
- id
- (or ids)
- Wikidata id (Q-number) of the point feature, Wikidata id that the OSM line/shape feature is tagged with. Separate multiple ids with a comma. Defaults to the current page's Wikidata id (if
|from=not set). - from
- The JSON (.map) file from Commons to display (excluding the
Data:prefix) - title
- Title of the feature (for features from OSM), displayed when the feature is clicked on; default is the page title
- description
- Description of the feature (for features from OSM), displayed when the feature is clicked on; optional
- stroke-color
- (or stroke-colour)
- Color code for the color used to draw the feature (for features from OSM); default is
#ff0000(red) - stroke-width
- Width for the lines used to draw the feature (for features from OSM); default is
6 - coord
- Coordinates to display for a point feature. Use {{Coord}} template to specify coordinates. If not set, coordinates will be retrieved from Wikidata.
- marker
- Name of Maki marker image to display at the point feature. See mw:Maps/Icons for options. If not set, a plain marker will be shown without an image.
- marker-color
- (or marker-colour)
- Color code (Hex triplet) specifying marker background color. Default is
5E74F3( )
多地图切换
[编辑]An option for Template:Switcher-style switching of multiple mapframes, where specified parameters like zoom, or frame coordinates, or a shape's item id are switched between different values. When using, ensure the number of values in each list are the same.
Instructions:
- Add parameter switch to specify labels for the different options: a list separated by either
,, or;if the labels contain commas, or###if the labels contain semi-colons. Each label will be displayed with a prefix of "Show ".- Example:
|switch=zoomed out, zoomed mid, zoomed in
- Example:
- For each parameter that is to be switched, set its value to SWITCH: followed by a list of values to switch between, again separated by
,or;or###- Example:
|zoom=SWITCH:4,9,14 - Parameters frame, plain, and text should not be switched
- Example:
- Make sure each list has the same number of entries. The position of value in a SWITCH: list corresponds to the same position in the list of labels set in
|switch=.
{{mapframe|frame=yes|type=point|id=Q100|text=Boston|zoom=SWITCH:4,9,14|switch=zoomed out, zoomed mid, zoomed in}}
范例
[编辑]Multiple features allow you to:
- Use external data from both Wikimedia Commons and OpenStreetMap together
- Apply different styles to different external data features from OpenStreetMap
- Include multiple links to external data from Wikimedia Commons
{{maplink
|text = [[高雄高工]]地理位置
|frame = yes
|zoom = 15
|type = point
|coord = {{Coord|22.649769|N|120.326540|E}}
|title = [[高雄市立高雄高級工業職業學校]]
|description = 簡稱高雄高工、雄工、KIHS,位於高雄市三民區的一所公立高職。
|type2 =shape
|id2 =Q15907921
|plain = yes
}}
多个地点

国立高雄科技大学各校区分布图
{{maplink
|text = [[國立高雄科技大學]]各校區分布圖
|frame = yes
|zoom = 10
|frame-width = 250
|frame-height = 400
|frame-align = right
|type3 = point
|coord3 = {{Coord|22.608539|120.272677|}}
|title3 = 國立高雄科技大學旗津校區
|description3 = [[高雄市]][[旗津區]]中洲三路482號
|type2 = point
|id2=Q6973907
|coord2 = {{Coord|22.649114|120.326640|}}
|title2 = 國立高雄科技大學建工校區
|description2 = [[高雄市]][[三民區]]建工路415號
|type = point
|coord = {{Coord|22.724591|120.314605|}}
|title = 國立高雄科技大學楠梓校區
|description = [[高雄市]][[楠梓區]]海專路142號
|type4 = point
|coord4 = {{Coord|22.754484|120.332831|}}
|title4 = 國立高雄科技大學第一校區
|description4 = [[高雄市]]<br>[[楠梓區]]卓越路2號<br>[[燕巢區]]大學路1號
|type5 = point
|coord5 = {{Coord|22.772374|120.398095|}}
|title5 = 國立高雄科技大學燕巢校區
|description5 = [[高雄市]][[燕巢區]]深中路58號
}}
{{Maplink|frame=yes
|type=shape|id=Q3495894|title=Shape|description=Description of shape
|type2=line|id2=Q1318331|title2=Line|description2=Description of line
|type3=point|coord3={{coord|32|S|116|E}}|title3=Point|description3=Description of point
}}
{{Maplink|frame=yes|plain=yes|frame-width=250|frame-height=280|zoom=6|frame-lat=29.185|frame-long=76.225
|type=shape-inverse|id=Q1174|title=Haryana
|type2=point|id2=Q200663|stroke-width=3|title2=Faridabad
}}
常见问题及解答
[编辑]Q1:为什么来自OpenStreetMap的线状或面状要素没有显示?
A1:有几种可能的原因:
- 根据mw:Help:Extension:Kartographer/OSM,OSM上的要素需要标记维基数据ID。仅在维基数据项上设置OSM关系标识符 (P402)是不够的。
- 只能使用某些OSM关系(类型为multipolygon、route、waterway和boundary的关系),而不能使用其他类型如建筑物和公共交通主干路线。请参阅mw:Help:Extension:Kartographer/OSM#Limitation和phab:T156433。
- 在OSM上标记后,可能需要1到2天数据才能在此处可用。
- 维基媒体偶尔在复制OSM数据时出现问题(例如phab:T218097),或因其他问题有意禁用复制(例如phab:T243609)
Q2:当底图出现问题时在哪里提交错误报告?(例如缺失湖泊)
A2:如果该问题也出现在OpenStreetMap上,则需要在OpenStreetMap上修复。如果问题仅出现在维基媒体地图上,可以在Phabricator上报告(您可以使用维基百科账户登录)。请参阅mw:How to report a bug获取操作说明(对于标签,请使用Maps)。(或者,您可以尝试mw:Help talk:Extension:Kartographer)
Q3:在哪里报告地图的其他错误或问题?
A3:这可能是维基百科模块的问题,也可能是底层软件的错误(这类错误很多)。
- 如果使用纯
<mapframe>...</mapframe>标签时也出现该问题,则应在Phabricator上报告(您可以使用维基百科账户登录)。请参阅mw:How to report a bug获取操作说明(对于标签,请使用Maps)。(或者,您可以尝试mw:Help talk:Extension:Kartographer) - 如果问题仅出现在维基百科的模板/模块中,或者您不确定,请在Wikipedia:互助客栈/技术报告。
Q4:为什么查看页面时缩略图地图呈现为静态图像,而编辑页面时却是交互式的?
A4:在维基百科以及除维基导游外的大多数wiki上,嵌入的缩略图是静态地图,需要打开全屏地图后才能进行缩放或平移。这是出于性能考虑,以便在禁用JavaScript时能显示某些内容,并方便打印。
预览模式显示交互式地图是一个错误,phab:T203863(也是一个性能问题)。更多解释可以在phab:T202793的评论中找到。
预览模式显示交互式地图是一个错误,phab:T203863(也是一个性能问题)。更多解释可以在phab:T202793的评论中找到。
Q5:为什么编辑或添加地图后,线状、面状或点状要素没有显示,尽管它们在页面预览中显示过?
A5:这是一个与生成缩略图图像相关的错误。它应该在一两个小时内自行修复。详情请参阅phab:T269984。
Q6:使用mapframe的
|raw=参数的页面显示“运行脚本的分配时间已到”的错误消息。该怎么办?A6:如果要处理的原始数据量过大,可能会显示该超时消息。您可以尝试将原始数据移至Commons(示例)或使用Special:ExpandTemplates将mapframe模板替换为等效的wikitext(示例)
重定向
[编辑]参见
[编辑]- en:Wikipedia:Maplink,有关此模板和类似模板的信息页
- Template:Mapbox,该模板的衍生版本,仅显示地图链接
- Template:Infobox mapframe,更简便的版本,用于信息框
- Template:Attached KML
- Template:Rapid transit OSM map








