admin管理员组文章数量:1183200
I'm using the Google Maps API v3 for javascript. On certain cases I only see the map on the upper left corner. To see, please try going to and then pressing on one of the many lines.
I'm using the Google Maps API v3 for javascript. On certain cases I only see the map on the upper left corner. To see, please try going to http://telofast.com/telofun/#stationRanking and then pressing on one of the many lines.
Share Improve this question edited Oct 9, 2014 at 2:19 hichris123 10.2k15 gold badges57 silver badges70 bronze badges asked Jan 10, 2012 at 12:32 ronmeronme 1,1721 gold badge11 silver badges18 bronze badges5 Answers
Reset to default 17The map works when the browser is resized as the width and height are correctly set and the resize event is raised.
The quickest solution to your problem would be to call the resize method (below) after the javascript which reveals it. Maybe after showDiv('mapDiv');
in showScoresAndCenterOn
?
google.maps.event.trigger(map, 'resize');
To fix this you need to
Resize the map
google.maps.event.trigger(map, 'resize');
Recenter the map, where
myCenter
is your lat, lng point.map.setCenter(myCenter);
It's a bit of a hack but it works.
I had the same problem which kept me bothering for few days and today I found the solution and it worked!
In my case I used tabs to view different parts of my page. It wasn't jquery ui, I made it. In one tab i placed the map's code. When I clicked on the maps tab it showed me the map but broken one. Finally I figured out the problem and the solution.
To hide my elements I used display:none
property any to reveal I used display:block
property. When google map tried to get the dimension of the container block it found 0 x 0
because it was hidden. So the map showed as broken.
Then I changed my css for the map tab only to position:absolute;left:-99999px;
instead of display:none
and used jquery
to add a class and remove when necessary with the properties above. Then the code started to work! My map was fixed.
set containar #Div width to 100%.. it's work for me.
Perfect thanks , i turned into the same issue. And indeed when you put display:none this would give problems when trying to view google maps. I removed the display:none and changed it towards a position outside the screen, when clicking a button this position changes towards somewhere in the screen and my map is shown correctly
本文标签: javascriptMap sometimes appears only on upper left corner of its divStack Overflow
版权声明:本文标题:javascript - Map sometimes appears only on upper left corner of its div - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738275792a2072481.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论