<html>
<head>
<title>JQVMap - World Map</title>
<link href="../dist/jqvmap.css" media="screen" rel="stylesheet" type="text/css">
<script type="text/javascript" src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
<script type="text/javascript" src="../dist/jquery.vmap.js"></script>
<script type="text/javascript" src="../dist/maps/jquery.vmap.world.js" charset="utf-8"></script>
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery('#vmap').vectorMap({ map: 'world_en' });
});
</script>
</head>
<body>
<div id="vmap" style="width: 600px; height: 400px;"></div>
</body>
</html>上面代码是创建一个JQVMap。例如,我想要:单击USA并让页面转到特定的链接。法国也是如此。
发布于 2017-02-05 04:14:29
像这样扩展vectormap加载代码:
jQuery('#vmap').vectorMap({
map: 'world_en',
onRegionClick: function(element, code, region) {
if(code == 'us'){
window.location = "http://www.yoururl.com/US";
//do something else
}
if(code == 'fr'){
window.location = "http://www.yoururl.com/FR";
//do something else
}
}
});现在只需将URL替换为所需的URL即可。如果需要https://github.com/manifestinteractive/jqvmap/blob/master/REGIONS.md,您可以在此处找到所有国家/地区代码的列表。
发布于 2017-02-05 04:14:17
您可以使用onRegionClick处理程序来处理单击事件。
onRegionClick: function(event, code, region){
//Do something here
}您可以在documentation中找到更多信息
发布于 2017-02-05 06:41:01
jQuery('#vmap').vectorMap({ map:'world_en',onRegionClick: function(element,code,region) { if(code == 'us'){ window.location = "http://www.yoururl.com/US";//做其他事情} if(code == 'fr'){ window.location = "http://www.yoururl.com/FR";//做其他事情});
现在只需将URL替换为所需的URL即可。如果需要https://github.com/manifestinteractive/jqvmap/blob/master/REGIONS.md,您可以在此处找到所有国家/地区代码的列表。
https://stackoverflow.com/questions/42044967
复制相似问题