谷歌地图无法在FancyBox内工作(灯箱)

时间:2011-07-27 03:25:01

标签: google-maps fancybox lightbox

如何在Fancybox灯箱内加载Google地图?不在灯箱中时,地图加载正常。我只是在他们的网站上使用标准的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>

1 个答案:

答案 0 :(得分:5)