Widget:Map: различия между версиями
Xunto (обсуждение | вклад) |
Xunto (обсуждение | вклад) |
||
| Строка 30: | Строка 30: | ||
function run_map () { | function run_map () { | ||
| − | |||
| − | |||
| − | |||
$('#world-map').vectorMap({ | $('#world-map').vectorMap({ | ||
map: 'test_map', | map: 'test_map', | ||
| Строка 47: | Строка 44: | ||
} | } | ||
| + | load("/resources/map/jquery-jvectormap-2.0.3.min.js"); | ||
| + | load("/resources/map/test_map.js"); | ||
processData(data); | processData(data); | ||
Версия 05:25, 29 июля 2019
<link rel="stylesheet" href="/resources/map/jquery-jvectormap-2.0.3.css" type="text/css" media="screen"/>
<script> var data = ""; var state_map = {};
function processData(d) { while (d.length > 0) { var s = d.indexOf("("); var e = d.indexOf(")");
var page = d.substring(0, s - 1).trim(); var map = d.substring(s + 1, e).split(",")[0].trim();
d = d.substr(e + 3);
state_map[map.toLowerCase()] = page; } }
function load(src) { ref = document.getElementsByTagName('script')[0]; var js = document.createElement('script'); js.type = 'text/javascript'; js.async = true; js.src = src; ref.parentNode.insertBefore(js, ref); }
function run_map () { $('#world-map').vectorMap({ map: 'test_map', onRegionClick: function(e, code) { var page = state_map[code.toLowerCase()]; if (page) window.open("/page/" + page); }, onRegionTipShow: function(e, tip, code){ var page = state_map[code.toLowerCase()]; if (page) tip.html(page) else tip.html(code); } }); }
load("/resources/map/jquery-jvectormap-2.0.3.min.js"); load("/resources/map/test_map.js"); processData(data);
if(window.addEventListener){ window.addEventListener('load', run_map) } else{ window.attachEvent('onload', run_map) } </script>