Maps javascript api center issue

前端 未结 1 1714
鱼传尺愫
鱼传尺愫 2021-01-25 05:02

My problem is realy simple. After creating a map by using the following code, the center of the map is not well placed.

var myOptions = {
  center: new google.ma         


        
相关标签:
1条回答
  • 2021-01-25 05:38

    The problem is not in the code you provided. The "top left corner" issue is when the div that contains map doesn't have a size when the map is initialized. You haven't provided the HTML/CSS that specifies the size of the map (or that displays it if it is initially hidden).

    Another possibility is that you are initializing the map before DOM is completely rendered, you should be initializing it after the DOM ready or body onload event fires.

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