Google Maps v3 load partially on top left corner, resize event does not work

后端 未结 7 1684
执笔经年
执笔经年 2020-11-30 03:28

Google Maps V3 loaded partially on top left corner. I tried the following methods:

  • Add google.maps.event.trigger(map, \'resize\'); after map in

7条回答
  •  情歌与酒
    2020-11-30 03:56

    I just got a similar issue (map loaded in container expanded with animation)

    As @Ian Devlin part of the solution is, is to trigger resize event after all is visible.
    The second part is to fix the center (as it is usually in the top left corner):

    google.maps.event.addListenerOnce(map, 'idle', function() {
       google.maps.event.trigger(map, 'resize');
       map.setCenter(center); // var center = new google.maps.LatLng(50,3,10.9);
    });
    

提交回复
热议问题