Google map API doesn't display correctly jQuery slideToggle

前端 未结 2 1865
北海茫月
北海茫月 2021-01-16 15:50

I put Google Map inside a div, and made a slideToggle onto the div. the Google Map doesn\'t display correctly.

\

2条回答
  •  孤城傲影
    2021-01-16 16:20

    You could wait until the map is loaded by adding an event listener for idle. This event will fire once the map is fully loaded and ready.

    google.maps.event.addListenerOnce(map, 'idle', function() {
        $('.hide').hide();
    });
    

    Here's the JSFiddle.

    EDIT:

    For anyone with a similar problem, here is the updated JSFiddle with the map positioned offscreen so it remains hidden without using display:none.

提交回复
热议问题