跳转到内容

模組: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)