Google Map API inside a Reveal Modal not showing fully

后端 未结 5 1744
鱼传尺愫
鱼传尺愫 2020-12-21 08:34

I am having problems with a Google Map that I have inside a div, which upon button click, pops up on screen. The Google Map is only partially showing. I know that I need t

5条回答
  •  伪装坚强ぢ
    2020-12-21 09:33

    Following Two solutions worked for me

    function initialize() {
       var mapOptions = {
        center: new google.maps.LatLng(39.739318, -89.266507),
        zoom: 5,
        mapTypeId: google.maps.MapTypeId.ROADMAP
      };
      var map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
      return map;
    }
    
    
    ×
    $(document).ready(function() { var myMap; $('#myModal').bind('open', function() { if(!myMap) { var myMap = initialize(); setTimeout(function() { google.maps.event.trigger(myMap, 'resize'); }, 300); } }); }

    OR

    $(document).ready(function() {
      var myMap;
      $('#myModal').bind('opened', function() {
        if(!myMap) {
          var myMap = initialize();
          google.maps.event.addDomListener(window, 'load', initialize);
        }
      });
    });
    

提交回复
热议问题