如果是第一次来,按"Ctrl+D"可以收藏随时查看更新~觉得WIKI好玩的话,请推荐给朋友哦~(◕ω<)☆
按右上角“WIKI功能→编辑”即可修改页面内容,新建相应的图鉴页请点击
。
开新页面
复制地图核心代码:
<div id="mapData" style="display:none">
<div id="categoryData">{{:Data:Map/type/json}}</div>
<div id="markerWithInfo">{{:Data:Map/point/list}}, {{#ask:[[~Data:Map/point/*]][[!~*/json]]|link=none|limit=1000|offset=0|searchlabel=|sort=创建日期|order=desc}}, {{#ask:[[~Data:Map/point/*]][[!~*/json]]|link=none|limit=1000|offset=1000|searchlabel=|sort=创建日期|order=desc}}, {{#ask:[[~Data:Map/point/*]][[!~*/json]]|link=none|limit=1000|offset=2000|searchlabel=|sort=创建日期|order=desc}}, {{#ask:[[~Data:Map/point/*]][[!~*/json]]|link=none|limit=1000|offset=3000|searchlabel=|sort=创建日期|order=desc}}</div>
<div id="mapAreaData">
[
{"name":"提瓦特", "icon":"world", "inside":"", "geojson": null, "center": null},
{"name":"蒙德", "icon":"mengde", "inside":"蒙德", "geojson": {{:Data:Map/蒙德.json}}, "center": [19.88871, 4.312327]},
{"name":"璃月", "icon":"liyue", "inside":"璃月", "geojson": {{:Data:Map/璃月.json}}, "center": [-23.182214, -20.965561]},
{"name":"雪山", "icon":"xueshan", "inside":"雪山", "geojson": {{:Data:Map/雪山.json}}, "center": [2.301491, 0.448894]},
{"name":"稻妻", "icon":"daoqi", "inside":"稻妻", "geojson": {{:Data:Map/稻妻.json}}, "center": [-51.085105, 38.289228]}
]
</div>
</div>
<div>
{{#widget:Map3/css}}
{{#widget:Map3/icon}}
{{#widget:Map3/mapc}}
{{#widget:Map3/main}}
{{#widget:Md5}}
</div>
为新地图配置部分新参数
categoryData和markerWithInfo
修改Data:Map/type/json和Data:Map/point/*中Map字段,例如:
<div id="categoryData">{{:Data:Map/type/json}}</div>
<div id="markerWithInfo">{{:Data:Map/point/list}}, {{#ask:[[~Data:Map/point/*]][[!~*/json]]|link=none|limit=1000|offset=0|searchlabel=|sort=创建日期|order=desc}}, {{#ask:[[~Data:Map/point/*]][[!~*/json]]|link=none|limit=1000|offset=1000|searchlabel=|sort=创建日期|order=desc}}, {{#ask:[[~Data:Map/point/*]][[!~*/json]]|link=none|limit=1000|offset=2000|searchlabel=|sort=创建日期|order=desc}}, {{#ask:[[~Data:Map/point/*]][[!~*/json]]|link=none|limit=1000|offset=3000|searchlabel=|sort=创建日期|order=desc}}</div>
旧↑新↓,其中MapHD就是新地图的字段(此处HD代表金苹果岛)
<div id="categoryData">{{:Data:MapHD/type/json}}</div>
<div id="markerWithInfo">{{:Data:MapHD/point/list}}, {{#ask:[[~Data:MapHD/point/*]][[!~*/json]]|link=none|limit=1000|offset=0|searchlabel=|sort=创建日期|order=desc}}, {{#ask:[[~Data:MapHD/point/*]][[!~*/json]]|link=none|limit=1000|offset=1000|searchlabel=|sort=创建日期|order=desc}}, {{#ask:[[~Data:MapHD/point/*]][[!~*/json]]|link=none|limit=1000|offset=2000|searchlabel=|sort=创建日期|order=desc}}, {{#ask:[[~Data:MapHD/point/*]][[!~*/json]]|link=none|limit=1000|offset=3000|searchlabel=|sort=创建日期|order=desc}}</div>
mapAreaData
mapAreaData这部分控制地图分区,替换记得要留意json格式的完整和准确,例如“[]”和“,”,具体如何定义区域详见:(教程暂缺)
<div id="mapAreaData">
[
{"name":"提瓦特", "icon":"world", "inside":"", "geojson": null, "center": null},
{"name":"蒙德", "icon":"mengde", "inside":"蒙德", "geojson": {{:Data:Map/蒙德.json}}, "center": [19.88871, 4.312327]},
{"name":"璃月", "icon":"liyue", "inside":"璃月", "geojson": {{:Data:Map/璃月.json}}, "center": [-23.182214, -20.965561]},
{"name":"雪山", "icon":"xueshan", "inside":"雪山", "geojson": {{:Data:Map/雪山.json}}, "center": [2.301491, 0.448894]},
{"name":"稻妻", "icon":"daoqi", "inside":"稻妻", "geojson": {{:Data:Map/稻妻.json}}, "center": [-51.085105, 38.289228]}
]
</div>
如果地图不需要区域划分请保留这个格式↓
<div id="mapAreaData">
[]
</div>
widget
如果不需要额外修改样式,只需要修改widget:Map3/main这个widget即可,
{{#widget:Map3/css}}
{{#widget:Map3/icon}}
{{#widget:Map3/mapc}}
{{#widget:Map3/main}}
{{#widget:Md5}}
旧↑新↓,和上面一样widget:Map3/main改为widget:Map3HD/main(此处HD代表金苹果岛)
{{#widget:Map3/css}}
{{#widget:Map3/icon}}
{{#widget:Map3/mapc}}
{{#widget:Map3HD/main}}
{{#widget:Md5}}
新建修改参数后的新页面
如果如上修改都正确的话,应该最少新建3个页面来定义新的地图:
- Data:Map<-参数->/type/json,如何编辑详见:Map维护#主表
- Data:Map<-参数->/point.json,如何编辑详见:Map维护#调用全部的点位
- widget:Map3<-参数->/main
widget修改方法
从widget:Map3/main复制过来之后主要修改如下3处
地图底图地址,第95行
return coords ? `https://wiki-dev-patch-oss.oss-cn-hangzhou.aliyuncs.com/res/ys/map2.6-u-1/tiles/${coords.z}/tile-${coords.x}_${coords.y}.png?v=${mapModel.srcVersion()}` :
新地图参数,第114行和119行中的Data:Map部分参数和之前修改的参数保持一致(例如上面教程中统一把Map改为和MapHD)
var $ready = function () {
$.fn.swipe = swipe;
$("#map-wrap").swipe();
mapApi.set({game: 'ys', site: mw.config.get("wgGameName"), dataPrefix: 'Data:MapHD'})
ko.applyBindings(mapModel = new MapModel(mapData.default = {
game: 'ys',
site: mw.config.get("wgGameName"),
mapid: 'map3',
dataPrefix: 'Data:MapHD',
mapCenter: [-25.456657, -33.90622],
srcVersion: '3.0.13',
zoom: 6,
minZoom: 4,
maxZoom: 8,
isPhone: window.innerWidth < 540,
toolbox: mw.config.get("wgUserGroups").indexOf("sysop") !== -1,
dataList: ["point.json", "point2.json", "point3.json"]
}));
最后
如果如上三步都做完仍旧有问题,可以按如下步骤排查
- 建议仔细检查修改参数的字段是否有误,大小写是否一致
- json格式是不是缺少“,”或者“]”
- 修改widget时多删除了“'”