Toggle navigation
剑灵百科-剑灵wiki
页面
页面
讨论
编辑
查看历史
编辑源代码
操作
刷新
工具
页面信息
特殊页面
相关更改
链入页面
未登录
讨论
贡献
Toggle navigation
剑灵百科-剑灵wiki
编辑“
Widget:Map3/single
”
_>33961147
2024年1月31日 (三) 21:53的版本
(差异) ←上一版本 |
最后版本
(
差异
) |
下一版本→
(
差异
)
警告:您正在编辑的是本页面的旧版本。
如果您发布该更改,该版本后的所有更改都会丢失。
警告:
您没有登录。如果您做出任意编辑,您的IP地址将会公开可见。如果您
登录
或
创建
一个账户,您的编辑将归属于您的用户名,且将享受其他好处。
反垃圾检查。
不要
加入这个!
<includeonly> <style> #map-wrap .map-setting-btn { zoom: 0.8; font-size: 8px; width: 32px; height: 32px; } #map-wrap #map-menu .mapShrink { display: none; } </style> <style> .leaflet-container { background: rgb(23,75,86)!important; } .leaflet-control-attribution {display:none} .leaflet-left { transition: all 0.5s; } .leaflet-popup-content-wrapper {border-radius:0} .leaflet-bar a, .leaflet-bar a:hover { background: rgba(0, 0, 0, 0.8); color: #CED3DE; border: 0; } .leaflet-bar a:hover { background: rgba(33, 33, 33, 0.8); } .leaflet-pm-toolbar .control-icon { filter: invert() brightness(1.25); } #map-wrap { border: 1px solid rgba(0, 0, 0, 0.1) } </style> <script name="map.main.js"> var map; // 地图对象 var mapApi = new BwikiMapApi(); // 地图api var mapModel, self; var markTypeName = "<!--{$markTypeName}-->", markType; var bounds = [ [0,0],[0,0]]; var mapData = { getIconUrl : function (icon) { return `https://prod-patch-wiki.biligame.com/res/ys/map/icons/${icon}?v=${mapData.default.srcVersion}` }, getCenter: function () { // #接参数可以走缓存,而?会慢一些 var center = (util.getUrlValue('hash', 'center').replace(/ /g, '') || '').split(',') return center.length === 2 ? center : [0, 0] }, getCategoryData: function () { var categoryDataJson = $("#mapData #categoryData").text().trim(); if (categoryDataJson !== "") { categoryDataJson = JSON.parse(categoryDataJson) var categoryDataJsonExtension = $("#mapData #categoryDataExtension").text().trim(); if (categoryDataJsonExtension !== "") { categoryDataJsonExtension = JSON.parse(categoryDataJsonExtension) categoryDataJson = categoryDataJson.concat(categoryDataJsonExtension) } var categoryTemp = {}, categoryList = [], categoryData = [] $.each(categoryDataJson, function (i, v) { if(v.markTypeName !== markTypeName) return true; markType = v.markType; v.defaultShow = 1; v.icon = v.icon.indexOf("http") === 0 ? v.icon : mapData.getIconUrl(v.icon); if (!categoryTemp[v.type]) { categoryList.push(v.type) categoryTemp[v.type] = {name: v.type, data: []} } categoryTemp[v.type].data.push(v) }) $.each(categoryList, function (i, v) { categoryData[i] = categoryTemp[v] }) return categoryData } return [] }, setCategoryData: function (data) { data.length > 0 ? mapModel.setMarkerLayer(data) : mapModel.getMarkerList(); }, setMarkersData: function () { var data = $("#mapData #markersData").text().trim(); data = (new Function('return ' + (data || "[]")))(); data[0].markType = markType; bounds = [ [data[0].point.lat, data[0].point.lng], [data[0].point.lat, data[0].point.lng]]; $.each(data, function (i, p) { bounds[0][0] = Math.max(bounds[0][0], p.point.lat); bounds[0][1] = Math.min(bounds[0][1], p.point.lng); bounds[1][0] = Math.min(bounds[1][0], p.point.lat); bounds[1][1] = Math.max(bounds[1][1], p.point.lng) ; }) mapModel.markersData({[markType]:data}); window.afterSetMarkersData(); }, setMarkerWithInfo: function () { var data = $("#mapData #markerWithInfo").text().trim().replace(RegExp(`${mapModel.dataPrefix()}\\/point\\/`,"g"), "").split(", "); mapModel.markerWithInfo(data); }, getTileUrl: function(coords) { coords = function (coords) { var y = -coords.y + -1, r = Math.ceil((1 << coords.z - 1)/2); return ( -r <= coords.x && coords.x < r && -r <= y && y <= r - 1 && {x: coords.x, y: -coords.y + -1, z: coords.z}) }(coords); return coords ? `https://wiki-prod-patch-oss.oss-cn-hangzhou.aliyuncs.com/res/ys/map-4.4/tiles/${coords.z}/tile-${coords.x}_${coords.y}.png?v=${mapModel.srcVersion()}` : `https://prod-patch-wiki.biligame.com/res/ys/map/tiles/default.png?v=${mapModel.srcVersion()}`; }, setGeoData: function () { mapModel.areaData(JSON.parse($("#mapData #mapAreaData").text().trim())); // mapModel.routeData(JSON.parse($("#mapData #mapAreaData").text().trim())); }, } var $ready = function () { $.fn.swipe = swipe; $("#map-wrap").swipe(); mapApi.set({game: 'ys', site: mw.config.get("wgGameName"), dataPrefix: 'Data:Map'}) ko.applyBindings(mapModel = new MapModel(mapData.default = { game: 'ys', site: mw.config.get("wgGameName"), mapid: 'map3', dataPrefix: 'Data:Map', mapCenter: [-51.085105, 38.289228], srcVersion: '3.0.13', minZoom: 4, maxZoom: 7, isPhone: window.innerWidth < 540, toolbox: false, dataList: [], showMenu: false })); self = mapModel; var categoryData = mapData.getCategoryData(); window.afterSetMarkersData = function(){ mapModel.map.init(); mapData.setCategoryData(categoryData); mapData.setMarkerWithInfo(); mapData.setGeoData(); if(categoryData[0].name === "坐标"){ // bounds[0][0] += 1 // bounds[1][0] -= 0.5 var $tab = $("#"+mapData.default.mapid).parents(".resp-tabs"); if($tab.length>0) $tab.find(".bili-list-style").click(function(){map.invalidateSize(false)}) } else { bounds[0][0] += 2.2 bounds[1][0] -= 0.3 } map.fitBounds(bounds); window.onresize=function(){ if(window.innerWidth < 540 && !mapModel.isPhone()) return mapModel.isPhone(true) if(window.innerWidth >= 540 && mapModel.isPhone()) return mapModel.isPhone(false) } } if($("#mapData #markersData").text().trim()) { mapData.setMarkersData(); } else { $.ajax({ "url": "/" + mapData.default.site + "/" + mapData.default.dataPrefix + "/type/" + markType + "/json?action=raw", "success": function(data) { console.log(data); data = (new Function('return ' + (data || "[]")))(); data[0].markType = markType; bounds = [ [data[0].point.lat, data[0].point.lng], [data[0].point.lat, data[0].point.lng]]; $.each(data, function (i, p) { bounds[0][0] = Math.max(bounds[0][0], p.point.lat); bounds[0][1] = Math.min(bounds[0][1], p.point.lng); bounds[1][0] = Math.min(bounds[1][0], p.point.lat); bounds[1][1] = Math.max(bounds[1][1], p.point.lng) ; }) mapModel.markersData({[markType]:data}); afterSetMarkersData(); } }); } }; </script> <script>(function () {var t = function () {window.jQuery && window.mw ? mw.loader.load('ext.gadget.Map3') : window.setTimeout(t, 100); }; t(); })();</script> </includeonly>
摘要:
请注意,您对剑灵百科-剑灵wiki的所有贡献都可能被其他贡献者编辑,修改或删除。如果您不希望您的文字被任意修改和再散布,请不要提交。
您同时也要向我们保证您所提交的内容是您自己所作,或得自一个不受版权保护或相似自由的来源(参阅
bnswiki:版权
的细节)。
未经许可,请勿提交受版权保护的作品!
取消
编辑帮助
(在新窗口中打开)