谷歌地图和Jquery.加载问题


Google Maps and Jquery .Load issue

在加载包含谷歌地图的页面内容方面,我遇到了一个似乎无法解决的问题。下面是包含父标题和googleapi信息的index.php页面。

<html>
<head>
    <script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery/jquery-1.7.2.min.js"></script>
    <!-- Google Maps -->
    <script src="http://maps.google.com/maps/api/js?sensor=false"></script>
    <script type="text/javascript">
      function initialize() {
        var mapOptions = {
          center: new google.maps.LatLng(-34.397, 150.644),
          zoom: 8,
          mapTypeId: google.maps.MapTypeId.ROADMAP
        };
        var map = new google.maps.Map(document.getElementById("location-wedding"),
            mapOptions);
      }
    </script>
    <!-- Switch Layout -->
    <script type="text/javascript">
        $(document).ready(function() {
            $('.Theme_Page').load("test.php");
        });
    </script>

</head> 

<body onload="initialize()">
    <!-- Page Change -->
    <div class="theme_holder">
    </div>
    <div class="Theme_Page">
        <!-- Content To Go Here -->
    </div>
</body>

正在加载的页面如下:

<div id="location-wedding" style="width:700px; height:250px"></div>

问题是,如果上面的div在index.php中,那么映射就存在,一旦它将其放置在要加载的页面中,它就根本不显示。我之所以希望它出现在.load()页面中,是因为我将使用Jquery更改该页面上的内容(带有onclick事件)

如有任何帮助或指导,我们将不胜感激。

为李加油。

正如yoda所说,初始化函数在load.php加载之前就开始了。因此,javascript不会在div中放入map,而不是从body onload调用initialize函数。您应该在load.php中调用此函数……尝试以下操作::从body中删除onload函数,并将以下javascript代码放在load.php 上

<script type="text/javascript">
    $(document).ready(function() {
        initialize()
    });
</script>

猜测,因为onload="initialize()"在加载test.phpdiv之前就开始了。将initialize()语句放入加载的页面中。