Google地图在JavaScript弹出窗口中显示不正确 [英] Google Map is not displaying properly in javascript popup

查看:163
本文介绍了Google地图在JavaScript弹出窗口中显示不正确的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Google地图API在简单的JavaScript弹出窗口中显示地图。当弹出窗口打开时,它将显示如下:
使用Javascript弹出地图预览http:// 122.170.97.189:81/gmap/preview.png
我尝试使用jquery自动刷新div,如地图div:
$('#map')。fadeOut('slow')。负荷()淡入( 快);
刷新地图div,但仍然没有解决问题。
如果我在Chrome和Firefox中按F12,地图显示正确。

I'm using Google map API to display map in simple javascript popup. While popup opens it will display as below: Map Preview in Javascript Popup http://122.170.97.189:81/gmap/preview.png I tried auto refresh div using Jquery for map div like: $('#map').fadeOut('slow').load().fadeIn("fast"); It refresh the map div but still the problem is not solved. If I press F12 in chrome and firefox the map is displaying correctly.

推荐答案

在完全加载弹出窗口后,调用google maps代码来渲染地图。您应该在 $(document).ready()内调用 google.maps.Map() setTimeout())。

Call the google maps code to render the map after the popup is fully loaded. You should call google.maps.Map() inside $(document).ready() or after some timeout (setTimeout()).

当地图对象被创建时,它会试图找出画布的大小, popup没有完全加载,但它可能会得到错误的值。

When map object is created it tries to figure out how big the canvas is and if popup is not fully loaded yet it may get wrong values.

这篇关于Google地图在JavaScript弹出窗口中显示不正确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆