跳至內容

模組:Mapframe/doc

本頁使用了標題或全文手工轉換
維基百科,自由的百科全書

此頁面為 Module:Mapframe 的說明文件

本模組用於 {{Maplink}}

用法

[編輯]
標準用法
只需使用 {{Maplink}},它預設會將參數傳遞給此模組的主函數(main)。
如果使用 {{Maplink}} 渲染頁面時,Lua 的渲染時間在 5 秒到 10 秒之間,那麼使用類似 {{#tag:mapframe|[raw GeoJSON]|frameless=[1 for frame]|align=[left/right/center]|text=[caption]|width=[in px]|height=[in px]|latitude=[decimal degrees]|longitude=[decimal degrees]|zoom=[zoom factor]}} 的語法直接調用模組可以節省 Lua 的開銷。這種替換的範例見 https://en.wikipedia.org/w/index.php?diff=970846012 。這樣的代碼可以最大限度地降低後端伺服器繁忙時觸發 10 秒 Lua 超時的概率。


通過另一個模組使用
  1. 匯入此模組,例如 local mf = require('Module:Mapframe')
  2. 將參數名稱和值的表傳遞給 _main 函數。有關參數名稱和說明,請參閱 {{Maplink}} 文檔。例如 local mapframe = mf._main(parameters)
  3. 在返回 _main 的輸出之前對其進行預處理,例如 return frame:preprocess(mapframe)