如何标记或识别jvectormap,以便可以调用该项中的功能更改?在我的情况下,我有一个jvectormap和一个按钮(不在地图上),我希望它像单击按钮时那样,可以将jvectormap的“ markersSelectable”更改为true:
<!DOCTYPE html>
<html>
<head>
<title>jVectorMap demo</title>
<link rel="stylesheet" href="jquery-jvectormap-1.0.css" type="text/css" media="screen"/>
<script src="jquery.js"></script>
<script src="jquery-jvectormap-1.0.min.js"></script>
<script src="jquery-jvectormap-world-mill-en.js"></script>
</head>
<body>
<form><input id="pan" type="button" value="Pan" /></form>
<div id="world-map" style="width: 600px; height: 400px"></div>
<script>
$(function(){
$('#world-map').vectorMap(
map: 'world_mill_en'
);
$('#pan').click(function() {
//change the jvectormap attribute "markersSelectable" to true
});
});
</script>
</body>
</html>
尝试清空元素,然后使用新属性重新加载它。以我的经验,它运作良好。
<script>
$(function(){
$('#world-map').vectorMap(
map: 'world_mill_en'
);
$('#pan').click(function() {
var map_object = $('#world-map').vectorMap('get', 'mapObject');
map_object.params.markersSelectable = false;
});
});
</script>
顺便说一句,您可能要使用1.2.2版本。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句