模板: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








