Google Map shows only partially

后端 未结 7 1166
不思量自难忘°
不思量自难忘° 2020-12-11 01:19

The Google Map I have is only beeing rendered partially and is centered to the wrong point (it should center to the marker). See below:

7条回答
  •  旧时难觅i
    2020-12-11 02:08

    I found a simple solution for the partially loaded google map. Usually it is caused by the onLoad() being called at times when the rest of the page (including your map element) is not completely loaded. This causes partial map load. A simple way around this issue is to change your onLoad body tag action as follows:

    old: onload="initialize()"
    
    
    new: onLoad="setTimeout('initialize()', 2000);"
    

    this waits 2 sec. before the Google JavaScript accesses the correct size attributes. Hope this helps :)

    BTW, this is my top Javascipt part in case you wandering ( exactly as described in Google Documentation but because I am calling the Latitude and Longitude from PHP variables, hence the PHP snippets :)

    
            
    

提交回复
热议问题