瀏覽代碼

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 = {};