Jvectormap very small on div change

风流意气都作罢 提交于 2019-12-03 07:09:34
bjornd

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.

You also can add logic to your code that when container of your map appears code executes a method called updateSize. In particular this looks like:

$('$world-map').vectorMap('get','mapObject').updateSize();
silenzium

You can also trigger a resize() on the container of that map after showing it.

I made an example in this post: Switch maps in Jvectormap?

I was having the same issue with jVectorMap display sizing and found a way to get them to display properly.

The problem is when you create your map object. For it to display properly, the vectorMap object must be visible when you create it. That being said, when you put them in tabs, you should:

  1. Click first tab.
  2. Create first map.
  3. Click Second tab.
  4. Create Second map.. ..
    You can eventually click the first tab again so it's the active one on the page load.

Hope this helps anyone having the same issue.

The problem is that the div with the US map is hidden, therefore it cannot calculate the map size (width) correctly. Instead you can css that div to have the height:0.

I encountered this issue using Highcharts, same for jvectormap. Below code fixed the issue (using bootstrap):

/* bootstrap hack: fix content width inside hidden tabs */
.tab-content > .tab-pane:not(.active),
.pill-content > .pill-pane:not(.active) {
    display: block;
    height: 0;
    overflow-y: hidden;
} 
/* bootstrap hack end */
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!