Skip to content
This repository was archived by the owner on Nov 30, 2018. It is now read-only.
This repository was archived by the owner on Nov 30, 2018. It is now read-only.

map render problem in different tabs #1395

Closed

Description

@uguryilmaz

i have a tab control in my form. every tab page has its map object. first tab loads succesfully but maps in other tabs not loaded successfuly. here is plunker:

http://plnkr.co/edit/JUHRt5ogLcq0Eq6uo8n1?p=preview

Activity

  1. rummelsworth commented on Jul 21, 2015

    @rummelsworth
    Contributor

    The behavior is caused by the maps in unselected tabs being rendered into hidden elements. The correct approach is to prevent map creation until the elements that will show it aren't hidden. You can use tab's active attribute along with ng-if to help with this...

    However, this is really strange because the FAQ's recommendation to use ng-if doesn't seem to help. See updated plunker here: http://plnkr.co/edit/pmCPVhGeIPQnUFqmCcJF?p=preview

    Not sure what the problem is. Hopefully I'm missing something obvious. @cthrax thoughts?

  2. cthrax commented on Jul 21, 2015

    @cthrax
    Contributor

    The ng-if condition is changing in the same digest loop as the display of the tabs, so the DOM still hasn't had a chance to render. If you disconnect those conditions, which honestly feels a little weird semantically, it will render properly. See this plnkr for an example http://plnkr.co/edit/KatCddVOfefPw9c09yPM?p=preview

  3. rummelsworth commented on Jul 21, 2015

    @rummelsworth
    Contributor

    Nice 👍 I've learned another nuance of Angular's digestion...

    @uguryilmaz Follow up and reopen if this doesn't resolve the issue for you. Thanks.

  4. uguryilmaz commented on Jul 21, 2015

    @uguryilmaz
    Author

    thanks so much @cthrax and @wrummler . that solves my problem.

  5. nmccready commented on Jul 21, 2015

    @nmccready
    Contributor

    🎱

  6. SunPj commented on Aug 13, 2016

    @SunPj

    Sometimes just setting ng-if to true doesn't solve the problem. I use following code to refresh map.

    $scope.showMap = false;
    $timeout(function() {
        $scope.showMap = true;
    });
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions