Jquery 设置单个区域不可选择
我有一个数组,里面填充了地图上的区域Jquery 设置单个区域不可选择,jquery,maps,jvectormap,Jquery,Maps,Jvectormap,我有一个数组,里面填充了地图上的区域 var regions = [ {name: 'BE-WV', positions: true}, {name: 'BE-OV', positions: true}, {name: 'BE-AN', positions: false}, {name: 'BE-LI', positions: true}, {name: 'BE-VB', positions: true}, {name: 'BE-BR', posi
var regions = [
{name: 'BE-WV', positions: true},
{name: 'BE-OV', positions: true},
{name: 'BE-AN', positions: false},
{name: 'BE-LI', positions: true},
{name: 'BE-VB', positions: true},
{name: 'BE-BR', positions: true},
{name: 'BE-WB', positions: true},
{name: 'BE-HG', positions: true},
{name: 'BE-NA', positions: true},
{name: 'BE-LK', positions: true},
{name: 'BE-LX', positions: true},
];
我想知道是否有可能创建一个检查区域的函数。如果该区域有一个位置:true,它应该是可选的,否则它不应该
我已经创建了一个函数,它可以更改鼠标光标在悬停位置上的位置,以确定它是否可以选择
onRegionOver: function(event, code, region){
for (var i = 0; i < regions.length; i++) {
element = regions[i];
elementName = element['name'];
if ( elementName == code){
if (element['positions'] !== false){
document.body.style.cursor = 'pointer';
}
}
}
onRegionOver:函数(事件、代码、区域){
对于(变量i=0;i
我找到了一个解决方案,但这是一个相当粗糙的解决方案。
在onRegionClick函数中,检查单击的区域是否有错误位置
然后将此代码粘贴到if中
var m = $('#map').vectorMap('get', 'mapObject');
m.series.regions[0].elements[code].element.style.selected.fill = 'grey';
其中灰色是未选定区域的颜色