Giter VIP home page Giter VIP logo

Comments (2)

stuporglue avatar stuporglue commented on June 12, 2024

Next round of updates I can look into this more closely, but for now,

What you'll want to call is mapobj.map.invalidateSize();.

You should be able to find the mapobj in window.leafletphp.maps, which is a dictionary. The map is given a random ID each time, so you could to do something like this:

jQuery('#mytabs').on('tabchange',function(e){  // <--- Or whatever the tab change event is
    for(mapobj in window.leafletphp.maps){
         mapobj.map.invalidateSize();
    }
});

from geometa-acf.

lizeidsness avatar lizeidsness commented on June 12, 2024

Thanks for the quick response! It generally worked, but I had to tweak a bit. I think the solution could be better, but this is all I can do for now. The click event of the tab was what I attached to, because i didn't now how to attach to the tab block being made visible. I added a delay though because on click the block isn't yet visible and invalidateSize wasn't working. Unless I clicked again.

Also The event fires twice when I click on the tab. No idea why. My selector is pretty specific.

This is what I ended up with:

jQuery("#acf-group_5a9ea4efe5997 .acf-tab-wrap [data-key='field_5a9ea930ce67f']").on("click",function(e){ 
  setTimeout(function() {
    for(mapobj in window.leafletphp.maps){
      m = window.leafletphp.maps[mapobj].map;
      m.invalidateSize();
    }
  }, 100);
});

from geometa-acf.

Related Issues (5)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.