Switch maps in Jvectormap?

拟墨画扇 提交于 2019-12-06 04:22:34

You can do what Alex Williams suggested and trigger a resize() on the Map container after showing it. Then it gets scaled before you can see it (at least if you fade in).

var $container = $('#yourHiddenMap');
map = new jvm.WorldMap({
    container: $container,
    map: ...
});
$('#yourSwitchButton').click(function() {
    $container.fadeIn().resize();
});

I didn't download the vectorMap library. However, it appears that you are loading the widget onto $('#world-map') each time openusmap() is called. I would initialize the widget only once on both the US and the world maps and use JQuery's toggle function to hide and show the maps. Alternatively, you could use the widget's destroy method or some equivalent.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!