Angularjs jVectorMap是否使用新的参考地图更改/刷新地图?
我有一个包含映射的div,但是,我想更改一个属性,该属性将更新映射以对应对属性所做的更改。更具体地说,当我更改地图名称时,我希望div更改以反映这个新的地图名称。如果我绘制了智利地图,并将地图名称更改为巴西,我希望绘制巴西地图。请参阅下文了解更多内容。我已经尝试了Angularjs jVectorMap是否使用新的参考地图更改/刷新地图?,angularjs,html,jvectormap,Angularjs,Html,Jvectormap,我有一个包含映射的div,但是,我想更改一个属性,该属性将更新映射以对应对属性所做的更改。更具体地说,当我更改地图名称时,我希望div更改以反映这个新的地图名称。如果我绘制了智利地图,并将地图名称更改为巴西,我希望绘制巴西地图。请参阅下文了解更多内容。我已经尝试了.reset(),.updateSize(),以及一些其他建议的调整。。。什么都没起作用 app.directive('countrymap', ['$rootScope', function($rootScope) { re
.reset()
,.updateSize()
,以及一些其他建议的调整。。。什么都没起作用
app.directive('countrymap', ['$rootScope', function($rootScope)
{
return {
link: function(scope, element, attrs) {
$(element).width('auto'),
$(element).height(500),
$rootScope.$watch("countryMap", function (newCountry, oldCountry)
{
setTimeout( function()
{
var map = new jvm.Map(
{
container: $(element),
map: newCountry,
backgroundColor: 'transparent',
regionsSelectable: true,
regionsSelectableOne: true,
zoomButtons : false,
regionStyle:
{
selected:
{ fill: 'Red' }
}
});
}, 100);
})
}
};
}]);
我想我应该把我找到的解决这个问题的办法贴在你们这些经历同样挫折的人的身上。我决定使用
.remove()
来摆脱旧地图,只绘制一张新地图。有关修改后的代码,请参见下文
app.directive('countrymap', ['$rootScope', function($rootScope)
{
return {
link: function(scope, element, attrs) {
$(element).width('auto'),
$(element).height(500),
$rootScope.$watch("countryMap", function (newCountry, oldCountry)
{
setTimeout( function()
{
try { $(element).vectorMap('get', 'mapObject').remove(); }
catch(err) {}
var map = new jvm.Map(
{
container: $(element),
map: newCountry,
backgroundColor: 'transparent',
regionsSelectable: true,
regionsSelectableOne: true,
zoomButtons : false,
regionStyle:
{
selected:
{ fill: 'Red' }
}
});
}, 100);
})
}
};
}]);
我想我应该把我找到的解决这个问题的办法贴在你们这些经历同样挫折的人的身上。我决定使用
.remove()
来摆脱旧地图,只绘制一张新地图。有关修改后的代码,请参见下文
app.directive('countrymap', ['$rootScope', function($rootScope)
{
return {
link: function(scope, element, attrs) {
$(element).width('auto'),
$(element).height(500),
$rootScope.$watch("countryMap", function (newCountry, oldCountry)
{
setTimeout( function()
{
try { $(element).vectorMap('get', 'mapObject').remove(); }
catch(err) {}
var map = new jvm.Map(
{
container: $(element),
map: newCountry,
backgroundColor: 'transparent',
regionsSelectable: true,
regionsSelectableOne: true,
zoomButtons : false,
regionStyle:
{
selected:
{ fill: 'Red' }
}
});
}, 100);
})
}
};
}]);
我想我应该把我找到的解决这个问题的办法贴在你们这些经历同样挫折的人的身上。我决定使用
.remove()
来摆脱旧地图,只绘制一张新地图。有关修改后的代码,请参见下文
app.directive('countrymap', ['$rootScope', function($rootScope)
{
return {
link: function(scope, element, attrs) {
$(element).width('auto'),
$(element).height(500),
$rootScope.$watch("countryMap", function (newCountry, oldCountry)
{
setTimeout( function()
{
try { $(element).vectorMap('get', 'mapObject').remove(); }
catch(err) {}
var map = new jvm.Map(
{
container: $(element),
map: newCountry,
backgroundColor: 'transparent',
regionsSelectable: true,
regionsSelectableOne: true,
zoomButtons : false,
regionStyle:
{
selected:
{ fill: 'Red' }
}
});
}, 100);
})
}
};
}]);
我想我应该把我找到的解决这个问题的办法贴在你们这些经历同样挫折的人的身上。我决定使用
.remove()
来摆脱旧地图,只绘制一张新地图。有关修改后的代码,请参见下文
app.directive('countrymap', ['$rootScope', function($rootScope)
{
return {
link: function(scope, element, attrs) {
$(element).width('auto'),
$(element).height(500),
$rootScope.$watch("countryMap", function (newCountry, oldCountry)
{
setTimeout( function()
{
try { $(element).vectorMap('get', 'mapObject').remove(); }
catch(err) {}
var map = new jvm.Map(
{
container: $(element),
map: newCountry,
backgroundColor: 'transparent',
regionsSelectable: true,
regionsSelectableOne: true,
zoomButtons : false,
regionStyle:
{
selected:
{ fill: 'Red' }
}
});
}, 100);
})
}
};
}]);