소스 검색

Js script que hace refresh del mapa oculto en un tab

Guillermo Espinoza 7 년 전
부모
커밋
3a15f63a11
1개의 변경된 파일18개의 추가작업 그리고 0개의 파일을 삭제
  1. 18 0
      Resources/public/js/leaflet-map.js

+ 18 - 0
Resources/public/js/leaflet-map.js

@@ -38,8 +38,26 @@ $(document).ready(function () {
     map.on('zoomend', function () {
         setDataValue();
     });
+    
 });
 
+// Espera que el tab mostrado tenga la clase CSS 'active' y hace un refresh del mapa
+// debido a que al estar oculto en un tab no se muestra con el tamaño correcto
+var tab_id;
+$('.nav-tabs a').on('click', function() {
+    tab_id = $(this).attr('href');
+    checkForChanges();
+});
+
+function checkForChanges()
+{
+    if ($(tab_id).hasClass('active')) {
+        map._onResize();
+    } else {
+        setTimeout(checkForChanges, 500);
+    }
+}
+
 function getDataCoords()
 {
     var jsonParseData = {};