Widget:Map: различия между версиями
Xunto (обсуждение | вклад) |
Xunto (обсуждение | вклад) |
||
| Строка 32: | Строка 32: | ||
map: 'test_map', | map: 'test_map', | ||
onRegionTipShow: function(e, el, code){ | onRegionTipShow: function(e, el, code){ | ||
| − | + | el.html(state_map[el.html()]) | |
} | } | ||
}); | }); | ||
}); | }); | ||
</script> | </script> | ||
Версия 04:05, 29 июля 2019
<script> var data = document.querySelector("#map_data").innerHTML; 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); var map = d.substring(s + 1, e);
d = d.substr(e + 3);
state_map[map] = page; } }
processData(data); </script>
<link rel="stylesheet" href="/resources/map/jquery-jvectormap-2.0.3.css" type="text/css" media="screen"/> <script src="/resources/map/jquery-3.4.1.min.js"></script> <script src="/resources/map/jquery-jvectormap-2.0.3.min.js"></script> <script src="/resources/map/test_map.js"></script>
<script> $(function(){ $('#world-map').vectorMap({ map: 'test_map', onRegionTipShow: function(e, el, code){ el.html(state_map[el.html()]) } }); }); </script>