Keep a Google Maps v3 Map hidden, show when needed

后端 未结 8 965
北海茫月
北海茫月 2020-12-05 04:34

Is there a way of preventing a Google Maps (JS, v3) map being displayed from the get-go? I\'m doing some pre-processing and would like to show my \'Loading\' spinner until e

相关标签:
8条回答
  • 2020-12-05 05:19

    This will work

        google.maps.event.addListener(map, "idle", function ()
        {
            google.maps.event.trigger(map, 'resize');
        });
    
    0 讨论(0)
  • 2020-12-05 05:22

    another way to show the hidden map when map is first time rendering the <div> is to set style: visibility.

    When firstly hidden, use visibility = hidden; to show use visibility = visible

    the reason is: visibility:hidden means that the contents of the element will be invisible, but the element stays in its original position and size.

    0 讨论(0)
提交回复
热议问题