Jvectormap对div的改变非常小 [英] Jvectormap very small on div change

查看:118
本文介绍了Jvectormap对div的改变非常小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个div,一个是世界地图,一个是美国地图。当美国在世界地图上点击时,我想隐藏该div,并将美国地图放入视图中。



这可以工作,但地图很小,即使位置的缩放按钮表示div的大小是应该如何。




任何想法?



如果我有两个div设置从一开始就阻止它们都是正确的大小,它只是在调用代码来切换它失败的div时。

  onRegionClick:函数(事件,代码){
if(code ==US){openUS('us-map')}
},

函数openUS a){

document.getElementById(world-map)。style.display ='none';
document.getElementById(a).style.display ='block';
}


解决方案

这个问题是由事实上,您初始化隐藏元素的地图,其大小在当时无法正确计算。尝试改变你的逻辑,以便在元素变得可见之后,jVectorMap将被初始化。


I have two divs, one with the world map and one with the US map. When the USA is clicked on the world map I want to hide that div and bring the US map into view.

This works but the map is tiny, even though the position of the zoom buttons indicates the size of the div is how it should be.

Any ideas?

If I have both divs set to "block" from the start they are both the correct size, it's only when invoking code to switch the div that it fails.

onRegionClick: function(event, code){
                        if (code == "US") { openUS('us-map') }
            },

  function openUS(a) {

    document.getElementById("world-map").style.display = 'none';
    document.getElementById(a).style.display = 'block';
  }

解决方案

This issue is caused by the fact that you initialize map on the hidden element, whose size can't be calculated properly at that time. Try to change your logic so that jVectorMap would be initialized after the element becomes visible.

这篇关于Jvectormap对div的改变非常小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆