Google 地图无法在 FancyBox(灯箱)内工作
如何在 Fancybox 灯箱内加载 Google 地图?当不在灯箱中时,地图加载正常。我只是使用他们网站上的标准谷歌地图代码:
<html>
<body>
<div id="map_canvas" style="width:100px; height:100px;"></div>
</body>
<script type="text/javascript">
function initialize() {
var myLatlng = new google.maps.LatLng(-36.8804280598958,
174.811848958333);
var myOptions = {
zoom: 13,
center: myLatlng,
mapTypeId: google.maps.MapTypeId.ROADMAP,
panControl: false,
zoomControl: false,
scaleControl: true,
mapTypeControl: false,
scaleControl: false
}
var map = new
google.maps.Map(document.getElementById("map_canvas"), myOptions); }
function loadScript() {
var script = document.createElement("script");
script.type = "text/javascript";
script.src =
"http://maps.google.com/maps/api/js?sensor=false&callback=initialize";
document.body.appendChild(script); }
window.onload = loadScript;
</script>
</html>
How do I get a Google Map to load inside the Fancybox lightbox? The map loads fine when not in the lightbox. I'm just using the standard Google maps code off their site:
<html>
<body>
<div id="map_canvas" style="width:100px; height:100px;"></div>
</body>
<script type="text/javascript">
function initialize() {
var myLatlng = new google.maps.LatLng(-36.8804280598958,
174.811848958333);
var myOptions = {
zoom: 13,
center: myLatlng,
mapTypeId: google.maps.MapTypeId.ROADMAP,
panControl: false,
zoomControl: false,
scaleControl: true,
mapTypeControl: false,
scaleControl: false
}
var map = new
google.maps.Map(document.getElementById("map_canvas"), myOptions); }
function loadScript() {
var script = document.createElement("script");
script.type = "text/javascript";
script.src =
"http://maps.google.com/maps/api/js?sensor=false&callback=initialize";
document.body.appendChild(script); }
window.onload = loadScript;
</script>
</html>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论