2amigos / yii2-leaflet-extension

Yii 2 Extension library to display interactive maps with Leaflet .
http://yiiwheels.com
Other
30 stars 26 forks source link

Map in non-active tab is not rendered correctly #47

Open gb5256 opened 5 years ago

gb5256 commented 5 years ago

When I render the widget on a hidden tab, the map will not be rendered correctly. (There is a thread from 2014 here, but that code is not working anymore...).

I tried to add a listener to the tab-show event. That works, but I can not figure out how to access the map container. map.invalidateSize(false); should do it, but it throws "Map not definded"

Any ideas? Thanks, gb5256

tonydspaniard commented 5 years ago

The problem @gb5256 is that you need to refresh the map on tab view. The issue with hidden tabs is common with leafleft or google maps.

map. <--- Map is not defined. You need to make sure the map is initialized with a name if you wish to refer it afterwards on your code.